SAM (new) Flashcards
What is a Serverless Application Model (SAM)?
SAM is built on and extends Cloud Formation.
SAM uses abstract, short-hand syntax to define and provision the infrastructure (Lambda functions, API Gateway and DynamoDB etc) for serverless apps.
It transforms the template to code behind the scenes to provision your infrastructure through Cloud Formation
Name the 5 benefits of SAM?
DMD QC
D - Define infrastructure quickly using less code
M - Manage the development lifecycle of serverless apps
D - Debug and test Lambda functions and layers locally
Q - Quickly give permissions between resources using SAM Connectors
C - Continuously sync local changes to the cloud as you develop
How would SAM improve the process of creating a serverless app such as a microservice with Lambda functions and an API Gateway Endpoint?
- Define Infrastructure quickly, less code
- Manage the development life cycle of the app - ‘Sam deploy’ used for quick deployment
- Debug and test locally
- Quickly give permissions through IAM roles
- API Gateway config (can define API methods etc in template)
- Resource Abstraction (abstracts complexities making it easier to define DynamoDB tables etc)
- Parameterization and Reusability
Name the 2 SAM components
SAM Template (define and manage resources)
SAM CLI (build and run)
What are the 8 key parts of a SAM template?
SAM template (YAML): (ATOM DRP G)
A - AWSTemplateFormatVersion
T - Transform
O - Outputs
M - Metadata
D - Description
R - Resources
P - Parameters
G - Globals
What does ‘Principal’ attribute define on a template?
The person to get permission
What is AWSTemplateFormatVersion?
Cloud Formation version
What is Transform?
The SAM version
What are the outputs?
Outputs are values that can be exported by the CloudFormation stack.
They are useful if you need to share info between stacks
What is the metadata?
Metadata is optional info you can add
Ie., MyDescription: This is a sample SAM template
What are the resources?
Resources define the resources that make up your serverless app
To define a resource you name the:
1. Type ie., (AWS::Serverless::Function for a Lambda function)
2. Properties (codeUri, functionName, permissions)
What are the parameters?
What is resource type: AWS::Serverless::Function for?
Lambda functions?
What is resource type: AWS::Serverless::Api for?
It represents an API Gateway
What is resource type: AWS::Serverless::SimpleTable for?
A DynamoDB table