AWS SAM Flashcards
What is AWS SAM
The AWS Serverless Application Model (AWS SAM) is an open-source framework for building serverless applications.
It provides shorthand syntax to express functions, APIs, databases, and event source mappings.
With just a few lines per resource, you can define the application you want and model it using YAML.
What happens during Deployment
During deployment, SAM transforms and expands the SAM syntax into AWS CloudFormation syntax, enabling you to build serverless applications faster.
Cloudformation Support
AWS SAM supports all AWS CloudFormation template items such as Outputs, Mappings, Parameters, etc.
AWS SAM is an extension of AWS CloudFormation, so you get the reliable deployment capabilities of CloudFormation.
You can also define resources using CloudFormation in your SAM template and use the full suite of resources, intrinsic functions, and other template features that are available in AWS CloudFormation.
SAM CLI
To get started with building AWS SAM-based applications, use the AWS SAM CLI. SAM CLI provides a Lambda-like execution environment that lets you locally build, test, and debug applications defined by SAM templates.
You can also use the SAM CLI to deploy your applications to AWS.
Key benefits of SAM
Single deployment configuration:
You can use SAM to organize related components, share configuration such as memory and timeouts between resources, and deploy all related resources together as a single, versioned entity.
Integration with development tools
SAM integrates with a suite of AWS serverless tools.
You can find new applications in the AWS Serverless Application Repository
The AWS Cloud9 IDE can be used to author, test, and debug SAM-based serverless applications,
AWS CodeBuild, AWS CodeDeploy, and AWS CodePipeline can be used to build a deployment pipeline.
Local testing and debugging
You can use SAM CLI to step-through and debug your code.
SAM CLI provides a Lambda-like execution environment locally and helps you catch issues upfront.
SAM Template Capabilities
A SAM template file is a YAML configuration that represents the architecture of a serverless application.
You use the template to declare all of the AWS resources that comprise your serverless application in one place.
AWS SAM templates are an extension of AWS CloudFormation templates, so any resource that you can declare in an AWS CloudFormation template can also be declared in an AWS SAM template.
All configuration code is in YAML.
What Header Indicates a SAM Template
The “Transform” header indicates it’s a SAM template: Transform: ‘AWS::Serverless-2016-10-31’
What are SAM Resource Types
- AWS::Serverless::Function (AWS Lambda)
- AWS::Serverless::Api (API Gateway)
- AWS::Serverless::SimpleTable (DynamoDB)
- AWS::Serverless::Application (AWS Serverless Application Repository)
- AWS::Serverless::HttpApi (API Gateway HTTP API)
- AWS::Serverless::LayerVersion (Lambda layers)
What are the two commands are required to package and deploy
Use either:
- sam package
- sam deploy
Or use:
- aws cloudformation package
- aws cloudformation deploy