Skip to content

Commit a9e286e

Browse files
authored
chore(cloudfront): encryption on distribution s3 loggingBucket (#19097)
#18264 got reverted in #18772 because of the BucketPolicy, re-submitting the **_non-BucketPolicy half of that PR_** ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 75f5b3b commit a9e286e

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

packages/@aws-cdk/aws-cloudfront/lib/distribution.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,9 @@ export class Distribution extends Resource implements IDistribution {
430430
throw new Error('Explicitly disabled logging but provided a logging bucket.');
431431
}
432432

433-
const bucket = props.logBucket ?? new s3.Bucket(this, 'LoggingBucket');
433+
const bucket = props.logBucket ?? new s3.Bucket(this, 'LoggingBucket', {
434+
encryption: s3.BucketEncryption.S3_MANAGED,
435+
});
434436
return {
435437
bucket: bucket.bucketRegionalDomainName,
436438
includeCookies: props.logIncludesCookies,

packages/@aws-cdk/aws-cloudfront/lib/web-distribution.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,9 @@ export class CloudFrontWebDistribution extends cdk.Resource implements IDistribu
954954
}
955955

956956
if (props.loggingConfig) {
957-
this.loggingBucket = props.loggingConfig.bucket || new s3.Bucket(this, 'LoggingBucket');
957+
this.loggingBucket = props.loggingConfig.bucket || new s3.Bucket(this, 'LoggingBucket', {
958+
encryption: s3.BucketEncryption.S3_MANAGED,
959+
});
958960
distributionConfig = {
959961
...distributionConfig,
960962
logging: {

packages/@aws-cdk/aws-cloudfront/test/integ.cloudfront-bucket-logging.expected.json

+11
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,17 @@
7575
},
7676
"AnAmazingWebsiteProbably2LoggingBucket222F7CE9": {
7777
"Type": "AWS::S3::Bucket",
78+
"Properties": {
79+
"BucketEncryption": {
80+
"ServerSideEncryptionConfiguration": [
81+
{
82+
"ServerSideEncryptionByDefault": {
83+
"SSEAlgorithm": "AES256"
84+
}
85+
}
86+
]
87+
}
88+
},
7889
"UpdateReplacePolicy": "Retain",
7990
"DeletionPolicy": "Retain"
8091
},

packages/@aws-cdk/aws-cloudfront/test/integ.distribution-extensive.expected.json

+11
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22
"Resources": {
33
"MyDistLoggingBucket9B8976BC": {
44
"Type": "AWS::S3::Bucket",
5+
"Properties": {
6+
"BucketEncryption": {
7+
"ServerSideEncryptionConfiguration": [
8+
{
9+
"ServerSideEncryptionByDefault": {
10+
"SSEAlgorithm": "AES256"
11+
}
12+
}
13+
]
14+
}
15+
},
516
"UpdateReplacePolicy": "Retain",
617
"DeletionPolicy": "Retain"
718
},

0 commit comments

Comments
 (0)