Skip to content

Commit

Permalink
fix(cloudfront): logging bucket uses global domain name (#10945)
Browse files Browse the repository at this point in the history
This reverts #10570. The logging buckets were originally using the regional
domain names, but this caused odd behavior with CloudFront's new console "Logs"
experience. #10570 switched logging buckets to use the global domain name, which
addressed the console issue but broke customers in CN regions.

We will follow up internally to improve the CloudFront console issue.

fixes #10923


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
njlynch authored Oct 20, 2020
1 parent dd81e77 commit aa3f3fd
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 @@ -419,7 +419,7 @@ export class Distribution extends Resource implements IDistribution {

const bucket = props.logBucket ?? new s3.Bucket(this, 'LoggingBucket');
return {
bucket: bucket.bucketDomainName,
bucket: bucket.bucketRegionalDomainName,
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 @@ -899,7 +899,7 @@ export class CloudFrontWebDistribution extends cdk.Resource implements IDistribu
distributionConfig = {
...distributionConfig,
logging: {
bucket: this.loggingBucket.bucketDomainName,
bucket: this.loggingBucket.bucketRegionalDomainName,
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 @@ -79,7 +79,7 @@ test('exhaustive example of props renders correctly', () => {
HttpVersion: 'http1.1',
IPV6Enabled: false,
Logging: {
Bucket: { 'Fn::GetAtt': ['MyDistLoggingBucket9B8976BC', 'DomainName'] },
Bucket: { 'Fn::GetAtt': ['MyDistLoggingBucket9B8976BC', 'RegionalDomainName'] },
IncludeCookies: true,
Prefix: 'logs/',
},
Expand Down Expand Up @@ -411,7 +411,7 @@ describe('logging', () => {
expect(stack).toHaveResourceLike('AWS::CloudFront::Distribution', {
DistributionConfig: {
Logging: {
Bucket: { 'Fn::GetAtt': ['MyDistLoggingBucket9B8976BC', 'DomainName'] },
Bucket: { 'Fn::GetAtt': ['MyDistLoggingBucket9B8976BC', 'RegionalDomainName'] },
},
},
});
Expand All @@ -428,7 +428,7 @@ describe('logging', () => {
expect(stack).toHaveResourceLike('AWS::CloudFront::Distribution', {
DistributionConfig: {
Logging: {
Bucket: { 'Fn::GetAtt': ['MyLoggingBucket4382CD04', 'DomainName'] },
Bucket: { 'Fn::GetAtt': ['MyLoggingBucket4382CD04', 'RegionalDomainName'] },
},
},
});
Expand All @@ -446,7 +446,7 @@ describe('logging', () => {
expect(stack).toHaveResourceLike('AWS::CloudFront::Distribution', {
DistributionConfig: {
Logging: {
Bucket: { 'Fn::GetAtt': ['MyDistLoggingBucket9B8976BC', 'DomainName'] },
Bucket: { 'Fn::GetAtt': ['MyDistLoggingBucket9B8976BC', 'RegionalDomainName'] },
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",
"DomainName"
"RegionalDomainName"
]
},
"IncludeCookies": true,
Expand Down Expand Up @@ -109,7 +109,7 @@
"Bucket": {
"Fn::GetAtt": [
"AnAmazingWebsiteProbably2LoggingBucket222F7CE9",
"DomainName"
"RegionalDomainName"
]
},
"IncludeCookies": false
Expand Down Expand Up @@ -146,4 +146,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"Bucket": {
"Fn::GetAtt": [
"MyDistLoggingBucket9B8976BC",
"DomainName"
"RegionalDomainName"
]
},
"IncludeCookies": true,
Expand Down

0 comments on commit aa3f3fd

Please sign in to comment.