Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid domain name identifier specified

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.

like image 509
Jacob Lambert Avatar asked Dec 05 '22 14:12

Jacob Lambert


2 Answers

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

like image 198
Aditya Avatar answered Dec 09 '22 16:12

Aditya


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
...
like image 31
RodrigoM Avatar answered Dec 09 '22 14:12

RodrigoM