|
1 | 1 | import { Construct } from 'constructs'; |
2 | | -import { CfnDomainName } from './apigateway.generated'; |
| 2 | +import { CfnDomainName, DomainNameReference, IDomainNameRef } from './apigateway.generated'; |
3 | 3 | import { BasePathMapping, BasePathMappingOptions } from './base-path-mapping'; |
4 | 4 | import { EndpointType, IRestApi } from './restapi'; |
5 | 5 | import { IStage } from './stage'; |
6 | 6 | import * as apigwv2 from '../../aws-apigatewayv2'; |
7 | 7 | import * as acm from '../../aws-certificatemanager'; |
8 | 8 | import { IBucket } from '../../aws-s3'; |
9 | | -import { IResource, Names, Resource, Token } from '../../core'; |
| 9 | +import { Arn, IResource, Names, Resource, Stack, Token } from '../../core'; |
10 | 10 | import { ValidationError } from '../../core/lib/errors'; |
11 | 11 | import { addConstructMetadata, MethodMetadata } from '../../core/lib/metadata-resource'; |
12 | 12 | import { propertyInjectable } from '../../core/lib/prop-injectable'; |
@@ -94,7 +94,7 @@ export interface DomainNameProps extends DomainNameOptions { |
94 | 94 | readonly mapping?: IRestApi; |
95 | 95 | } |
96 | 96 |
|
97 | | -export interface IDomainName extends IResource { |
| 97 | +export interface IDomainName extends IResource, IDomainNameRef { |
98 | 98 | /** |
99 | 99 | * The domain name (e.g. `example.com`) |
100 | 100 | * |
@@ -132,12 +132,22 @@ export class DomainName extends Resource implements IDomainName { |
132 | 132 | public readonly domainName = attrs.domainName; |
133 | 133 | public readonly domainNameAliasDomainName = attrs.domainNameAliasTarget; |
134 | 134 | public readonly domainNameAliasHostedZoneId = attrs.domainNameAliasHostedZoneId; |
| 135 | + |
| 136 | + public readonly domainNameRef = { |
| 137 | + domainName: this.domainName, |
| 138 | + domainNameArn: Arn.format({ |
| 139 | + service: 'apigateway', |
| 140 | + resource: 'domainnames', |
| 141 | + resourceName: attrs.domainName, |
| 142 | + }, Stack.of(scope)), |
| 143 | + }; |
135 | 144 | } |
136 | 145 |
|
137 | 146 | return new Import(scope, id); |
138 | 147 | } |
139 | 148 |
|
140 | 149 | public readonly domainName: string; |
| 150 | + public readonly domainNameRef: DomainNameReference; |
141 | 151 | public readonly domainNameAliasDomainName: string; |
142 | 152 | public readonly domainNameAliasHostedZoneId: string; |
143 | 153 | private readonly basePaths = new Set<string | undefined>(); |
@@ -168,6 +178,7 @@ export class DomainName extends Resource implements IDomainName { |
168 | 178 | }); |
169 | 179 |
|
170 | 180 | this.domainName = resource.ref; |
| 181 | + this.domainNameRef = resource.domainNameRef; |
171 | 182 |
|
172 | 183 | this.domainNameAliasDomainName = edge |
173 | 184 | ? resource.attrDistributionDomainName |
|
0 commit comments