Muhammad Ali
Muhammad Ali

Reputation: 438

Configure API event integration as "lambda" instead of default "lambda proxy" in AWS SAM Template

All the examples of SAM use Events for Serverless::functions in default state mostly. And by default, the API integration for a Lambda is configured to be "Lambda proxy".

I require integration type "Lambda (non-proxy)" with the following setting in "Mapping" enter image description here

How can I achieve that using SAM templates?

Upvotes: 0

Views: 400

Answers (1)

stijndepestel
stijndepestel

Reputation: 3564

If you want more control over your API (e.g., to bypass certain defaults/assumptions that AWS SAM makes), you should explicitly define your AWS::Serverless::Api and pass along the definition of the API using the OpenAPI specification (either using the DefinitionUri or DefinitionBody attributes). In the specification, you have more control over how the API should integrate with the lambda functions. Setting the type attribute on the x-amazon-apigateway-integration object will allow you to use the aws integration instead of the aws_proxy integration.

You should still either configure the Events section in the lambda function or manually fix the necessary permissions in order to ensure that your API Gateway will have permission to invoke the lambda.

Upvotes: 1

Related Questions