Skip to content

Commit 734ca66

Browse files
authored
feat(ecs): add validation checks to memory cpu combinations of FARGATE compatible task definitions (#33608)
### Issue # (if applicable) Closes #22216 ### Reason for this change ### Description of changes Trying to fix the cause of regression by adding a validation to see if values are tokens #31106 Added a validateFargateTaskDefinitionMemoryCpu method in the base task definition and run this validation when a task definition has FARGATE in requiresCompatibilities. This is in line with the ECS requirement that even if a task definition has EC2 compatibility (along with FARGATE), FARGATE validations apply ### Description of how you validated changes unit and integ tests and also the [previous issue](#31106 (comment)) ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 5984ba2 commit 734ca66

25 files changed

+1200
-42
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/integ.fargate-task-def.js.snapshot/FargateTaskDefinitionDefaultTestDeployAssertD76B1D35.assets.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/integ.fargate-task-def.js.snapshot/FargateTaskDefinitionDefaultTestDeployAssertD76B1D35.template.json

+36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/integ.fargate-task-def.js.snapshot/aws-ecs-fargate-task-def.assets.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
{
2+
"Resources": {
3+
"TaskDefTaskRole1EDB4A67": {
4+
"Type": "AWS::IAM::Role",
5+
"Properties": {
6+
"AssumeRolePolicyDocument": {
7+
"Statement": [
8+
{
9+
"Action": "sts:AssumeRole",
10+
"Effect": "Allow",
11+
"Principal": {
12+
"Service": "ecs-tasks.amazonaws.com"
13+
}
14+
}
15+
],
16+
"Version": "2012-10-17"
17+
}
18+
}
19+
},
20+
"TaskDef54694570": {
21+
"Type": "AWS::ECS::TaskDefinition",
22+
"Properties": {
23+
"ContainerDefinitions": [
24+
{
25+
"Essential": true,
26+
"Image": "amazon/amazon-ecs-sample",
27+
"Name": "SampleContainer",
28+
"PortMappings": [
29+
{
30+
"ContainerPort": 80,
31+
"HostPort": 80,
32+
"Protocol": "tcp"
33+
}
34+
]
35+
}
36+
],
37+
"Cpu": "256",
38+
"Family": "awsecsfargatetaskdefTaskDef69F258AC",
39+
"Memory": "512",
40+
"NetworkMode": "awsvpc",
41+
"RequiresCompatibilities": [
42+
"FARGATE"
43+
],
44+
"TaskRoleArn": {
45+
"Fn::GetAtt": [
46+
"TaskDefTaskRole1EDB4A67",
47+
"Arn"
48+
]
49+
}
50+
}
51+
}
52+
},
53+
"Parameters": {
54+
"BootstrapVersion": {
55+
"Type": "AWS::SSM::Parameter::Value<String>",
56+
"Default": "/cdk-bootstrap/hnb659fds/version",
57+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
58+
}
59+
},
60+
"Rules": {
61+
"CheckBootstrapVersion": {
62+
"Assertions": [
63+
{
64+
"Assert": {
65+
"Fn::Not": [
66+
{
67+
"Fn::Contains": [
68+
[
69+
"1",
70+
"2",
71+
"3",
72+
"4",
73+
"5"
74+
],
75+
{
76+
"Ref": "BootstrapVersion"
77+
}
78+
]
79+
}
80+
]
81+
},
82+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
83+
}
84+
]
85+
}
86+
}
87+
}

packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/integ.fargate-task-def.js.snapshot/cdk.out

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/integ.fargate-task-def.js.snapshot/integ.json

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/integ.fargate-task-def.js.snapshot/manifest.json

+145
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)