diff --git a/packages/@aws-cdk/aws-apigatewayv2/lib/common/domain-name.ts b/packages/@aws-cdk/aws-apigatewayv2/lib/common/domain-name.ts index dca1a60bd4548..6b1123512c678 100644 --- a/packages/@aws-cdk/aws-apigatewayv2/lib/common/domain-name.ts +++ b/packages/@aws-cdk/aws-apigatewayv2/lib/common/domain-name.ts @@ -98,7 +98,7 @@ export class DomainName extends Resource implements IDomainName { ], }; const resource = new CfnDomainName(this, 'Resource', domainNameProps); - this.name = props.domainName ?? resource.ref; + this.name = resource.ref; this.regionalDomainName = Token.asString(resource.getAtt('RegionalDomainName')); this.regionalHostedZoneId = Token.asString(resource.getAtt('RegionalHostedZoneId')); } diff --git a/packages/@aws-cdk/aws-apigatewayv2/test/common/api-mapping.test.ts b/packages/@aws-cdk/aws-apigatewayv2/test/common/api-mapping.test.ts index ff53d3dad11fc..855ad32dda137 100644 --- a/packages/@aws-cdk/aws-apigatewayv2/test/common/api-mapping.test.ts +++ b/packages/@aws-cdk/aws-apigatewayv2/test/common/api-mapping.test.ts @@ -26,7 +26,6 @@ describe('ApiMapping', () => { ApiId: { Ref: 'ApiF70053CD', }, - DomainName: 'example.com', Stage: '$default', }); }); @@ -58,7 +57,6 @@ describe('ApiMapping', () => { ApiId: { Ref: 'ApiF70053CD', }, - DomainName: 'example.com', Stage: 'beta', ApiMappingKey: 'beta', }); diff --git a/packages/@aws-cdk/aws-apigatewayv2/test/http/domain-name.test.ts b/packages/@aws-cdk/aws-apigatewayv2/test/http/domain-name.test.ts index 30c981a1da1d5..2d0d856c7ae15 100644 --- a/packages/@aws-cdk/aws-apigatewayv2/test/http/domain-name.test.ts +++ b/packages/@aws-cdk/aws-apigatewayv2/test/http/domain-name.test.ts @@ -102,7 +102,9 @@ describe('DomainName', () => { ApiId: { Ref: 'ApiF70053CD', }, - DomainName: 'example.com', + DomainName: { + Ref: 'DNFDC76583', + }, Stage: 'beta', ApiMappingKey: 'beta', }); @@ -139,7 +141,9 @@ describe('DomainName', () => { ApiId: { Ref: 'ApiF70053CD', }, - DomainName: 'example.com', + DomainName: { + Ref: 'DNFDC76583', + }, Stage: '$default', }); }); diff --git a/packages/@aws-cdk/aws-apigatewayv2/test/http/stage.test.ts b/packages/@aws-cdk/aws-apigatewayv2/test/http/stage.test.ts index e7a05924719d3..b617fe4613a51 100644 --- a/packages/@aws-cdk/aws-apigatewayv2/test/http/stage.test.ts +++ b/packages/@aws-cdk/aws-apigatewayv2/test/http/stage.test.ts @@ -140,7 +140,11 @@ describe('HttpStage with domain mapping', () => { }, }); - expect(stage.domainUrl).toBe(`https://${domainName}/`); + expect(stack.resolve(stage.domainUrl)).toEqual({ + 'Fn::Join': ['', [ + 'https://', { Ref: 'DNFDC76583' }, '/', + ]], + }); }); test('domainUrl throws error if domainMapping is not configured', () => {