Vman
Vman

Reputation: 454

The API with ID does not include a resource with path /* having an integration LAMBDA on the ANY method

.net core serverless web api I am trying to do proxy integration with lambda and api gateway, everything is working fine with aws console

but i am facing issues with aws cli commands i tried integrating with cli but the lambda is not properly integrated

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

Upvotes: 26

Views: 27187

Answers (1)

Sarthak Jain
Sarthak Jain

Reputation: 2096

There are two problems with your commands -

Incorrect

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

Correct: Notice the double quotes

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

Incorrect

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 

Correct

  • type should be AWS_PROXY for Lambda Proxy Integrations.

  • integration-http-method should always be POST for Lambda Proxy integration, even if the http method is GET or ANY or anything else.

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

Upvotes: 5

Related Questions