diff --git a/packages/aws-cdk-lib/aws-ecs/lib/base/base-service.ts b/packages/aws-cdk-lib/aws-ecs/lib/base/base-service.ts index eaf5172d17536..984a234c0abdc 100644 --- a/packages/aws-cdk-lib/aws-ecs/lib/base/base-service.ts +++ b/packages/aws-cdk-lib/aws-ecs/lib/base/base-service.ts @@ -504,6 +504,9 @@ export class EbsVolume extends Construct { } } + /** + * Render for CloudFormation property. + */ public render(): CfnService.ServiceVolumeConfigurationProperty[] | undefined { if (!this) { return; diff --git a/packages/aws-cdk-lib/aws-ecs/test/task-definition.test.ts b/packages/aws-cdk-lib/aws-ecs/test/task-definition.test.ts index 2b4bad0b5d5a1..922346451fa60 100644 --- a/packages/aws-cdk-lib/aws-ecs/test/task-definition.test.ts +++ b/packages/aws-cdk-lib/aws-ecs/test/task-definition.test.ts @@ -315,6 +315,30 @@ describe('task definition', () => { Template.fromStack(stack); }).toThrow("ECS Container Container must have at least one of 'memoryLimitMiB' or 'memoryReservationMiB' specified"); }); + + test('A task definition with EC2 and configuredAtLaunch', () => { + // GIVEN + const stack = new cdk.Stack(); + + // WHEN + const def = new ecs.TaskDefinition(stack, 'TD', { + cpu: '512', + memoryMiB: '512', + compatibility: ecs.Compatibility.EC2_AND_FARGATE, + }); + def.addVolume({ + name: 'volume', + configuredAtLaunch: true, + }); + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::ECS::TaskDefinition', { + Volumes: [{ + Name: 'volume', + ConfiguredAtLaunch: true, + }], + }); + }); }); describe('When importing from an existing Task definition', () => {