CLOUD CONCEPT

Immutable Infrastructure

Immutable infrastructure is an operating model in which deployed compute resources are replaced with newly built, versioned resources rather than modified in place.

Cloud Concepts Hub →

What is Immutable Infrastructure

Changes to operating systems, application dependencies, and security configuration are built into tested machine or container images and deployed as replacements. This reduces configuration drift and makes recovery more repeatable, provided that persistent data, secrets, and incident evidence are managed separately.

Immutable infrastructure treats deployed compute resources as replaceable instances of a controlled definition. Instead of logging into production servers to install patches or changing software inside running containers, engineers update the build definition, produce a new image, test it, and replace the affected resources. The objective is consistent, traceable deployments rather than a promise that running systems cannot change.

A typical cloud implementation combines version-controlled infrastructure definitions with automated image builds. A virtual machine image can include a patched operating system, approved packages, logging configuration, endpoint protection, and a management agent. A container image can include a minimal runtime, pinned dependencies, and an application configured to run without root privileges. Build pipelines should scan and test these artifacts, restrict who can publish them, and record their provenance. Secrets and long-lived credentials should not be embedded in either image type; workloads should obtain credentials and configuration through controlled runtime mechanisms.

For example, an EC2 fleet can use a launch template that references an approved AMI. To remediate a vulnerable library, build and validate a replacement AMI, create a new launch template version, and roll the fleet onto that version using an instance refresh. For containers, rebuild the image and update the deployment to a specific image digest. A mutable tag such as latest does not reliably identify the artifact that was tested. Health checks, capacity headroom, and connection draining help replacements occur without unnecessary service interruption.

Hardening belongs in the build process, but some controls must be applied at deployment or runtime. Installing the Systems Manager Agent in an AMI does not by itself make an instance manageable: the instance also needs suitable permissions, connectivity, and a supported agent configuration. Similarly, a hardened container image does not enforce the workload's network policy or runtime privileges. Least-privilege roles, restricted network access, monitoring, and runtime security controls remain necessary.

During a security incident, replacing a compromised resource is a recovery technique, not the entire response. First contain the affected workload using appropriate network controls and remove it from normal traffic. Coordinate with orchestration and automatic replacement processes so that evidence is not inadvertently destroyed. Preserve required disk snapshots, logs, and, where appropriate, volatile evidence before termination. Restrict access to forensic artifacts because they may contain sensitive information.

Recover by deploying a trusted image that addresses the entry point, rotating exposed credentials, and checking for persistence outside the replaced resource. Restore persistent data from a validated recovery point when necessary, and verify that the restored data does not reintroduce malicious content. An image captured from a compromised server is not a trustworthy recovery baseline. Replacing compute alone does not remove an attacker’s access through stolen credentials, altered identity policies, or infected shared storage.

The main trade-offs are build latency, image maintenance, temporary replacement capacity, and the need to separate application state from disposable compute. Emergency in-place patching may sometimes be justified, but it creates an exception that must be incorporated into the next approved image. Infrastructure as code alone does not make a system immutable if deployments still modify existing hosts. Immutable infrastructure also does not replace backups, and rolling back an image may be unsafe when database schemas have changed or the previous image contains a known vulnerability.

Key aspects of Immutable Infrastructure

Immutable infrastructure combines trusted image builds, replacement-based deployment, externalized state, and evidence-aware recovery to reduce drift and make compute workloads reproducible.

Replace rather than modify

Deliver software and configuration changes through newly built resources instead of routine in-place edits. Restrict interactive production changes and reconcile any emergency exceptions into the approved build.

Versioned, trusted artifacts

Identify approved machine images and container images explicitly, using AMI IDs or container digests as appropriate. Protect build pipelines and artifact publishing permissions so that a repeatable deployment does not repeatedly deploy a compromised artifact.

Security built into the baseline

Apply operating system hardening, dependency updates, logging agents, and security tooling during image creation. Validate both image contents and the deployment-time permissions, connectivity, and runtime settings needed for those controls to function.

Controlled replacement and recovery

Use staged deployment, health checks, and sufficient capacity to replace resources safely. Retain approved versions for recovery, but verify security fixes and data compatibility before rolling back.

Separation of state and secrets

Keep durable application data outside disposable compute and protect it with independently tested backups. Retrieve secrets at runtime rather than baking credentials into images.

Evidence-aware incident response

Contain suspected workloads and preserve required evidence before replacement destroys it. Rebuild from a trusted baseline, address the initial compromise, and remediate exposed credentials and affected external state.

Cloud services for Immutable Infrastructure

EC2 Image Builder produces tested machine and container baselines, while Amazon ECR stores container artifacts for deployment. EC2 Auto Scaling replaces virtual machines using approved AMIs, and Amazon ECS replaces container tasks using updated task definitions. Systems Manager provides operational visibility and controlled automation without making routine production edits the deployment model. AWS Backup protects supported persistent resources that must survive compute replacement. Together, these services support rebuilding workloads from trusted artifacts while keeping state recoverable. Incident workflows must additionally coordinate containment, evidence preservation, credential remediation, and validation before returning replacement workloads to service.

EC2 Image Builder

Automates the creation, testing, and distribution of AMIs and container images using defined recipes and components. Use it to build patched, hardened baselines rather than manually maintaining production hosts.

Open EC2 Image Builder →
Amazon EC2 Auto Scaling image Amazon EC2 Auto Scaling

Replaces EC2 instances using launch template configurations that reference approved AMIs. Instance refresh supports rolling a fleet onto a new image; incident procedures should account for automatic replacement before isolating or preserving affected instances.

Open Amazon EC2 Auto Scaling →
AWS Systems Manager image AWS Systems Manager

Supports inventory, managed access, and automated operational or response workflows for instances configured with the necessary agent, permissions, and connectivity. Use it to inspect and orchestrate workloads while keeping routine patch delivery in the image rebuild-and-replace process.

Open AWS Systems Manager →
AWS Backup image AWS Backup

Provides policy-based backup and restore capabilities for supported persistent resources. It complements disposable compute by protecting state, but recovery procedures must still validate recovery points and avoid restoring compromised data.

Open AWS Backup →