Created
February 21, 2020 01:06
-
-
Save michimani/a6240ebf8b33595c1e890e3cec72f72e to your computer and use it in GitHub Desktop.
CloudFormation template for setting up custom domain name for an API in API Gateway.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: "2010-09-09" | |
Description: "Setup API Gateway custom domain name" | |
Parameters: | |
AcmArn: | |
Type: String | |
CustomDomainName: | |
Type: String | |
ApiID: | |
Type: String | |
DomainHostZoneId: | |
Type: String | |
Resources: | |
ApiGatewayCustomDomainName: | |
Type: "AWS::ApiGateway::DomainName" | |
Properties: | |
CertificateArn: !Ref AcmArn | |
DomainName: !Ref CustomDomainName | |
BasePathMapping: | |
Type: "AWS::ApiGateway::BasePathMapping" | |
DependsOn: ApiGatewayCustomDomainName | |
Properties: | |
DomainName: !Ref CustomDomainName | |
RestApiId: !Ref ApiID | |
Stage: api | |
CustomDomainRecord: | |
Type: "AWS::Route53::RecordSet" | |
Properties: | |
Name: !Ref CustomDomainName | |
Type: A | |
HostedZoneId: !Ref DomainHostZoneId | |
AliasTarget: | |
DNSName: !GetAtt ApiGatewayCustomDomainName.DistributionDomainName | |
HostedZoneId: !GetAtt ApiGatewayCustomDomainName.DistributionHostedZoneId |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment