Describe the bug
When adding the packedByCpu() PlacementStrategy to a new ecs service, the cf template generated has the Property
"PlacementStrategies": [{
"Field": "cpu",
"Type": "binpack"
}]
However this will cause the Stack to drift as CF only allows CPU spelled in uppercase.
See here: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ecs-service-placementstrategy.html
Expected Behavior
CDK should generate the "Field" attribute of "PlacementStrategies" according to CF demands.
In the CF Template PlacementStrategies should look like this:
"PlacementStrategies": [{
"Field": "CPU",
"Type": "binpack"
}],
Current Behavior
CDK generates the "Field" attribute of "PlacementStrategies" NOT according to CF demands but instead spells it in lowercase.
In the CF Template PlacementStrategies actually looks like this:
"PlacementStrategies": [{
"Field": "cpu",
"Type": "binpack"
}],
Reproduction Steps
-
Generate a fresh cdk project with cdk init app --language=typescript -j
-
in the lib/project-name-stack.ts add a ecs service to a cluster with the PlacementStrategy set:
import { aws_ecs, aws_ec2, Stack, StackProps } from 'aws-cdk-lib';
import { Construct } from 'constructs';
export class VanillaCdkStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const vpc = new aws_ec2.Vpc(this, 'Vpc', { maxAzs: 2 });
const cluster = new aws_ecs.Cluster(this, 'EcsCluster', { vpc });
cluster.addCapacity('DefaultAutoScalingGroup', {
instanceType: aws_ec2.InstanceType.of(aws_ec2.InstanceClass.T2, aws_ec2.InstanceSize.MICRO)
});
const taskDefinition = new aws_ecs.Ec2TaskDefinition(this, 'TaskDef');
const container = taskDefinition.addContainer('web', {
image: aws_ecs.ContainerImage.fromRegistry("amazon/amazon-ecs-sample"),
memoryLimitMiB: 256,
});
const service = new aws_ecs.Ec2Service(this, "Test_Stack",{
cluster,
taskDefinition,
placementStrategies: [
aws_ecs.PlacementStrategy.packedByCpu(), // <--- here
]
});
}
}
- run cdk synth
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.28.1 (build d035432)
Framework Version
No response
Node.js Version
v16.14.2
OS
Windows 10 Enterprise 21H2
Language
Typescript
Language Version
No response
Other information
No response
Describe the bug
When adding the packedByCpu() PlacementStrategy to a new ecs service, the cf template generated has the Property
However this will cause the Stack to drift as CF only allows CPU spelled in uppercase.
See here: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ecs-service-placementstrategy.html
Expected Behavior
CDK should generate the "Field" attribute of "PlacementStrategies" according to CF demands.
In the CF Template PlacementStrategies should look like this:
Current Behavior
CDK generates the "Field" attribute of "PlacementStrategies" NOT according to CF demands but instead spells it in lowercase.
In the CF Template PlacementStrategies actually looks like this:
Reproduction Steps
Generate a fresh cdk project with
cdk init app --language=typescript -jin the lib/project-name-stack.ts add a ecs service to a cluster with the PlacementStrategy set:
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.28.1 (build d035432)
Framework Version
No response
Node.js Version
v16.14.2
OS
Windows 10 Enterprise 21H2
Language
Typescript
Language Version
No response
Other information
No response