How to have set up Stage in API gateway to have resources pointing to different lambda in different stages

天大地大妈咪最大 提交于 2021-02-11 06:53:27

问题


I was wondering what is the exact functionality of the "Stage" in the API gateway console.

What I am trying to achieve is. To have the same resources with the same HTTP methods point to different lambda function in different stages.

my development URL point to my development lambda and my production URL point to the production lambda.

will it be possible?


回答1:


Yes it is possible through stage variables. The variables allow you to invoke different functions depending on the used stage. This is exemplified in:

  • Call a Lambda function through an API with a stage variable

What's more, you could invoke same function, but with different parameters that depend on the stage:

For example, you might want to reuse the same Lambda function for multiple stages in your API, but the function should read data from a different Amazon DynamoDB table depending on which stage is being called.

Technically, a stage is a snapshot of the API. It is something similar to versions of a lambda function, where different versions represent different snapshots of your function. The exception in API is, that the API stages can be modified, whereas versions of a lambda function are immutable.



来源:https://stackoverflow.com/questions/65913827/how-to-have-set-up-stage-in-api-gateway-to-have-resources-pointing-to-different

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!