I am trying to deploy a serverless application to different stages (prod and dev). I want to deploy it to a single API gateway on two different stages like:- http://vfdfdf.execute-api.us-west-1.amazonaws.com/dev/ http://vfdfdf.execute-api.us-west-1.amazonaws.com/prod/
I have written a code in serverless -
provider:
name: aws
runtime: nodejs14.x
region: ${self:custom.${self:custom.stage}.lambdaRegion}
httpApi:
id: ${self:custom.${self:custom.stage}.httpAPIID}
stage: ${opt:stage, 'dev'}
Edited to reflect the comments
That can be done during the serverless deployment phase.
I would just have the
dev
by default in the serverless yml fileThen, the command:
serverless deploy
deploys in stage
dev
and region hereeu-west-1
. It's using the default values.While for production, the default values can be overridden on the command line. Then I would use the command:
serverless deploy --stage prod
In my understanding, you do not change the region between
dev
andprod
; but in case you would want to do that. The production deployment could be:serverless deploy --stage prod --region eu-west-2
to deploy in a different region than the default one from the serverless yml file.