Attempting a custom mapping for ApiGateway

Hello all,

I’ve searched the forum and can’t find anything similar, so I’m going to post this question here. I’m attempting to do a base path mapping based on stage. In the resources section I’ve added a section as follows:

    Type: "AWS::ApiGateway::BasePathMapping"
      BasePath: ${opt:stage, self:provider.stage}
      DomainName: ""
        Ref: ApiGatewayRestApi
      Stage: ${opt:stage, self:provider.stage}

when running sls deploy --stage dsnitker, I get the following error:

…Serverless: Deployment failed!

Serverless Error ---------------------------------------

 An error occurred while provisioning your stack: APIDomainMapping
 - Invalid stage identifier specified.

Get Support --------------------------------------------

Your Environment Information -----------------------------
OS: win32
Node Version: 6.9.1
Serverless Version: 1.3.0

I have also tried using the variable ${self:custom.myStage} instead of the stage variables listed above. The generated json looks fine:

“APIDomainMapping”: {
“Type”: “AWS::ApiGateway::BasePathMapping”,
“Properties”: {
“BasePath”: “dsnitker”,
“DomainName”: “”,
“RestApiId”: {
“Ref”: “ApiGatewayRestApi”
“Stage”: “dsnitker”

Has anyone run into anything similar?


1 Like

Upon looking further into the bug list, this appears to be the same issue as reported in:


Is the typical response to run the cloudformation for the mapping at a later point through a parent script?