A developer is deploying a serverless backend using AWS SAM. The configuration file `template.yaml` contains the following definition:
yaml
Resources:
ProcessDataFunction:
Type: AWS::Serverless::Function
Properties:
Handler: app.handler
Runtime: python3.12
CodeUri: src/
Events:
GetData:
Type: HttpApi
Properties:
Path: /data
Method: GET
During the deployment process, the CloudFormation stack creation fails with the message `Template format error: Unrecognized resource type: AWS::Serverless::Function`. Additionally, the developer notes that the python handler code currently returns a plain text string `'Success'`, which will cause integration failure when invoked through the API Gateway endpoint.
Which two actions must the developer take to resolve these issues?
- Add `Transform: AWS::Serverless-2016-10-31` at the root of the template file.Answer
- Modify the python handler to return a dictionary with `statusCode` and `body` keys, where `body` is a JSON-formatted string.Answer
- CCreate a new trust policy for the Lambda execution role allowing the `apigateway.amazonaws.com` service principal to perform `sts:AssumeRole`.
- DConfigure the `Timeout` property of the `AWS::Serverless::Function` resource to 900 seconds to prevent execution timeouts.
- EStore the response string in the Systems Manager Parameter Store and retrieve it dynamically in the API Gateway integration settings.