Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove omitEmptyArray default in Ec2Service constructor #27572

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion design/aws-ecs/aws-ecs-tagging-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export class Ec2Service extends BaseService implements IEc2Service, elb.ILoadBal
{
cluster: props.cluster.clusterName,
taskDefinition: props.taskDefinition.taskDefinitionArn,
placementConstraints: Lazy.anyValue({ produce: () => this.constraints }, { omitEmptyArray: true }),
placementConstraints: Lazy.anyValue({ produce: () => this.constraints }),
placementStrategies: Lazy.anyValue({ produce: () => this.strategies }, { omitEmptyArray: true }),
schedulingStrategy: props.daemon ? 'DAEMON' : 'REPLICA',
}, props.taskDefinition);
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/aws-ecs/lib/ec2/ec2-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export class Ec2Service extends BaseService implements IEc2Service {
{
cluster: props.cluster.clusterName,
taskDefinition: props.deploymentController?.type === DeploymentControllerType.EXTERNAL ? undefined : props.taskDefinition.taskDefinitionArn,
placementConstraints: Lazy.any({ produce: () => this.constraints }, { omitEmptyArray: true }),
placementConstraints: Lazy.any({ produce: () => this.constraints }),
placementStrategies: Lazy.any({ produce: () => this.strategies }, { omitEmptyArray: true }),
schedulingStrategy: props.daemon ? 'DAEMON' : 'REPLICA',
}, props.taskDefinition);
Expand Down
26 changes: 26 additions & 0 deletions packages/aws-cdk-lib/aws-ecs/test/ec2/ec2-service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1853,6 +1853,32 @@ describe('ec2 service', () => {
});
});

test('with an empty list in placement constraints', () => {
// GIVEN
const stack = new cdk.Stack();
const vpc = new ec2.Vpc(stack, 'MyVpc', {});
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
addDefaultCapacityProvider(cluster, stack, vpc);
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef');

taskDefinition.addContainer('web', {
image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
memoryLimitMiB: 512,
});

new ecs.Ec2Service(stack, 'Ec2Service', {
cluster,
taskDefinition,
placementConstraints: [],
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::ECS::Service', {
PlacementConstraints: Match.arrayEquals([]),
});

});

testDeprecated('with both propagateTags and propagateTaskTagsFrom defined', () => {
// GIVEN
const stack = new cdk.Stack();
Expand Down
Loading