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:

APIDomainMapping:
    Type: "AWS::ApiGateway::BasePathMapping"
    Properties:
      BasePath: ${opt:stage, self:provider.stage}
      DomainName: "my.domain.com"
      RestApiId:
        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 --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues

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”: “my.domain.com”,
“RestApiId”: {
“Ref”: “ApiGatewayRestApi”
},
“Stage”: “dsnitker”
}
}

Has anyone run into anything similar?

TIA

1 Like

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

https://github.com/serverless/serverless/pull/2234

and

https://github.com/serverless/serverless/issues/2233

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

-D