(synthetics): getbucketlocation policy is incorrect
See original GitHub issueSynthetics canary default role policy contains the incorrect arn syntax for a call to s3:GetBucketLocation
When using Synthetics runtime “syn-nodejs-puppeteer-3.1” the canary will try to call s3:GetBucketLocation
but with an improper policy which will result in denied access.
Reproduction Steps
minimal amount of code that causes the bug (if possible) or a reference:
The current implementation on master
is bugged:
new iam.PolicyStatement({
resources: [this.artifactsBucket.arnForObjects(`${prefix ? prefix+'/*' : '*'}`)],
actions: ['s3:PutObject', 's3:GetBucketLocation'],
})
What did you expect to happen?
Allow the “syn-nodejs-puppeteer-3.1” runtime to operate correctly without generating IAM access denied errors.
What actually happened?
The role will be denied access by IAM get call s3:GetBucketLocation
on that S3 bucket.
Environment
- CDK CLI Version :
- Framework Version:
- Node.js Version:
- OS :
- Language (Version):
Other
Should be fixed by creating a separate policy that breaks s3:GetBucketLocation
out into a separate policy that is targeted specifically at just the bucket arn:
new iam.PolicyStatement({
resources: [this.artifactsBucket.bucketArn],
actions: ['s3:GetBucketLocation'],
}),
new iam.PolicyStatement({
resources: [this.artifactsBucket.arnForObjects(`${prefix ? prefix+'/*' : '*'}`)],
actions: ['s3:PutObject'],
}),
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 3 years ago
- Reactions:9
- Comments:6 (5 by maintainers)
Top GitHub Comments
There is an open PR for a fix for this issue. Would it be possible to review that and merge?
Hello @NetaNir - thank you for taking the time to respond.
The specific runtime is
syn-nodejs-puppeteer-3.1
. When you manually create asyn-nodejs-puppeteer-3.1
based synthetic in the console, you get the following policy as the default IAM role attached to the canary.Versus the synthetics-cdk default role that gets provisioned is equivalent to:
The above policy generates the following error in the canary logs:
syn-nodejs-2.2
does not exhibit this error. The first runtime to produce theaccess denied
error issyn-nodejs-puppeteer-3.0
- so my best guess as to “how did it work till now?” is that section of the role policy was not getting exercised untilsyn-nodejs-puppeteer-3.0
was introduced.