Invalid domain name identifier specified

11,281

Solution 1

Quoting from AWS forums:

You can only create or modify base path mappings after the domain name has been added to API Gateway. This "Invalid domain name identifier specified" error message is returned when the domain name given in the base path mapping is not found, indicating that it has not been added yet.

Also, as of March 2017, the only way to add domain name to the API Gateway via CloudFormation is via custom resources that CloudFormation offers.

Ref: https://forums.aws.amazon.com/message.jspa?messageID=769627

Solution 2

It is now possible to just do that. You just have to explicit state on your CFN template that there is a dependency (DependsOn):

...
ApiDevMapping:
  Type: 'AWS::ApiGateway::BasePathMapping'
  Properties:
    BasePath: v1.0
    Stage: dev
    DomainName: my-api.example.com
    RestApiId: !Ref MobileApiDev
DependsOn:
  - MobileApiDevDomain
...
Share:
11,281
Jacob Lambert
Author by

Jacob Lambert

Updated on June 23, 2022

Comments

  • Jacob Lambert
    Jacob Lambert over 1 year

    When trying to create an AWS::ApiGateway::BasePathMapping through CloudFormation, I am given the following error:

    Invalid domain name identifier specified
    

    Below is the portion(s) of my CloudFormation template that should create the AWS::ApiGateway::BasePathMapping:

    {
        "Parameters": {
            "ApiDomainName": {
                "Description": "The domain name for the API",
                "Type": "String"
            }
        },
        "Resources": {
            "ApiBasePathMapping": {
                "Type": "AWS::ApiGateway::BasePathMapping",
                "Properties": {
                    "DomainName": {
                        "Ref": "ApiDomainName"   
                    },
                    "RestApiId": {
                        "Ref": "RepositoryApi"
                    },
                    "Stage": {
                        "Ref": "ApiProductionStage"
                    }
                },
                "DependsOn": [
                    "ApiProductionStage"
                ]
            }
        }
    }
    

    The documentation makes no mention that it needs to be anything special for the DomainName, but the documentation for this resource seems to be lacking some information (It doesn't list outputs for example even though there is a Distribution Domain Name created as an example).

    The remainder of the stack works as expected. I am trying to add this resource in as a Change Set. I do own the domain I am trying to use, and I have created a certificate in ACM for this domain.