gpt4 book ai didi

amazon-web-services - 具有ID的API不包含路径/*的资源,该资源的ANY方法具有集成LAMBDA

转载 作者:行者123 更新时间:2023-12-04 02:28:49 24 4
gpt4 key购买 nike

.net核心无服务器Web API
我正在尝试与lambda和api网关进行代理集成,而AWS控制台一切正常

但是我面对aws cli命令的问题
我尝试与cli集成,但lambda未正确集成

aws apigateway create-resource --rest-api-id id --parent-id id --path-part {proxy+}


aws apigateway put-method --rest-api-id id --resource-id id --http-method ANY --authorization-type "NONE"


aws apigateway put-integration --rest-api-id id --resource-id id --http-method ANY --type HTTP_PROXY --integration-http-method ANY --uri arn:aws:apigateway:us-east-2:lambda:path//2015-03-31/functions/arn:aws:lambda:us-east-2:account_id:function:helloworld/invocations


aws lambda add-permission --function-name helloworld --action lambda:InvokeFunction --principal apigateway.amazonaws.com --source-arn arn:aws:execute-api:us-east-2:account_id:apiid/*/*/* --statement-id 12345678

最佳答案

This article列出了在具有Lambda代理集成的AWS API Gateway上创建简单的/ping API的所有步骤。

具体来说,您的命令有两个问题-

不正确的

aws apigateway create-resource --rest-api-id id --parent-id id --path-part {proxy+}


正确:请注意双引号

aws apigateway create-resource --rest-api-id id --parent-id id --path-part "{proxy+}"


不正确的

aws apigateway put-integration \
--rest-api-id id \
--resource-id id \
--http-method ANY \
--type HTTP_PROXY \
--integration-http-method ANY \
--uri arn:aws:apigateway:us-east-2:lambda:path//2015-03-31/functions/arn:aws:lambda:us-east-2:account_id:function:helloworld/invocations


正确


对于Lambda代理集成,类型应为AWS_PROXY。
对于Lambda代理集成,Integration-http-method应该始终为POST,即使http方法为GET或ANY或其他任何方法。




aws apigateway put-integration \
--rest-api-id id \
--resource-id id \
--http-method ANY \
--type AWS_PROXY \
--integration-http-method POST \
--uri arn:aws:apigateway:us-east-2:lambda:path//2015-03-31/functions/arn:aws:lambda:us-east-2:account_id:function:helloworld/invocations

关于amazon-web-services - 具有ID的API不包含路径/*的资源,该资源的ANY方法具有集成LAMBDA,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56567101/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com