serverless-api-stage
serverless-api-stage copied to clipboard
Standardize the logicalId for other cloudformation templates
The plugin will create a cf resource with the logical id of 'ApiGatewayStage' suffixed with the stage name having the first character capitalized. Example: ApiGatewayStageDev
While I agree this makes for a better readable logical id and more in line with naming standards, there is no way to get access via the logical id if your stage name starts with a lowercase (which I believe is also a common practice)
NOTE: not sure this "should" be fixed, there are pros/cons to addressing it.
For instance: sls deploy --stage prod
or if set via the provider stage var
The logical is would be: ApiGatewayStageProd
you can't then:
DomainBasePathMapping:
Type: AWS::ApiGateway::BasePathMapping
DependsOn: ApiGatewayStage${self:provider.stage}
Properties:
BasePath: v1
DomainName: api.${self:provider.stage}.some.domain
RestApiId:
Ref: ApiGatewayRestApi
Stage: ${self:provider.stage}
See:
ApiGatewayStage${_.upperFirst(deployment.Properties.StageName)}
https://github.com/leftclickben/serverless-api-stage/blob/1e7adf1328d087819e3bafc50aa4e2d58340a11d/src/index.js#L133
The work around I did was to map alllowercase to CorrectCase via a extern js config file.
module.exports = () => ({
pascalStage: {
local: 'Local',
dev: 'Dev',
stage: 'Stage',
prod: 'Prod',
},
});
Hi @pkubat Thanks for your feedback, I think this is a good point that can be easily addressed, however it will break BC, so I've tagged this for a 2.0.0
release. Apart from that, were there other negatives you were considering? I can't see any -- I'll just use an underscore to separate "ApiGatewayStage" and the stage name. (edit: And apologies also for the delay responding)
Agreed on BC. Thanks. I think an underscore will work.
FYI @pkubat https://github.com/leftclickben/serverless-api-stage/pull/17/files