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

时间:2019-06-12 16:58:14

标签: amazon-web-services aws-lambda asp.net-core-webapi aws-cli aws-serverless

.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

1 个答案:

答案 0 :(得分:0)

This article列出了在具有Lambda代理集成的AWS API Gateway上创建简单的grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(100) }); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); API的所有步骤。

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

不正确

/ping

正确:请注意双引号

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+}"

正确

    对于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 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