Skip to content

Commit 54d8a84

Browse files
authored
feat(synthetics): add maxRetries prop to configure automatic retries on canary runs (#34541)
### Issue # (if applicable) Closes #34511. ### Reason for this change Adds support for configuring automatic retries of Canary runs. ### Description of changes This adds a `maxRetries` property on the top-level of the CanaryProps interface. It uses this to configure the `retryConfig` structure on the `schedule` structure. This works similarly to how the `timeToLive` property configures the `durationInSeconds` field on the `schedule` structure. ### Describe any new or updated permissions being added N/A ### Description of how you validated changes I have updated the unit and integ tests, and have deployed manually, and verified the changes in the AWS console. ### 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 123afbe commit 54d8a84

File tree

17 files changed

+937
-1
lines changed

17 files changed

+937
-1
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-retry.js.snapshot/SyntheticsCanaryRetryDefaultTestDeployAssert341E434F.assets.json

Lines changed: 20 additions & 0 deletions
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-synthetics/test/integ.canary-retry.js.snapshot/SyntheticsCanaryRetryDefaultTestDeployAssert341E434F.template.json

Lines changed: 36 additions & 0 deletions
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-synthetics/test/integ.canary-retry.js.snapshot/SyntheticsCanaryRetryStack.assets.json

Lines changed: 34 additions & 0 deletions
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,242 @@
1+
{
2+
"Resources": {
3+
"RetryCanaryArtifactsBucket96F3BE6A": {
4+
"Type": "AWS::S3::Bucket",
5+
"Properties": {
6+
"BucketEncryption": {
7+
"ServerSideEncryptionConfiguration": [
8+
{
9+
"ServerSideEncryptionByDefault": {
10+
"SSEAlgorithm": "aws:kms"
11+
}
12+
}
13+
]
14+
}
15+
},
16+
"UpdateReplacePolicy": "Retain",
17+
"DeletionPolicy": "Retain"
18+
},
19+
"RetryCanaryArtifactsBucketPolicy381668A7": {
20+
"Type": "AWS::S3::BucketPolicy",
21+
"Properties": {
22+
"Bucket": {
23+
"Ref": "RetryCanaryArtifactsBucket96F3BE6A"
24+
},
25+
"PolicyDocument": {
26+
"Statement": [
27+
{
28+
"Action": "s3:*",
29+
"Condition": {
30+
"Bool": {
31+
"aws:SecureTransport": "false"
32+
}
33+
},
34+
"Effect": "Deny",
35+
"Principal": {
36+
"AWS": "*"
37+
},
38+
"Resource": [
39+
{
40+
"Fn::GetAtt": [
41+
"RetryCanaryArtifactsBucket96F3BE6A",
42+
"Arn"
43+
]
44+
},
45+
{
46+
"Fn::Join": [
47+
"",
48+
[
49+
{
50+
"Fn::GetAtt": [
51+
"RetryCanaryArtifactsBucket96F3BE6A",
52+
"Arn"
53+
]
54+
},
55+
"/*"
56+
]
57+
]
58+
}
59+
]
60+
}
61+
],
62+
"Version": "2012-10-17"
63+
}
64+
}
65+
},
66+
"RetryCanaryServiceRole6EAC7F33": {
67+
"Type": "AWS::IAM::Role",
68+
"Properties": {
69+
"AssumeRolePolicyDocument": {
70+
"Statement": [
71+
{
72+
"Action": "sts:AssumeRole",
73+
"Effect": "Allow",
74+
"Principal": {
75+
"Service": "lambda.amazonaws.com"
76+
}
77+
}
78+
],
79+
"Version": "2012-10-17"
80+
},
81+
"Policies": [
82+
{
83+
"PolicyDocument": {
84+
"Statement": [
85+
{
86+
"Action": "s3:ListAllMyBuckets",
87+
"Effect": "Allow",
88+
"Resource": "*"
89+
},
90+
{
91+
"Action": "s3:GetBucketLocation",
92+
"Effect": "Allow",
93+
"Resource": {
94+
"Fn::GetAtt": [
95+
"RetryCanaryArtifactsBucket96F3BE6A",
96+
"Arn"
97+
]
98+
}
99+
},
100+
{
101+
"Action": "s3:PutObject",
102+
"Effect": "Allow",
103+
"Resource": {
104+
"Fn::Join": [
105+
"",
106+
[
107+
{
108+
"Fn::GetAtt": [
109+
"RetryCanaryArtifactsBucket96F3BE6A",
110+
"Arn"
111+
]
112+
},
113+
"/*"
114+
]
115+
]
116+
}
117+
},
118+
{
119+
"Action": "cloudwatch:PutMetricData",
120+
"Condition": {
121+
"StringEquals": {
122+
"cloudwatch:namespace": "CloudWatchSynthetics"
123+
}
124+
},
125+
"Effect": "Allow",
126+
"Resource": "*"
127+
},
128+
{
129+
"Action": [
130+
"logs:CreateLogGroup",
131+
"logs:CreateLogStream",
132+
"logs:PutLogEvents"
133+
],
134+
"Effect": "Allow",
135+
"Resource": {
136+
"Fn::Join": [
137+
"",
138+
[
139+
"arn:",
140+
{
141+
"Ref": "AWS::Partition"
142+
},
143+
":logs:",
144+
{
145+
"Ref": "AWS::Region"
146+
},
147+
":",
148+
{
149+
"Ref": "AWS::AccountId"
150+
},
151+
":log-group:/aws/lambda/cwsyn-*"
152+
]
153+
]
154+
}
155+
}
156+
],
157+
"Version": "2012-10-17"
158+
},
159+
"PolicyName": "canaryPolicy"
160+
}
161+
]
162+
}
163+
},
164+
"RetryCanary3B0C27B7": {
165+
"Type": "AWS::Synthetics::Canary",
166+
"Properties": {
167+
"ArtifactS3Location": {
168+
"Fn::Join": [
169+
"",
170+
[
171+
"s3://",
172+
{
173+
"Ref": "RetryCanaryArtifactsBucket96F3BE6A"
174+
}
175+
]
176+
]
177+
},
178+
"Code": {
179+
"Handler": "canary.handler",
180+
"S3Bucket": {
181+
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
182+
},
183+
"S3Key": "5178413cfe8db00b2d5dcfa9be417e934c64601d0da3031d88c145c8293bc27f.zip"
184+
},
185+
"ExecutionRoleArn": {
186+
"Fn::GetAtt": [
187+
"RetryCanaryServiceRole6EAC7F33",
188+
"Arn"
189+
]
190+
},
191+
"Name": "retry",
192+
"RunConfig": {
193+
"MemoryInMB": 2048,
194+
"TimeoutInSeconds": 240
195+
},
196+
"RuntimeVersion": "syn-python-selenium-5.1",
197+
"Schedule": {
198+
"DurationInSeconds": "0",
199+
"Expression": "rate(5 minutes)",
200+
"RetryConfig": {
201+
"MaxRetries": 2
202+
}
203+
},
204+
"StartCanaryAfterCreation": true
205+
}
206+
}
207+
},
208+
"Parameters": {
209+
"BootstrapVersion": {
210+
"Type": "AWS::SSM::Parameter::Value<String>",
211+
"Default": "/cdk-bootstrap/hnb659fds/version",
212+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
213+
}
214+
},
215+
"Rules": {
216+
"CheckBootstrapVersion": {
217+
"Assertions": [
218+
{
219+
"Assert": {
220+
"Fn::Not": [
221+
{
222+
"Fn::Contains": [
223+
[
224+
"1",
225+
"2",
226+
"3",
227+
"4",
228+
"5"
229+
],
230+
{
231+
"Ref": "BootstrapVersion"
232+
}
233+
]
234+
}
235+
]
236+
},
237+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
238+
}
239+
]
240+
}
241+
}
242+
}

0 commit comments

Comments
 (0)