First, the basic question - is there a straightforward way to add the HTTP header X-Amz-Invocation-Type:'Event'
to an existing API Gateway POST method with Integration Type Lambda Function so that I can easily launch an asynchronous Lambda from my existing endpoint?
Now the background...
I have an API Gateway with a POST method, Integration type Lambda Function that works quite well for me via curl and Javascript, except for the 29s API timeout.
Through some searching, I think I've learned that setting up an HTTP header X-Amz-Invocation-Type:'Event' is what I would need to get my Lambda function to run asynchronously.
I've seen advice that suggests going through the console and using an AWS Service integration type, then adding in the header along with mapping templates and such, and this is far more complicated than I really want to try (maybe I don't have a choice?). I tried, but I "think" I end up having to deal with mapping templates, and I have a pretty complicated payload - does it really have to be this hard?
I've also seen suggestions to use two Lambdas, the first one is triggered through the API and is synchronous, and triggers the asynchronous one. I know how to do this, and it does have advantages (but also added complexity), but I'm putting that aside for now.
I read one post that "hinted" that it might be possible to add this new HTTP header via CLI. I've done a bit of trial and error with things like aws.apigateway.put_method() etc., but I'm kind of shooting in the dark. I like to think there's an easy way to do this, but the solution is evading me up to now.