Skip to content

Commit b69a699

Browse files
committed
fix: add listBucket permission to s3 policy
Signed-off-by: Arjun Raja Yogidas <arjunry@amazon.com>
1 parent d1a0647 commit b69a699

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/artifact-bucket-cloudfront.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ export class ArtifactBucketCloudfrontStack extends cdk.Stack {
1818
const artifactBucket = new s3.Bucket(this, 'ArtifactBucket', {
1919
bucketName,
2020
publicReadAccess: false,
21-
blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL
21+
blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL,
22+
enforceSSL: true
2223
});
2324

2425
// upload the file for integration testing puporse

lib/cloudfront_cdn.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ export class CloudfrontCdn extends Construct {
2020

2121
props.bucket.addToResourcePolicy(
2222
new iam.PolicyStatement({
23-
actions: ['s3:GetObject'],
24-
resources: [props.bucket.arnForObjects('*')],
23+
actions: ['s3:GetObject', 's3:ListBucket'],
24+
resources: [
25+
props.bucket.bucketArn, // arn:aws:s3:::bucket-name
26+
props.bucket.arnForObjects('*') // arn:aws:s3:::bucket-name/*
27+
],
2528
principals: [new iam.CanonicalUserPrincipal(cloudfrontOAI.cloudFrontOriginAccessIdentityS3CanonicalUserId)]
2629
})
2730
);

0 commit comments

Comments
 (0)