I am writing an AWS Lambda that is invoked via HTTP (i.e. the API Gateway integration).
I wish to use that API as a GitHub webhook. When the webhook/lambda is called I want the HTTP response to be sent right away and the lambda to keep executing (because it can take some time).
This is similar to the Event
invocation type when invoking a lambda:
Is that possible to use that invocation type with the HTTP integration?
Note: I am using the serverless.com framework.
You can invoke a Lambda function asynchronously via API Gateway only if the integration is non-proxy. By default, HTTP APIs are designed to support only proxy integrations for Lambda and HTTP endpoints so it is not possible to set the X-Amz-Invocation-Type header in the API Gateway integration config.
Lambda functions can be invoked either synchronously or asynchronously, depending upon the trigger. In synchronous invocations, the caller waits for the function to complete execution and the function can return a value.
You can now use an AWS Lambda function from a different AWS account as your API integration backend. Each account can be in any region where Amazon API Gateway is available. This makes it easy to centrally manage and share Lambda backend functions across multiple APIs.
As @michael-sqlbot pointed out you can get this behavior by using the X-Amz-Invocation-Type:Event Header. Getting this setup is a little screwy and the linked documentation is accurate but a little outdated (in my opinion).
/2015-03-31/functions/<ARN TO YOUR LAMBDA>/invocations
'Event'
in the Mapped from
field (as pictured below)Or... you could also achieve this by having your lambda that's wired up to the API Gateway (we'll call it lambda A) invoke another lambda (lambda B) using the Event
invocation type. This way A doesn't care about the response of B and can return a successful response to the API Gateway within several hundred milliseconds (assuming you aren't doing too much else). Then Lambda B can continue running for however long is necessary (as long as it's under the 5 minute lambda limitation or your configured timeout).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With