Cloud concept · Updated

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.

In short

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.

Cloud Concepts Hub →

6 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.

01
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.

02
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.

03
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.

04
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.

05
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.

06
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.

Amazon EC2 Auto ScalingAmazon 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.

AWS Systems ManagerAWS 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.

AWS BackupAWS 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.

Immutable Infrastructure exam questions

Real practice exam questions on Immutable Infrastructure, with the correct answer and its explanation. Answer them with every option in the exam simulator.

MLA-C02 (beta)

A company runs GPU-based PyTorch inference on Amazon EKS. Its application image extends an AWS-provided framework image with a custom preprocessing package and is stored in private Amazon ECR. A security review identifies a vulnerable CUDA user-space library inherited from the base image. AWS has published a replacement base image that fixes the vulnerability and supports the company's approved PyTorch version and GPU instances. The company requires tested, reproducible releases and rollback to the exact previous application image. Which solution meets these requirements with the least dependency-maintenance effort?

Show answerCORRECT ANSWER

Update the Dockerfile to reference the patched GPU inference AWS Deep Learning Container by digest. Rebuild the application image with pinned custom dependencies, test it, and push it to Amazon ECR. Deploy the new application image by digest and retain the previous digest for rollback.

AWS Deep Learning Containers provide preconfigured framework and accelerator libraries, reducing the need to assemble and maintain that stack. Rebuilding from the compatible patched base incorporates the library fix into the application image. Pinned dependencies, testing, digest-based deployment, and retention of the previous image provide reproducibility and exact rollback.

SOA-C03

A company runs an Amazon ECS service on EC2 container instances. EC2 Image Builder produces the host AMI, and Amazon ECR stores the application's container image. A security assessment identifies a vulnerable Linux kernel on the hosts and a vulnerable application library in the container image.

The company requires both vulnerabilities to be remediated. All operating system and application software changes must pass testing before reaching production. Production hosts and running containers must not have software installed or updated in place. Sufficient capacity is available to drain workloads during replacement.

Which remediation plan meets these requirements?

Show answerCORRECT ANSWER

Build and test a replacement host AMI with the updated kernel and a replacement container image with the updated library. Update the fleet's launch configuration to use the new AMI, drain and replace the existing hosts, and deploy replacement tasks that reference the tested container image digest.

The host AMI controls the host kernel, while the container image controls the application's library. Testing both replacement images and replacing the hosts and tasks remediates both layers without modifying production software in place. Referencing the tested container image digest identifies the exact approved artifact.

SCS-C03

A company stores container images in private Amazon ECR repositories. A security-controlled build pipeline applies the required hardening configuration and runs security tests. Developers can also push images to these repositories, so the presence of an image in a repository does not establish that it passed the approved build process.

The security team wants cryptographic evidence that each production image passed the security-controlled pipeline and has not changed since approval. The production deployment pipeline is centrally managed, and developers cannot modify or bypass its checks. Images that lack valid evidence must not be deployed, including when verification cannot complete.

Which solution best meets these requirements?

Show answerCORRECT ANSWER

Use AWS Signer with Notation in the security-controlled pipeline to sign images after all required tests pass. Restrict use of the signing profile to that pipeline. Before deployment, verify the signature against a trust policy for the approved signing identity, reject missing or invalid signatures and verification errors, and deploy the verified image by digest.

Signing after successful testing binds the approved signing identity to the image digest. Restricting signing permissions makes that identity evidence of the approved pipeline. Explicit signature verification with a trusted identity and fail-closed behavior rejects unapproved or unverifiable images. Deploying the verified digest ensures production uses the exact artifact that was checked.

Practice Immutable Infrastructure in a full exam

Questions on Immutable Infrastructure in each practice exam, with every answer option and an explanation for each:

Start a free practice exam

What is Immutable Infrastructure

3 min read

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.

Learn Immutable Infrastructure in lessons

10 short lessons on Immutable Infrastructure in 6 certification courses.

and 4 more lessons

Open the lessons