Skip to content

Commit

Permalink
feat(ecs-patterns): add family name to queue processing service prope…
Browse files Browse the repository at this point in the history
…rties (#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
  • Loading branch information
Pk authored and mergify[bot] committed Oct 18, 2019
1 parent 7f4b5c5 commit b0874bb
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ export interface QueueProcessingServiceBaseProps {
* @default false
*/
readonly enableECSManagedTags?: boolean;

/**
* The name of a family that the task definition is registered to. A family groups multiple versions of a task definition.
*
* @default - Automatically generated name.
*/
readonly family?: string;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ export class QueueProcessingEc2Service extends QueueProcessingServiceBase {
super(scope, id, props);

// Create a Task Definition for the container to start
this.taskDefinition = new Ec2TaskDefinition(this, 'QueueProcessingTaskDef');
this.taskDefinition = new Ec2TaskDefinition(this, 'QueueProcessingTaskDef', {
family: props.family
});
this.taskDefinition.addContainer('QueueProcessingContainer', {
image: props.image,
memoryLimitMiB: props.memoryLimitMiB,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export class QueueProcessingFargateService extends QueueProcessingServiceBase {
this.taskDefinition = new FargateTaskDefinition(this, 'QueueProcessingTaskDef', {
memoryLimitMiB: props.memoryLimitMiB || 512,
cpu: props.cpu || 256,
family: props.family
});
this.taskDefinition.addContainer('QueueProcessingContainer', {
image: props.image,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ export = {
Image: "test",
Memory: 512
}
]
],
Family: "ServiceQueueProcessingTaskDef83DB34F1"
}));

test.done();
Expand Down Expand Up @@ -88,7 +89,8 @@ export = {
TEST_ENVIRONMENT_VARIABLE2: "test environment variable 2 value"
},
queue,
maxScalingCapacity: 5
maxScalingCapacity: 5,
family: "ecs-task-family"
});

// THEN - QueueWorker is of EC2 launch type, an SQS queue is created and all optional properties are set.
Expand Down Expand Up @@ -131,7 +133,8 @@ export = {
Image: "test",
Memory: 1024
}
]
],
Family: "ecs-task-family"
}));

test.done();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ export = {
},
Image: "test",
}
]
],
Family: "ServiceQueueProcessingTaskDef83DB34F1"
}));

test.done();
Expand Down Expand Up @@ -86,7 +87,8 @@ export = {
TEST_ENVIRONMENT_VARIABLE2: "test environment variable 2 value"
},
queue,
maxScalingCapacity: 5
maxScalingCapacity: 5,
family: "fargate-task-family"
});

// THEN - QueueWorker is of FARGATE launch type, an SQS queue is created and all optional properties are set.
Expand Down Expand Up @@ -126,7 +128,8 @@ export = {
],
Image: "test",
}
]
],
Family: "fargate-task-family"
}));

test.done();
Expand Down

0 comments on commit b0874bb

Please sign in to comment.