Skip to content

Commit

Permalink
fix(cloudfront): aliasConfiguration fallback identifier conflict (#4760)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimmy Gaussen authored and mergify[bot] committed Oct 31, 2019
1 parent d89504f commit 4d16f79
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
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 @@ -760,7 +760,7 @@ export class CloudFrontWebDistribution extends cdk.Construct implements IDistrib
const {acmCertRef, securityPolicy, sslMethod, names: aliases} = props.aliasConfiguration;

_viewerCertificate = ViewerCertificate.fromAcmCertificate(
certificatemanager.Certificate.fromCertificateArn(scope, 'AliasConfigurationCert', acmCertRef),
certificatemanager.Certificate.fromCertificateArn(this, 'AliasConfigurationCert', acmCertRef),
{ securityPolicy, sslMethod, aliases }
);
}
Expand Down
40 changes: 40 additions & 0 deletions packages/@aws-cdk/aws-cloudfront/test/test.basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,46 @@ export = {
test.done();
},

'allows multiple aliasConfiguration CloudFrontWebDistribution per stack'(test: Test) {
const stack = new cdk.Stack();
const s3BucketSource = new s3.Bucket(stack, 'Bucket');

const originConfigs = [{
s3OriginSource: {s3BucketSource},
behaviors: [{ isDefaultBehavior: true }]
}];

new CloudFrontWebDistribution(stack, 'AnAmazingWebsiteProbably', {
originConfigs,
aliasConfiguration: {acmCertRef: 'acm_ref', names: ['www.example.com']},
});
new CloudFrontWebDistribution(stack, 'AnotherAmazingWebsiteProbably', {
originConfigs,
aliasConfiguration: {acmCertRef: 'another_acm_ref', names: ['ftp.example.com']},
});

expect(stack).to(haveResourceLike('AWS::CloudFront::Distribution', {
"DistributionConfig": {
"Aliases": ["www.example.com"],
"ViewerCertificate": {
"AcmCertificateArn": "acm_ref",
"SslSupportMethod": "sni-only"
}
}
}));

expect(stack).to(haveResourceLike('AWS::CloudFront::Distribution', {
"DistributionConfig": {
"Aliases": ["ftp.example.com"],
"ViewerCertificate": {
"AcmCertificateArn": "another_acm_ref",
"SslSupportMethod": "sni-only"
}
}
}));
test.done();
},

'viewerCertificate': {
'acmCertificate': {
'base usage'(test: Test) {
Expand Down

0 comments on commit 4d16f79

Please sign in to comment.