Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

          ....
like image 864
RedHatter Avatar asked Jun 01 '26 10:06

RedHatter


1 Answers

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

like image 60
Francois Gergaud Avatar answered Jun 04 '26 13:06

Francois Gergaud



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!