Immutable infrastructure

Task Statement 2.2: Design highly available and/or fault-tolerant architectures.

📘AWS Certified Solutions Architect – (SAA-C03)


What is Immutable Infrastructure?

Immutable infrastructure means that once a server or resource is created, it is never modified after deployment.

Instead of updating or patching a running server:

  • You create a new server with the required changes.
  • You replace the old server with the new one.
  • The old server is then deleted or terminated.

👉 In simple terms:
“Don’t change servers—replace them.”


Why Immutable Infrastructure is Important

Immutable infrastructure is widely used in AWS to improve:

  • High Availability
  • Fault Tolerance
  • Consistency
  • Predictability
  • Security

It ensures that every deployment is:

  • Repeatable
  • Reliable
  • Free from configuration drift

Key Concepts

1. Configuration Drift

When a server is updated manually over time (patches, hotfixes, configuration changes), it becomes different from the original version. This is called configuration drift.

Problems caused by drift:

  • Unexpected bugs
  • Hard-to-debug issues
  • Environment inconsistency (dev vs production)

👉 Immutable infrastructure eliminates configuration drift because servers are never modified after creation.


2. Golden Image

A golden image is a pre-configured machine image used to launch servers.

In AWS, this is typically created using:

  • Amazon Machine Image (AMI)

Steps:

  1. Create a base server
  2. Install required software and configuration
  3. Create an AMI from it
  4. Use this AMI to launch identical instances

👉 Each new instance is a copy of the same image, ensuring consistency.


3. Replace Instead of Patch

Instead of:

  • SSH into a server and install updates

You:

  1. Build a new AMI with updates
  2. Deploy new instances using that AMI
  3. Redirect traffic to the new instances
  4. Terminate old instances

How Immutable Infrastructure Works in AWS

Common Services Used

  • Amazon EC2
  • Auto Scaling Groups
  • Elastic Load Balancer (ELB)
  • Amazon Machine Images (AMI)
  • AWS CodeDeploy / CI-CD pipelines

Example Workflow

  1. You create a new application version.
  2. Build a new AMI with the updated code.
  3. Update the Auto Scaling Group to use the new AMI.
  4. The system launches new EC2 instances.
  5. Health checks ensure the new instances are working.
  6. Old instances are gradually terminated.

👉 This ensures zero downtime and smooth transitions.


Deployment Strategies for Immutable Infrastructure

1. Blue/Green Deployment

Two environments:

  • Blue = current version (live)
  • Green = new version

Steps:

  1. Deploy the new version (Green)
  2. Test it
  3. Switch traffic from Blue → Green
  4. Terminate Blue

Services used:

  • Elastic Load Balancer
  • Route 53

2. Rolling Deployment

Gradually replace instances in batches:

  • A few instances are updated at a time
  • Traffic continues to flow

Used with:

  • Auto Scaling Groups

3. Canary Deployment

  • Deploy new version to a small subset of users
  • Monitor performance
  • Gradually increase traffic

Benefits of Immutable Infrastructure

1. High Availability

  • New instances are launched automatically
  • No need to patch running systems
  • Reduces downtime

2. Fault Tolerance

  • If a server fails → just replace it
  • No dependency on a single server

3. Consistency

  • Every instance is identical
  • Eliminates environment differences

4. Easier Rollbacks

  • If something breaks:
    • Switch back to the previous AMI
  • Fast and reliable recovery

5. Improved Security

  • Old instances are destroyed regularly
  • Reduces attack surface
  • Ensures latest patches are included in new images

Limitations / Challenges

  • Requires strong automation (CI/CD pipelines)
  • Stateless design is preferred (state must be externalized)
  • Slightly higher storage and build overhead (new images each time)
  • Initial setup can be complex

Stateful vs Stateless (Important for Exam)

Stateless Applications

  • No stored session or data on the server
  • Works perfectly with immutable infrastructure

Examples:

  • Web servers
  • API services

Stateful Applications

  • Store data locally (e.g., logs, session, files)

👉 In immutable architecture:

  • State must be stored externally:
    • Amazon S3
    • Amazon RDS
    • Amazon DynamoDB
    • Amazon EFS

Exam Tips (VERY IMPORTANT)

You will often see questions like:

1. “How to ensure consistency across environments?”

✔ Answer: Use immutable infrastructure with golden images (AMI)


2. “How to reduce configuration drift?”

✔ Answer: Do not modify running instances—replace them with new ones


3. “How to safely deploy new versions with minimal downtime?”

✔ Answer:

  • Use immutable infrastructure
  • Combine with:
    • Blue/Green deployment
    • Auto Scaling
    • Load balancer

4. “How to recover from failure quickly?”

✔ Answer:

  • Launch new instances using a known good AMI
  • Replace failed instances automatically

Key AWS Services to Remember

  • Amazon EC2 – compute instances
  • Amazon Machine Image (AMI) – golden images
  • Auto Scaling Groups – replace instances automatically
  • Elastic Load Balancer (ELB) – distribute traffic
  • AWS CodeDeploy – automated deployments
  • Amazon S3 / RDS / DynamoDB – external state storage

Simple Summary

  • Immutable infrastructure = never modify servers
  • Always replace with new versions
  • Uses AMI (golden images)
  • Works with Auto Scaling + Load Balancers
  • Helps achieve:
    • High availability
    • Fault tolerance
    • Consistency
    • Easy rollback
Buy Me a Coffee