Skip to content

Commit

Permalink
fix(cloudfront): logging bucket uses regional domain name
Browse files Browse the repository at this point in the history
According to the CloudFront docs, the logging bucket should be specified as the
bucket domain name. #2554 updated origin buckets to use the regional bucket
domain names -- which is correct -- but also incorrectly updated the logging
bucket specifications as well.

This has a minor impact of being unable to navigate to the logging bucket from
the CloudFront console, but otherwise the logs are stored correctly.

fixes #10512
  • Loading branch information
njlynch committed Sep 28, 2020
1 parent 350105a commit 688d4d8
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-cloudfront/lib/distribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ export class Distribution extends Resource implements IDistribution {

const bucket = props.logBucket ?? new s3.Bucket(this, 'LoggingBucket');
return {
bucket: bucket.bucketRegionalDomainName,
bucket: bucket.bucketDomainName,
includeCookies: props.logIncludesCookies,
prefix: props.logFilePrefix,
};
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-cloudfront/lib/web_distribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ export class CloudFrontWebDistribution extends cdk.Resource implements IDistribu
distributionConfig = {
...distributionConfig,
logging: {
bucket: this.loggingBucket.bucketRegionalDomainName,
bucket: this.loggingBucket.bucketDomainName,
includeCookies: props.loggingConfig.includeCookies || false,
prefix: props.loggingConfig.prefix,
},
Expand Down
8 changes: 4 additions & 4 deletions packages/@aws-cdk/aws-cloudfront/test/distribution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ test('exhaustive example of props renders correctly', () => {
HttpVersion: 'http1.1',
IPV6Enabled: false,
Logging: {
Bucket: { 'Fn::GetAtt': ['MyDistLoggingBucket9B8976BC', 'RegionalDomainName'] },
Bucket: { 'Fn::GetAtt': ['MyDistLoggingBucket9B8976BC', 'DomainName'] },
IncludeCookies: true,
Prefix: 'logs/',
},
Expand Down Expand Up @@ -402,7 +402,7 @@ describe('logging', () => {
expect(stack).toHaveResourceLike('AWS::CloudFront::Distribution', {
DistributionConfig: {
Logging: {
Bucket: { 'Fn::GetAtt': ['MyDistLoggingBucket9B8976BC', 'RegionalDomainName'] },
Bucket: { 'Fn::GetAtt': ['MyDistLoggingBucket9B8976BC', 'DomainName'] },
},
},
});
Expand All @@ -419,7 +419,7 @@ describe('logging', () => {
expect(stack).toHaveResourceLike('AWS::CloudFront::Distribution', {
DistributionConfig: {
Logging: {
Bucket: { 'Fn::GetAtt': ['MyLoggingBucket4382CD04', 'RegionalDomainName'] },
Bucket: { 'Fn::GetAtt': ['MyLoggingBucket4382CD04', 'DomainName'] },
},
},
});
Expand All @@ -437,7 +437,7 @@ describe('logging', () => {
expect(stack).toHaveResourceLike('AWS::CloudFront::Distribution', {
DistributionConfig: {
Logging: {
Bucket: { 'Fn::GetAtt': ['MyDistLoggingBucket9B8976BC', 'RegionalDomainName'] },
Bucket: { 'Fn::GetAtt': ['MyDistLoggingBucket9B8976BC', 'DomainName'] },
IncludeCookies: true,
Prefix: 'logs/',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"Bucket": {
"Fn::GetAtt": [
"Bucket83908E77",
"RegionalDomainName"
"DomainName"
]
},
"IncludeCookies": true,
Expand Down Expand Up @@ -109,7 +109,7 @@
"Bucket": {
"Fn::GetAtt": [
"AnAmazingWebsiteProbably2LoggingBucket222F7CE9",
"RegionalDomainName"
"DomainName"
]
},
"IncludeCookies": false
Expand Down Expand Up @@ -146,4 +146,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"Bucket": {
"Fn::GetAtt": [
"MyDistLoggingBucket9B8976BC",
"RegionalDomainName"
"DomainName"
]
},
"IncludeCookies": true,
Expand Down

0 comments on commit 688d4d8

Please sign in to comment.