Skip to content

Commit

Permalink
feat: plat-5577 api construct exposes the domain name (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
malcyL authored Jul 7, 2022
1 parent ec68fb5 commit 91a9ece
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,5 +154,10 @@ export class SimpleAuthenticatedApiStack extends cdk.Stack {
path: "/api-documentation",
method: apigatewayv2.HttpMethod.GET,
});

console.log(`Regional domain name: ${api.domainName.regionalDomainName}`);
console.log(
`Regional hosted zone id: ${api.domainName.regionalHostedZoneId}`
);
}
}
5 changes: 3 additions & 2 deletions lib/authenticated-api/authenticated-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const DEFAULT_LAMBDA_DURATION_THRESHOLD = cdk.Duration.minutes(1);
export class AuthenticatedApi extends cdk.Construct {
readonly apiId: string;
readonly httpApiId: string;
readonly domainName: apigatewayv2.DomainName;

private httpApi: apigatewayv2.HttpApi;
private authorizer: apigatewayv2.IHttpRouteAuthorizer;
Expand All @@ -36,7 +37,7 @@ export class AuthenticatedApi extends cdk.Construct {
`To use a custom domain name both certificateArn and domainName must be specified`
);
}
const domainName = new apigatewayv2.DomainName(this, "domain-name", {
this.domainName = new apigatewayv2.DomainName(this, "domain-name", {
domainName: props.domainName,
certificate: acm.Certificate.fromCertificateArn(
this,
Expand All @@ -46,7 +47,7 @@ export class AuthenticatedApi extends cdk.Construct {
});
const apiGatewayProps: apigatewayv2.HttpApiProps = {
apiName: `${props.prefix}${props.name}`,
defaultDomainMapping: { domainName: domainName },
defaultDomainMapping: { domainName: this.domainName },
...(props.corsDomain && {
corsPreflight: {
allowHeaders: ["*"],
Expand Down

0 comments on commit 91a9ece

Please sign in to comment.