'Custom domain for API Gateway using CloudFormation
I'm trying to define a custom domain (sub domain actually) for an API Gateway using CloudFormation. According to all the documentation I've been able to find the following should work but when I deploy it I get Invalid domain name identifier specified
for the BasePathMapping
aws cloudformation deploy --template-file packaged-prompt.yaml --capabilities CAPABILITY_IAM --stack-name prompt-stack
prompt.yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
...
Certificate:
Type: 'AWS::CertificateManager::Certificate'
Properties:
DomainName: example.mydomain.com
DomainName:
Type: 'AWS::ApiGateway::DomainName'
Properties:
CertificateArn: !Ref Certificate
DomainName: example.mydomain.com
Mapping:
Type: 'AWS::ApiGateway::BasePathMapping'
Properties:
DomainName: !Ref DomainName
RestApiId: !Ref Api
Api:
Type: AWS::Serverless::Api
Properties:
StageName: prod
DefinitionBody:
swagger: 2.0
info:
title:
Ref: AWS::StackName
paths:
....
Solution 1:[1]
The properties in your BasePathMapping is missing
BasePath: ""
Solution 2:[2]
It may not be the case, but I had the same problem as I was using uppercase letters in my domain-name, which must be avoided. See BaseUrl Mapping in AWS with inconsistencies
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Richard H Boyd |
Solution 2 | Francois Gergaud |