Skip to content

Commit e743525

Browse files
authored
fix(synthetics): correct getbucketlocation policy (#13573)
When using synthetics runtime "syn-nodejs-puppeteer-3.1" the default role tries to call s3:getBucketLocation on the artifacts bucket, but the policy is incorrect to allow that action. The policy should allow for that call directly on the bucket arn. fixes #13572 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent b48ff22 commit e743525

File tree

3 files changed

+82
-29
lines changed

3 files changed

+82
-29
lines changed

packages/@aws-cdk/aws-synthetics/lib/canary.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,13 @@ export class Canary extends cdk.Resource {
299299
resources: ['*'],
300300
actions: ['s3:ListAllMyBuckets'],
301301
}),
302+
new iam.PolicyStatement({
303+
resources: [this.artifactsBucket.bucketArn],
304+
actions: ['s3:GetBucketLocation'],
305+
}),
302306
new iam.PolicyStatement({
303307
resources: [this.artifactsBucket.arnForObjects(`${prefix ? prefix+'/*' : '*'}`)],
304-
actions: ['s3:PutObject', 's3:GetBucketLocation'],
308+
actions: ['s3:PutObject'],
305309
}),
306310
new iam.PolicyStatement({
307311
resources: ['*'],

packages/@aws-cdk/aws-synthetics/test/integ.asset.expected.json

+22-8
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,17 @@
4141
"Resource": "*"
4242
},
4343
{
44-
"Action": [
45-
"s3:PutObject",
46-
"s3:GetBucketLocation"
47-
],
44+
"Action": "s3:GetBucketLocation",
45+
"Effect": "Allow",
46+
"Resource": {
47+
"Fn::GetAtt": [
48+
"MyCanaryArtifactsBucket89975E6D",
49+
"Arn"
50+
]
51+
}
52+
},
53+
{
54+
"Action": "s3:PutObject",
4855
"Effect": "Allow",
4956
"Resource": {
5057
"Fn::Join": [
@@ -197,10 +204,17 @@
197204
"Resource": "*"
198205
},
199206
{
200-
"Action": [
201-
"s3:PutObject",
202-
"s3:GetBucketLocation"
203-
],
207+
"Action": "s3:GetBucketLocation",
208+
"Effect": "Allow",
209+
"Resource": {
210+
"Fn::GetAtt": [
211+
"MyCanaryArtifactsBucket89975E6D",
212+
"Arn"
213+
]
214+
}
215+
},
216+
{
217+
"Action": "s3:PutObject",
204218
"Effect": "Allow",
205219
"Resource": {
206220
"Fn::Join": [

packages/@aws-cdk/aws-synthetics/test/integ.canary.expected.json

+55-20
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,17 @@
3030
"Resource": "*"
3131
},
3232
{
33-
"Action": [
34-
"s3:PutObject",
35-
"s3:GetBucketLocation"
36-
],
33+
"Action": "s3:GetBucketLocation",
34+
"Effect": "Allow",
35+
"Resource": {
36+
"Fn::GetAtt": [
37+
"mytestbucket8DC16178",
38+
"Arn"
39+
]
40+
}
41+
},
42+
{
43+
"Action": "s3:PutObject",
3744
"Effect": "Allow",
3845
"Resource": {
3946
"Fn::Join": [
@@ -210,10 +217,17 @@
210217
"Resource": "*"
211218
},
212219
{
213-
"Action": [
214-
"s3:PutObject",
215-
"s3:GetBucketLocation"
216-
],
220+
"Action": "s3:GetBucketLocation",
221+
"Effect": "Allow",
222+
"Resource": {
223+
"Fn::GetAtt": [
224+
"MyCanaryOneArtifactsBucketDF4A487D",
225+
"Arn"
226+
]
227+
}
228+
},
229+
{
230+
"Action": "s3:PutObject",
217231
"Effect": "Allow",
218232
"Resource": {
219233
"Fn::Join": [
@@ -424,10 +438,17 @@
424438
"Resource": "*"
425439
},
426440
{
427-
"Action": [
428-
"s3:PutObject",
429-
"s3:GetBucketLocation"
430-
],
441+
"Action": "s3:GetBucketLocation",
442+
"Effect": "Allow",
443+
"Resource": {
444+
"Fn::GetAtt": [
445+
"MyCanaryTwoArtifactsBucket79B179B6",
446+
"Arn"
447+
]
448+
}
449+
},
450+
{
451+
"Action": "s3:PutObject",
431452
"Effect": "Allow",
432453
"Resource": {
433454
"Fn::Join": [
@@ -638,10 +659,17 @@
638659
"Resource": "*"
639660
},
640661
{
641-
"Action": [
642-
"s3:PutObject",
643-
"s3:GetBucketLocation"
644-
],
662+
"Action": "s3:GetBucketLocation",
663+
"Effect": "Allow",
664+
"Resource": {
665+
"Fn::GetAtt": [
666+
"MyCanaryThreeArtifactsBucket894E857E",
667+
"Arn"
668+
]
669+
}
670+
},
671+
{
672+
"Action": "s3:PutObject",
645673
"Effect": "Allow",
646674
"Resource": {
647675
"Fn::Join": [
@@ -852,10 +880,17 @@
852880
"Resource": "*"
853881
},
854882
{
855-
"Action": [
856-
"s3:PutObject",
857-
"s3:GetBucketLocation"
858-
],
883+
"Action": "s3:GetBucketLocation",
884+
"Effect": "Allow",
885+
"Resource": {
886+
"Fn::GetAtt": [
887+
"MyPythonCanaryArtifactsBucket7AE88133",
888+
"Arn"
889+
]
890+
}
891+
},
892+
{
893+
"Action": "s3:PutObject",
859894
"Effect": "Allow",
860895
"Resource": {
861896
"Fn::Join": [

0 commit comments

Comments
 (0)