Introduction to AWS SAM and AWS CloudFormation
Infrastructure as code for provisioning and deploying AWS resources.
- 4 lessons
- Module quiz
Creating cloud resources by clicking through the console is slow, hard to repeat and easy to get wrong. Infrastructure as code (IaC) solves this by describing resources in files that are stored in source control, reviewed and deployed automatically, so that every environment is created in the same way and can be recreated at any time.
AWS CloudFormation is AWS's IaC service. A template written in YAML or JSON describes resources, and CloudFormation creates, updates and deletes them together as a single unit called a stack, rolling back automatically if a change fails. The AWS Serverless Application Model (AWS SAM) extends CloudFormation for serverless applications. A template that begins with Transform: AWS::Serverless-2016-10-31 can use short SAM resource types, such as a function with its API trigger in a few lines, and the SAM CLI builds, tests locally and deploys the application. CloudFormation is free for AWS resources; the resources it creates are charged.
Where these tools fit
Developers on the exam are expected to read and write templates, including their sections and intrinsic functions, to share values between stacks, and to use SAM to package, test and deploy serverless applications. SAM also connects to AWS CodeDeploy so that new Lambda versions can be released gradually, and the AWS CDK, covered in the next module, generates CloudFormation templates from code.
How this module is organised
Defining and Updating Stacks with CloudFormation Templates explains template sections, intrinsic functions, stack updates and cross-stack references. Building Serverless Applications with AWS SAM Templates and the SAM CLI explains SAM resource types and the SAM CLI workflow. Testing Serverless Code Locally and in the Cloud with AWS SAM explains how functions and APIs are run and tested on a developer's machine and in a development account, and Combining Unit Tests with Mocks and Integration Tests in the Cloud explains how to test code that depends on AWS services.
- Defining and Updating Stacks with CloudFormation Templates Lesson 1
- Building Serverless Applications with AWS SAM Templates and the SAM CLI Lesson 2
- Testing Serverless Code Locally and in the Cloud with AWS SAM Lesson 3
- Combining Unit Tests with Mocks and Integration Tests in the Cloud Lesson 4
- Practise and review
- Test your knowledge 10 questions