What should the developer do to configure the API to meet these requirements?
Change the API Gateway route to add an X-Amz-Invocation-Type header with a static value of ‘Event’ in the integration request. Deploy the API Gateway stage to apply the changes.
Change the configuration of the Lambda function that implements the request to process a file. Configure the maximum age of the event so that the Lambda function will run asynchronously.
Change the API Gateway timeout value to match the Lambda function timeout value. Deploy the API Gateway stage to apply the changes.
Change the API Gateway route to add an X-Amz-Target header with a static value of ‘Async’ in the integration request. Deploy the API Gateway stage to apply the changes.
Explanations:
TheX-Amz-Invocation-Typeheader with the valueEventconfigures API Gateway to invoke the Lambda function asynchronously, allowing the API to respond immediately while processing continues in the background.
Changing the Lambda function’s event age does not influence the asynchronous execution of the function. It controls the maximum allowable event age, but this does not solve the timeout issue with API Gateway.
Changing the API Gateway timeout value does not solve the underlying issue of long processing times. The problem is that the API needs an immediate response, which requires asynchronous invocation.
TheX-Amz-Targetheader withAsyncis not a valid configuration for making Lambda calls asynchronous. The correct header for asynchronous invocation isX-Amz-Invocation-Typewith the valueEvent.