如何在API网关中设置Stage以使资源在不同阶段指向不同的Lambda [英] How to have set up Stage in API gateway to have resources pointing to different lambda in different stages
问题描述
我想知道阶段"功能的确切功能是什么?在API网关控制台中.
I was wondering what is the exact functionality of the "Stage" in the API gateway console.
我想要实现的是. 使用相同的HTTP方法拥有相同的资源会在不同的阶段指向不同的lambda函数.
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.
我的开发URL指向我的开发lambda,我的生产URL指向生产lambda.
my development URL point to my development lambda and my production URL point to the production lambda.
有可能吗?
推荐答案
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:
例如,您可能想在API的多个阶段中重用相同的Lambda函数,但是该函数应从不同的Amazon DynamoDB表读取数据,具体取决于所调用的阶段.
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.
从技术上讲,阶段是 API的快照.它类似于 lambda函数的版本 ,其中不同的版本代表您的函数的不同快照. API中的例外是,可以修改API阶段,而lambda函数的版本是不可变的.
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.
这篇关于如何在API网关中设置Stage以使资源在不同阶段指向不同的Lambda的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!