question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deploy: pathmapping - Invalid stage identifier specified.

See original GitHub issue

This is a Bug Report

Description

For bug reports:

  • What went wrong? - pathmapping failed, invalid stage identifier
  • What did you expect should have happened? - deployment
  • What was the config you used?

Pathmapping section

pathmapping:
      Type: AWS::ApiGateway::BasePathMapping
      Properties:
        BasePath: ${self:service}
        DomainName: ${self:custom.domains.${opt:stage, self:provider.stage}}
        RestApiId: 
          Ref: ApiGatewayRestApi
        Stage: ${opt:stage}

Produces this in the serverless-state.json

"resources": {
      "Resources": {
        "pathmapping": {
          "Type": "AWS::ApiGateway::BasePathMapping",
          "Properties": {
            "BasePath": "demolambda",
            "DomainName": "staging-api.<REDACTED>",
            "RestApiId": {
              "Ref": "ApiGatewayRestApi"
            },
            "Stage": "staging"
          }
        }
      }
  • What stacktrace or error message from your provider did you see?

Verbose logging of CloudFormation process:

CloudFormation - CREATE_FAILED - AWS::ApiGateway::BasePathMapping - pathmapping

Ending error:

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

Additional Data

  • Serverless Framework Version you’re using: 1.17.0
  • Operating System: Linux (Ubuntu 14.04)
  • Stack Trace:
  • Provider Error messages:

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:17
  • Comments:25 (1 by maintainers)

github_iconTop GitHub Comments

47reactions
pmuenscommented, Feb 8, 2019

Closing since this is an old issue and a DependsOn does the trick here.

28reactions
ksafranskicommented, Aug 3, 2017

After some digging I figured out that the cause here was basically order of ops on the deploy. Since I was deploying a new stack APIGateway didn’t have a staging stage and it would try to run the pathmapping before the stage existed, hence Invalid Stage.

I saw a couple posts about adding a bogus DependsOn to force it to “wait” but that approach didn’t work so I was left doing 2 deploys; the first without pathmapping in the config to get the stage and Lambda functions created, followed by a second (and then all subsequent deploys) where pathmapping is present and the stage exists.

This doesn’t seem like a major issue since you can pretty easily get around it and once it’s fixed (and the stage exists) it doesn’t happen again, but would be nice to have a better way to get this working on new deploys.

Read more comments on GitHub >

github_iconTop Results From Across the Web

BasePathMapping deployment error: Invalid stage identifier ...
It tries to deploy the BasePathMapping before the ApiGateway Stage, which results in the error: Invalid stage identifier specified.
Read more >
AWS CloudFormation: pathmapping - Invalid stage identifier ...
when I ran the stack, I kept my deployed API stageName same as the BasePathMapping stageName and able to successfully create the Mapping....
Read more >
Attempting a custom mapping for ApiGateway
I'm attempting to do a base path mapping based on stage. ... provisioning your stack: APIDomainMapping - Invalid stage identifier specified.
Read more >
The template had one minor issue i.e Stage resource needs to ...
Invalid stage identifier specified (Service: AmazonApiGateway; Status Code: 400; ... Had to add AWS::ApiGateway::Deployment dependency in ...
Read more >
AWS::ApiGateway::BasePathMapping - AWS CloudFormation
The AWS::ApiGateway::BasePathMapping resource creates a base path that clients who call your API must use in the invocation URL.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found