Skip to content

Commit

Permalink
fix(s3): autoDeleteObjects had redundant GetObject* permissions (a…
Browse files Browse the repository at this point in the history
…ws#14573)

This should fix  aws#14572.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
berenddeboer authored and hollanddd committed Aug 26, 2021
1 parent 90b6623 commit 4db5fff
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-s3/lib/bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1841,7 +1841,8 @@ export class Bucket extends BucketBase {
// objects in the bucket
this.addToResourcePolicy(new iam.PolicyStatement({
actions: [
...perms.BUCKET_READ_ACTIONS, // list objects
// list objects
...perms.BUCKET_READ_METADATA_ACTIONS,
...perms.BUCKET_DELETE_ACTIONS, // and then delete them
],
resources: [
Expand Down
5 changes: 5 additions & 0 deletions packages/@aws-cdk/aws-s3/lib/perms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ export const BUCKET_READ_ACTIONS = [
's3:List*',
];

export const BUCKET_READ_METADATA_ACTIONS = [
's3:GetBucket*',
's3:List*',
];

export const LEGACY_BUCKET_PUT_ACTIONS = [
's3:PutObject*',
's3:Abort*',
Expand Down
1 change: 0 additions & 1 deletion packages/@aws-cdk/aws-s3/test/bucket.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2385,7 +2385,6 @@ describe('bucket', () => {
'Statement': [
{
'Action': [
's3:GetObject*',
's3:GetBucket*',
's3:List*',
's3:DeleteObject*',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"Statement": [
{
"Action": [
"s3:GetObject*",
"s3:GetBucket*",
"s3:List*",
"s3:DeleteObject*"
Expand Down

0 comments on commit 4db5fff

Please sign in to comment.