diff --git a/packages/@aws-cdk/aws-certificatemanager/test/test.dns-validated-certificate.ts b/packages/@aws-cdk/aws-certificatemanager/test/test.dns-validated-certificate.ts index e6c39428962b6..5a07f63069e03 100644 --- a/packages/@aws-cdk/aws-certificatemanager/test/test.dns-validated-certificate.ts +++ b/packages/@aws-cdk/aws-certificatemanager/test/test.dns-validated-certificate.ts @@ -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'; @@ -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(); + }, }; diff --git a/packages/@aws-cdk/aws-route53/lib/hosted-zone.ts b/packages/@aws-cdk/aws-route53/lib/hosted-zone.ts index bba51a08e06f4..35aec1a5bba81 100644 --- a/packages/@aws-cdk/aws-route53/lib/hosted-zone.ts +++ b/packages/@aws-cdk/aws-route53/lib/hosted-zone.ts @@ -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 {