[AWS DA] API Gateway and Lambda Stage variable

Posted Answer1215

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[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

以上是关于[AWS DA] API Gateway and Lambda Stage variable的主要内容,如果未能解决你的问题,请参考以下文章

如果在 Terraform 模块中创建了 aws_api_gateway_integration,如何在 aws_api_gateway_deployment 资源上填充depends_on?

从AWS API-Gateway中找出lambda名称

响应未定义 - aws-api-gateway-client

AWS API Gateway:用户匿名无权执行 API

AWS API Gateway 默认响应和触发 AWS Lambda

是否可以使用 AWS API 为 Lambda 函数设置 AWS API Gateway 端点?