I use AWS::Serverless::Api
to define a API Gateway resource in my SAM template. As per this blog: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification-generated-resources-api.html,
The Stage created should have a logical ID of the format <api‑LogicalId><stage‑name>Stage
.
My api‑LogicalId = Api
, stage-name=dev
. However the CFN stack ends up with a stage logical id called ApiStage
with the correct stage value dev
.
This is not the main issue though. Later when I transform the API resource and try to deploy it again, it tries to create a new Logical Id ApidevStage
which follows the format, but the stack fails as the it already has a resource for the same api gateway stage but with a different logical Id ApiStage
. How to ensure my CFN stack sticks to the same Logical Id for Stage?
Can we explicitly create a stage resource and refer to it inside AWS::Serverless::Api