Skip to content

Commit b0874bb

Browse files
Pkmergify[bot]
authored andcommitted
feat(ecs-patterns): add family name to queue processing service properties (#4508)
* feat(ecs-patterns): add support for specifying ECS task definition family name in queue processing ECS service constructs (#4507) * feat(ecs-patterns) renaming taskDefinitionFamily to family to be more inline with other taskdef properties * feat(ecs-patterns) adding unit tests to check if family name is autogenerated if not passed in
1 parent 7f4b5c5 commit b0874bb

File tree

5 files changed

+23
-7
lines changed

5 files changed

+23
-7
lines changed

packages/@aws-cdk/aws-ecs-patterns/lib/base/queue-processing-service-base.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ export interface QueueProcessingServiceBaseProps {
118118
* @default false
119119
*/
120120
readonly enableECSManagedTags?: boolean;
121+
122+
/**
123+
* The name of a family that the task definition is registered to. A family groups multiple versions of a task definition.
124+
*
125+
* @default - Automatically generated name.
126+
*/
127+
readonly family?: string;
121128
}
122129

123130
/**

packages/@aws-cdk/aws-ecs-patterns/lib/ecs/queue-processing-ecs-service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ export class QueueProcessingEc2Service extends QueueProcessingServiceBase {
7575
super(scope, id, props);
7676

7777
// Create a Task Definition for the container to start
78-
this.taskDefinition = new Ec2TaskDefinition(this, 'QueueProcessingTaskDef');
78+
this.taskDefinition = new Ec2TaskDefinition(this, 'QueueProcessingTaskDef', {
79+
family: props.family
80+
});
7981
this.taskDefinition.addContainer('QueueProcessingContainer', {
8082
image: props.image,
8183
memoryLimitMiB: props.memoryLimitMiB,

packages/@aws-cdk/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export class QueueProcessingFargateService extends QueueProcessingServiceBase {
7373
this.taskDefinition = new FargateTaskDefinition(this, 'QueueProcessingTaskDef', {
7474
memoryLimitMiB: props.memoryLimitMiB || 512,
7575
cpu: props.cpu || 256,
76+
family: props.family
7677
});
7778
this.taskDefinition.addContainer('QueueProcessingContainer', {
7879
image: props.image,

packages/@aws-cdk/aws-ecs-patterns/test/ec2/test.queue-processing-ecs-service.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ export = {
5959
Image: "test",
6060
Memory: 512
6161
}
62-
]
62+
],
63+
Family: "ServiceQueueProcessingTaskDef83DB34F1"
6364
}));
6465

6566
test.done();
@@ -88,7 +89,8 @@ export = {
8889
TEST_ENVIRONMENT_VARIABLE2: "test environment variable 2 value"
8990
},
9091
queue,
91-
maxScalingCapacity: 5
92+
maxScalingCapacity: 5,
93+
family: "ecs-task-family"
9294
});
9395

9496
// THEN - QueueWorker is of EC2 launch type, an SQS queue is created and all optional properties are set.
@@ -131,7 +133,8 @@ export = {
131133
Image: "test",
132134
Memory: 1024
133135
}
134-
]
136+
],
137+
Family: "ecs-task-family"
135138
}));
136139

137140
test.done();

packages/@aws-cdk/aws-ecs-patterns/test/fargate/test.queue-processing-fargate-service.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ export = {
5757
},
5858
Image: "test",
5959
}
60-
]
60+
],
61+
Family: "ServiceQueueProcessingTaskDef83DB34F1"
6162
}));
6263

6364
test.done();
@@ -86,7 +87,8 @@ export = {
8687
TEST_ENVIRONMENT_VARIABLE2: "test environment variable 2 value"
8788
},
8889
queue,
89-
maxScalingCapacity: 5
90+
maxScalingCapacity: 5,
91+
family: "fargate-task-family"
9092
});
9193

9294
// THEN - QueueWorker is of FARGATE launch type, an SQS queue is created and all optional properties are set.
@@ -126,7 +128,8 @@ export = {
126128
],
127129
Image: "test",
128130
}
129-
]
131+
],
132+
Family: "fargate-task-family"
130133
}));
131134

132135
test.done();

0 commit comments

Comments
 (0)