ENES

AWS CloudFormation

Describe your AWS infrastructure in a text file; AWS builds it exactly like that.

A template file with a few YAML lines, an arrow labeled deploy, and a stack containing a bucket, a function and a table

AWS CloudFormation is the AWS service for infrastructure as code. Instead of clicking through the console to create a VPC, two servers, a database and the permissions between them, you write a template (a YAML or JSON file) that lists those resources and their settings. You hand the template to CloudFormation and it creates everything, in the right order, as a stack.

The value shows up the second time. Need the same environment for testing? Deploy the same template under another name. Need a bigger database? Edit the file, update the stack, and CloudFormation works out the difference and applies only that. Did the change break? It rolls back to the previous state. The template lives in Git, so every change to the infrastructure has an author, a review and a history.

Example: a 150-line template defines an AWS Lambda function, its IAM role, an Amazon API Gateway in front and an Amazon DynamoDB table. One command (aws cloudformation deploy) creates all four in a couple of minutes; deleting the stack deletes all four, with nothing forgotten and still billing.

Raw templates get verbose, so many teams generate them: the AWS CDK lets you describe the same resources in TypeScript or Python code that compiles to CloudFormation, and AWS SAM is a shorthand for serverless apps. Terraform is the popular alternative that works across clouds.

Keep in mind

Go deeper

Related terms

More in AWS