简体   繁体   中英

Visual studio deploy AWS Lambda for non prod environment

I have deployed and able to use a webApi published to AWS Lambda, but it is always "prod"

I want to now setup test/dev environments

If i right click the project and choose to "Publish to AWS Lambda", there is no option to change the env.

I have however, found in my project a "serverless.template" file, which contains the following:

"Outputs": {
    "ApiURL": {
      "Description": "API endpoint URL for Prod environment",
      "Value": {
        "Fn::Sub": "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/"
      }
    },

So, my question is, do i just need to change the Fn::Sub to be "/Dev/" instead of "/Prod/" and if not, how will i publish to a dev environment?

Thank you

UPDATE: I have created a stages "stage" called Dev now: 在此处输入图像描述

so i guess the next stop is to deploy from visual studio, however, there is no way to select this stage when trying to deploy?

If you change the Prod to Dev it will output the URL for a API Gateway stage named Dev .

If you're using API Gateway then having a separate stage for each environment is a good approach to seperate.

Regarding deploying Lambdas you should use an Alias for each environments version to ensure you don't accidently update prod.

Then within API Gateway create a stage variable and reference this for the Arn to the Lambda alias so that the Dev stage will use the Dev Alias.

If you have seperate accounts between prod and non prod then these won't collide, although I always believe its better to us clear naming conventions for environments to avoid confusion.

Hope this helps

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