Skip to content

Commit

Permalink
fix(cloudfront): all origin access identities have identical names (#…
Browse files Browse the repository at this point in the history
…9829)

Replaces the single hard-coded value for the origin access identity comment
field with one that refernces the origin's ID.

fixes #9580


----

*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 committed Aug 19, 2020
1 parent 34450b0 commit ca79188
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion packages/@aws-cdk/aws-cloudfront-origins/lib/s3-origin.ts
Expand Up @@ -58,7 +58,9 @@ class S3BucketOrigin extends cloudfront.OriginBase {

public bind(scope: cdk.Construct, options: cloudfront.OriginBindOptions): cloudfront.OriginBindConfig {
if (!this.originAccessIdentity) {
this.originAccessIdentity = new cloudfront.OriginAccessIdentity(scope, 'S3Origin');
this.originAccessIdentity = new cloudfront.OriginAccessIdentity(scope, 'S3Origin', {
comment: `Access identity for ${options.originId}`,
});
this.bucket.grantRead(this.originAccessIdentity);
}
return super.bind(scope, options);
Expand Down
Expand Up @@ -60,7 +60,7 @@
"Type": "AWS::CloudFront::CloudFrontOriginAccessIdentity",
"Properties": {
"CloudFrontOriginAccessIdentityConfig": {
"Comment": "Allows CloudFront to reach the bucket"
"Comment": "Access identity for cloudfrontorigingroupDistributionOrigin137659A54"
}
}
},
Expand Down
Expand Up @@ -60,7 +60,7 @@
"Type": "AWS::CloudFront::CloudFrontOriginAccessIdentity",
"Properties": {
"CloudFrontOriginAccessIdentityConfig": {
"Comment": "Allows CloudFront to reach the bucket"
"Comment": "Access identity for cloudfronts3originDistributionOrigin1741C4E95"
}
}
},
Expand Down
Expand Up @@ -54,7 +54,7 @@ describe('With bucket', () => {

expect(stack).toHaveResourceLike('AWS::CloudFront::CloudFrontOriginAccessIdentity', {
CloudFrontOriginAccessIdentityConfig: {
Comment: 'Allows CloudFront to reach the bucket',
Comment: 'Access identity for StackDistOrigin15754CE84',
},
});
expect(stack).toHaveResourceLike('AWS::S3::BucketPolicy', {
Expand Down

0 comments on commit ca79188

Please sign in to comment.