Invoking lambda asynchronously with AWS API-Gateway

Piyush J
2 min readApr 14, 2019

--

To call a lambda function asynchronously with AWS API-Gateway, you need to integrate the gateway requests to the lambda using the integration-type Lambda Function. So, make sure that the Use Lambda Proxy integration option is not checked on the Integration Request view for the method.

Then, all you need to do is to add a header mapping in integration request like below. Note that the value needs single quotes.

The requests should now be asynchronous!

By the way, here’s how it can be done with a SAM template.

Note: You don’t need to actually pass the X-Amz-Invocation-Type header in the request.

If a DLQ is configured and the lambda throws an error on every retry, you should see the events going to the DLQ after the two automatic retries, while the client gets 200 OK immediately after the first request.

Async invocation, unfortunately, does not work with the lambda-proxy (aws_proxy) integration type. However, as a workaround, you can invoke a second lambda asynchronously from the first synchronous lambda using the lambda API. But this does not feel right to me.

--

--