A cloud engineer is deploying a serverless microservice using an AWS Serverless Application Model (SAM) template. During the deployment process, the AWS CloudFormation engine returns an error stating that the resource type `AWS::Serverless::Function` is not supported or is invalid.
The template contains the following configuration:
yaml
AWSTemplateFormatVersion: '2010-09-09'
Resources:
GetProductFunction:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs18.x
CodeUri: ./src
Events:
GetProductApi:
Type: Api
Properties:
Path: /products/{id}
Method: get
Which of the following configuration adjustments will resolve this deployment error?
- AModify the event source properties to use a custom Integration type instead of the default proxy integration.
- BConfigure an explicit IAM Role with a trust policy that allows the API Gateway service principal to assume the execution role.
- Add the `Transform: AWS::Serverless-2016-10-31` declaration at the root level of the template.Cevap
- DSpecify a larger timeout value under the Globals section of the template to prevent deployment timeouts.
Cevap
Add the `Transform: AWS::Serverless-2016-10-31` declaration at the root level of the template.
Adding the `Transform` declaration at the root level of the template allows AWS CloudFormation to process the SAM template. The template is converted into standard CloudFormation resources, resolving the error where `AWS::Serverless::Function` is unrecognized.
Adım Adım Çözüm
Anahtar Kavram
AWS Serverless Application Model (SAM) template transformation
Tahmini Süre:1m 15s