Skip to content

Commit 5ff59d9

Browse files
authored
feat(synthetics): add support for tag replication for aws synthetics (#34830)
### Issue # (if applicable) Closes #34811 Related: aws-cloudformation/cloudformation-coverage-roadmap#1101 ### Reason for this change Support for tag propagation to underlying resources (Lambda) for AWS Synthetics. ### Description of changes Add support for `ResourcesToReplicateTags` property (like [CF](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-synthetics-canary.html)) ### Describe any new or updated permissions being added / ### Description of how you validated changes - Added unit test - Added integration test ### 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 6cd1802 commit 5ff59d9

File tree

17 files changed

+1062
-1
lines changed

17 files changed

+1062
-1
lines changed

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

0 commit comments

Comments
 (0)