A developer is creating an AWS Serverless Application Model (SAM) template to deploy a Lambda function that is triggered by an API Gateway endpoint. Which two template configurations or declarations are required to successfully define the serverless function and its API Gateway trigger?
- Include the `Transform: AWS::Serverless-2016-10-31` declaration at the root of the templateAnswer
- Define an `Events` property of type `Api` under the `AWS::Serverless::Function` resourceAnswer
- CDeclare `AWS::Serverless-2016-10-31` as the value for the `AWSTemplateFormatVersion` property
- DConfigure a custom integration mapping template to manually structure the HTTP request payload for the API Gateway endpoint
- EConfigure the trust policy of the Lambda execution role to allow the API Gateway principal (`apigateway.amazonaws.com`) to assume the role
Answer
To configure the serverless function and its API Gateway trigger, the developer must include the `Transform: AWS::Serverless-2016-10-31` declaration at the root of the template and define an `Events` property of type `Api` under the `AWS::Serverless::Function` resource.
The correct configurations are including the `Transform: AWS::Serverless-2016-10-31` declaration at the root of the template to instruct CloudFormation to evaluate the SAM syntax, and defining an `Events` property of type `Api` under the `AWS::Serverless::Function` resource to set up the API Gateway trigger.
Step-by-Step Solution
Key Concept
AWS Serverless Application Model (SAM) Template Structure