首页 > Windows开发 > 详细

[AWS DA] API Gateway and Lambda Stage variable

时间:2021-06-01 09:16:48      阅读:21      评论:0      收藏:0      [点我收藏+]

技术分享图片

 

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

技术分享图片

技术分享图片

[AWS DA] API Gateway and Lambda Stage variable

原文:https://www.cnblogs.com/Answer1215/p/14835465.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!