简体   繁体   中英

How to deploy serverless code in different stages via command line?

Currently I'm using following command line to deploy in different stages from my local mechine:

serverless deploy --stage qa

But this code create whole new section (project) in the API Gateway section. See my attached link.

https://photos.google.com/share/AF1QipPU6X8Dej7rNq5Ofo1eKfCq1cn6GpsL3GYdZ50yUO_a4quVPao9bllHIvRFA6VkbA?key=WVFDLVQ0cEd6aVB3cVlSY1hYcnBmS1BRT1QtNVVB

should this code create serverless deploy --stage qa different stages in the APIs -> (API Project) -> Stages section?

I'm kind of confused which way is the correct. I see many tutorials creating both ways. However for me it makes sense creating different stages in one project.

Or is there a different command to do what I want?

I would argue the way serverless is written is a much cleaner way to deploy to different stages. Whilst API Gateway does allow different stages under the same API Gateway, this leaves much more room for accidentally doing something you didnt want to do eg accidentally tearing down your production API instead of dev.

Also, best practice is to have each stage in its own AWS account. This allows you to better lock down your production environment at an account level, to avoid accidental changes. This is beneficial for all your AWS resources, not just API Gateway.

If you follow best practices and have an AWS account per stage, your problem is mute as you will have an API Gateway in each of your staging accounts.

If these best practices aren't for your, you can always revert back to normal CloudFormation templates to force each stage to be a different deployment under the same API Gateway.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM