Skip to content

Commit

Permalink
fix(route53): dummy hosted zone has right name (#2995)
Browse files Browse the repository at this point in the history
Be sure that the dummy hosted zone props that are returned before
the actual lookup is done have the right domain name already. This is
necessary to make DnsValidateCertificate's validation check succeed.

Fixes #2076.
  • Loading branch information
rix0rrr authored Jun 21, 2019
1 parent 5282a08 commit 76b5309
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, haveResource } from '@aws-cdk/assert';
import { PublicHostedZone } from '@aws-cdk/aws-route53';
import { Stack } from '@aws-cdk/cdk';
import { HostedZone, PublicHostedZone } from '@aws-cdk/aws-route53';
import { App, Stack } from '@aws-cdk/cdk';
import { Test } from 'nodeunit';
import { DnsValidatedCertificate } from '../lib/dns-validated-certificate';

Expand Down Expand Up @@ -123,4 +123,35 @@ export = {
}));
test.done();
},

'works with imported zone'(test: Test) {
// GIVEN
const app = new App();
const stack = new Stack(app, 'Stack', {
env: { account: '12345678', region: 'us-blue-5' },
});
const imported = HostedZone.fromLookup(stack, 'ExampleDotCom', {
domainName: 'mydomain.com',
});

// WHEN
new DnsValidatedCertificate(stack, 'Cert', {
domainName: 'mydomain.com',
hostedZone: imported,
});

// THEN
expect(stack).to(haveResource('AWS::CloudFormation::CustomResource', {
ServiceToken: {
'Fn::GetAtt': [
'CertCertificateRequestorFunction98FDF273',
'Arn'
]
},
DomainName: 'mydomain.com',
HostedZoneId: 'DUMMY'
}));

test.done();
},
};
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-route53/lib/hosted-zone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class HostedZone extends Resource implements IHostedZone {
public static fromLookup(scope: Construct, id: string, query: HostedZoneProviderProps): IHostedZone {
const DEFAULT_HOSTED_ZONE: HostedZoneContextResponse = {
Id: '/hostedzone/DUMMY',
Name: 'example.com',
Name: query.domainName,
};

interface HostedZoneContextResponse {
Expand Down

0 comments on commit 76b5309

Please sign in to comment.