Skip to content

Commit a22e8cc

Browse files
authored
feat(ecs): support restart policy for container (#31228)
### Issue # (if applicable) Closes #31127 #31425. ### Reason for this change A restart policy can be specified in CloudFormation, but not in L2. https://docs.aws.amazon.com/AmazonECS/latest/developerguide/container-restart-policy.html ### Description of changes Add `enableRestartPolicy` and some properties to the container definition. ### Description of how you validated changes unit tests and integ tests. ### 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 218331b commit a22e8cc

12 files changed

+808
-0
lines changed

Diff for: packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.task-definition-container-restart-policy.js.snapshot/TaskDefinitionContainerRestartPolicyDefaultTestDeployAssert2196C660.assets.json

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

Diff for: packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.task-definition-container-restart-policy.js.snapshot/TaskDefinitionContainerRestartPolicyDefaultTestDeployAssert2196C660.template.json

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

Diff for: packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.task-definition-container-restart-policy.js.snapshot/aws-ecs-task-definition-container-restart-policy.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,88 @@
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": "public.ecr.aws/ecs-sample-image/amazon-ecs-sample:latest",
27+
"Name": "Container",
28+
"RestartPolicy": {
29+
"Enabled": true,
30+
"IgnoredExitCodes": [
31+
0,
32+
127
33+
],
34+
"RestartAttemptPeriod": 360
35+
}
36+
}
37+
],
38+
"Cpu": "256",
39+
"Family": "awsecstaskdefinitioncontainerrestartpolicyTaskDef3A6394C1",
40+
"Memory": "512",
41+
"NetworkMode": "awsvpc",
42+
"RequiresCompatibilities": [
43+
"FARGATE"
44+
],
45+
"TaskRoleArn": {
46+
"Fn::GetAtt": [
47+
"TaskDefTaskRole1EDB4A67",
48+
"Arn"
49+
]
50+
}
51+
}
52+
}
53+
},
54+
"Parameters": {
55+
"BootstrapVersion": {
56+
"Type": "AWS::SSM::Parameter::Value<String>",
57+
"Default": "/cdk-bootstrap/hnb659fds/version",
58+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
59+
}
60+
},
61+
"Rules": {
62+
"CheckBootstrapVersion": {
63+
"Assertions": [
64+
{
65+
"Assert": {
66+
"Fn::Not": [
67+
{
68+
"Fn::Contains": [
69+
[
70+
"1",
71+
"2",
72+
"3",
73+
"4",
74+
"5"
75+
],
76+
{
77+
"Ref": "BootstrapVersion"
78+
}
79+
]
80+
}
81+
]
82+
},
83+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
84+
}
85+
]
86+
}
87+
}
88+
}

Diff for: packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.task-definition-container-restart-policy.js.snapshot/cdk.out

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

Diff for: packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.task-definition-container-restart-policy.js.snapshot/integ.json

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

Diff for: packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.task-definition-container-restart-policy.js.snapshot/manifest.json

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

0 commit comments

Comments
 (0)