Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
284 views
in Technique[技术] by (71.8m points)

amazon web services - How to have set up Stage in API gateway to have resources pointing to different lambda in different stages

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.

resource

stage

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

will it be possible?

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...