I have set up API Gateway with Lambda backend where all the http requests (ANY) are supposed to be redirected to Lambda. I know that Lambda can only be invoked with POST method from the API Gateway according to the terraform docs (that is what I have specified for integration_http_method), but since I have specified ANY for API Gateway external method, shouldn’t it redirect all methods to POST for Lambda. Currently, only POST method works and any other method requests fail with internal error without even reaching Lambda.
Hi @mismayil,
This seems more an API Gateway question than a Terraform question, so I’ve moved this over into the AWS provider category in the hope that the participants there will share their Lambda knowledge. If not though, you may find it better to ask in a general AWS forum.
I’m very rusty on API Gateway myself – I’ve not used it for several years – but one thing that came to mind reading your question is that you might need to use a custom request mapping template that writes $context.httpMethod
into the body of your Lambda request (one of the arguments to the function), rather than using it as the real HTTP method in the request to Lambda. Hopefully then you can leave the real HTTP method set to POST
but still access the client’s original HTTP method in your Lambda function code via the arguments passed in.
Thanks for your response and moving it to that category @apparentlymart! I will have a look at that template approach.