0Pricing
AWS for Backend Developers (EC2, S3, RDS, Lambda) · Lesson

Infrastructure as Code with CloudFormation

Learn how to define, provision, and version your AWS infrastructure declaratively using AWS CloudFormation templates and stacks.

Infrastructure as Code with CloudFormation is a free AWS for Backend Developers (EC2, S3, RDS, Lambda) lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the AWS for Backend Developers (EC2, S3, RDS, Lambda) learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Why Infrastructure as Code?

Clicking through the console to create resources is slow, error-prone, and impossible to reproduce reliably.

Infrastructure as Code (IaC) defines your infrastructure in files you can version, review, and deploy repeatedly.

What Is CloudFormation?

AWS CloudFormation provisions AWS resources from a declarative template. You describe the desired end state and CloudFormation figures out how to create it.

Templates and Stacks

Key terms:

  • A template is a YAML or JSON file describing resources
  • A stack is a deployed instance of a template
  • Updating the template updates the stack

A Minimal Template

This template creates a single S3 bucket.

AWSTemplateFormatVersion: '2010-09-09'
Resources:
  MyBucket:
    Type: AWS::S3::Bucket
    Properties:
      BucketName: my-iac-bucket

Parameters

Parameters make templates reusable by accepting input at deploy time, like an environment name or instance size.

Parameters:
  EnvName:
    Type: String
    Default: dev

Outputs

Outputs export useful values from a stack, such as a bucket name or endpoint URL, so other stacks or operators can reference them.

Outputs:
  BucketName:
    Value: !Ref MyBucket

Deploying a Stack

Create or update a stack from the CLI.

aws cloudformation deploy \
  --template-file template.yaml \
  --stack-name my-app

Change Sets

A change set previews exactly what an update will add, modify, or delete before you apply it — a safety net against accidental data loss.

Automatic Rollback

If a stack update fails partway, CloudFormation rolls back to the last known good state, so you are never left with half-broken infrastructure.

Drift Detection

Drift detection tells you when someone changed a resource manually outside CloudFormation, so you can bring reality back in line with the template.

CloudFormation in CI/CD

In a pipeline, CodePipeline can deploy CloudFormation stacks automatically on every commit, making infrastructure changes follow the same review-and-deploy flow as your application code.

Quick Check

Test your IaC knowledge.

Recap

You learned Infrastructure as Code:

  • Templates declare resources; stacks deploy them
  • Parameters and outputs make templates reusable
  • Change sets preview updates safely
  • Drift detection and rollback keep infrastructure consistent

IaC makes your infrastructure repeatable, reviewable, and version-controlled.

Frequently asked questions

Is the “Infrastructure as Code with CloudFormation” lesson free?

Yes — the full text of “Infrastructure as Code with CloudFormation” is free to read here on the web, and the AWS for Backend Developers (EC2, S3, RDS, Lambda) course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the AWS for Backend Developers (EC2, S3, RDS, Lambda) course, upgrade to CoddyKit PRO.

What will I learn in “Infrastructure as Code with CloudFormation”?

Learn how to define, provision, and version your AWS infrastructure declaratively using AWS CloudFormation templates and stacks. You practise AWS for Backend Developers (EC2, S3, RDS, Lambda) with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start AWS for Backend Developers (EC2, S3, RDS, Lambda)?

No prior experience is required. AWS for Backend Developers (EC2, S3, RDS, Lambda) on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Infrastructure as Code with CloudFormation” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this AWS for Backend Developers (EC2, S3, RDS, Lambda) lesson?

Yes. Every AWS for Backend Developers (EC2, S3, RDS, Lambda) lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. CodeCommit and CodeBuild Basics
  2. CodeDeploy for EC2/Lambda
  3. Serverless Application Model (SAM)
  4. Infrastructure as Code with CloudFormation
← Back to AWS for Backend Developers (EC2, S3, RDS, Lambda)