[AWS DA] API Gateway and Lambda Stage variable

 

1. First, create a Lambda function call `lambdav1`

2. Create three alias PROD, TEST, DEV

For each alias, you can modify the response body code, so that you are able to tell which alias currently working on.

3. Create API Gateway resouce `/`, method: GET; 

4. Enable "Use Lambda Proxy integration"

5. Lambda Function: ``lambdav1${stageVariables.lambdaAlias}

6. Alert you to add Permission for API Gateway to invoke alias:

7. Run the commands for `DEV`, `TEST`, `PROD`:

aws lambda add-permission   
--function-name "arn:aws:lambda:us-east-1:860348619467:function:lambdav1:PROD"
--source-arn "arn:aws:execute-api:us-east-1:860348619467:simzh6y9t2/*/GET/"
--principal apigateway.amazonaws.com --statement-id 10712fb2-6ee5-4383-9e66-3cddf29e438a
--action lambda:InvokeFunction
--region us-east-1

8. Then varify the alias resouce-based policy is not empty:

9. Now if you invoke API gateway "TEST" button with stage Variable

you should be able to see the response

10. Deploy API Gateway and create `dev`, `test`, `prod` stages. For each deploy, modify stage vairable to its alias

posted @   Zhentiw  阅读(106)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
历史上的今天:
2019-06-01 [Algorithm] Chunk Array
2017-06-01 [Angular] @ContentChild with Directive ref
2016-06-01 [TypeScript] Understanding Generics with RxJS
2016-06-01 [React + Mobx] Mobx and React intro: syncing the UI with the app state using observable and observer
点击右上角即可分享
微信分享提示