AWS SAM Template Resource Types for Serverless Projects | AWS Certification Exam Prep

AWS SAM Template Resource Types

Prev Question Next Question

Question

You are working on a proof of concept serverless project and presenting it to the shareholders in a week.

This project needs an API gateway, a Lambda function, and a DynamoDB table to store user data.

To save time, you plan to use AWS Serverless Application Model (AWS SAM) as it provides templates to deploy all required resources quickly.

You have found that SAM templates are very similar to CloudFormation templates.

However, which resource types are specially introduced by the SAM template? (Select TWO.)

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D. E.

Correct Answer - B, D.

AWS SAM is an extension of AWS CloudFormation.

A SAM serverless application is defined in a CloudFormation template and deployed as a CloudFormation stack.

The AWS SAM template can be regarded as a CloudFormation template.

However, it has its own special resources.

Check https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessapplication for details.

Note: to include objects defined by AWS SAM, the template must include a Transform section in the document with a value of AWS::Serverless-2016-10-31.

Option A is incorrect: Because AWS::DynamoDB::Table is not SAM special and belongs to the CloudFormation resource type.

Option B is CORRECT: Because AWS::Serverless::Api is designed for API gateway resource in the SAM framework.

Option C is incorrect: Similar to.

Option A.Option D is CORRECT: Because AWS::Serverless::Function is the SAM resource that creates a Lambda function, IAM execution role, and event source mappings.

Option E is incorrect: Because AWS::ApiGateway::RestApi also belongs to the CloudFormation resource type.

Refer to https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html.

The AWS Serverless Application Model (SAM) is an open-source framework used for building serverless applications. It provides a simplified way of defining the Amazon API Gateway APIs, AWS Lambda functions, and Amazon DynamoDB tables needed for your serverless application. SAM templates are very similar to AWS CloudFormation templates, but they include some additional resource types that are specifically designed for serverless applications.

The SAM template includes the following resource types that are specifically designed for serverless applications:

  1. AWS::Serverless::Function: This resource type is used to define a serverless function, which is executed by AWS Lambda. This resource type includes properties such as the function code location, runtime environment, and event triggers.

  2. AWS::Serverless::Api: This resource type is used to define an Amazon API Gateway REST API that integrates with a serverless function. This resource type includes properties such as the API Gateway stage name, endpoint configuration, and authorization settings.

In contrast, AWS::ApiGateway::RestApi is a CloudFormation resource type used to define an Amazon API Gateway REST API, but it is not specifically designed for serverless applications. AWS::Lambda::Api is not a valid resource type.

AWS::DynamoDB::Table is a CloudFormation resource type used to define an Amazon DynamoDB table, but it is not specifically designed for serverless applications. However, the SAM template includes a Serverless::SimpleTable resource type that simplifies the creation of DynamoDB tables in serverless applications.

Therefore, the correct answer is: B. AWS::Serverless::Api D. AWS::Serverless::Function