liveBook · Manning

Immutable server

As explained in Amazon Web Services in Action, Third Edition: An in-depth guide to AWS

An immutable server is a server instance that is not modified after launch and is replaced with a newly built instance when changes are needed.

An immutable server is launched from an image and not changed afterward. When the application changes, build a new image and replace the existing server with a new instance. section 15.3 section 15.5

Treat every change as an image-building and rollout operation rather than an edit to a running machine. This makes deployments easier to reproduce and avoids accumulating undocumented changes. section 15.5 section 15.4

A practical AWS workflow uses these steps:

  • Define a Packer template with a source AMI, EC2 build settings, an IAM instance profile, and a provisioner script. section 15.3
  • Launch a temporary EC2 instance, connect through Systems Manager, install dependencies, copy application code, and create an AMI. section 15.3
  • Pass the AMI ID to a CloudFormation launch template, then let an Auto Scaling group replace instances through a rolling update. section 15.3

Etherpad AMI rollout

Run `packer init` and `packer build` to create an Etherpad AMI. Deploy it with CloudFormation by supplying the AMI ID, then update the Auto Scaling group so new instances use the image.

Table 15.2 Differences between CodeDeploy, CloudFormation and user data, and Packer (view table figure)

 

AWS CodeDeploy

AWS CloudFormation and user data

Packer

Deployment speed

Fast

Slow

Medium

Agility

Medium

High

Low

Advantages

In-place deployments work for stateful machines as well.

Changing the user data script is a flexible way to deploy changes.

Machines are starting really fast, which is important if you want to scale based on demand. Also, you have low risk of failures during the boot process.

Disadvantages

Changes pile up on machines, which make it difficult to reproduce a deployment.

Potential failures during the boot process exist, for example, when third parties like GitHub are down.

Handling the life cycle of AMIs is tricky because you have to clean up unused and old AMIs to avoid storage costs.

Compare immutable AMI deployments with CodeDeploy and CloudFormation user-data deployments, including speed, agility, and operational trade-offs. section 15.4

How Amazon Web Services in Action, Third Edition: An in-depth guide to AWS covers it

How deep it goes
Explains Packer image creation, Systems Manager provisioning, CloudFormation handoff, and Auto Scaling rollouts, but not AMI lifecycle automation.
Examples
Demonstrates Etherpad AMI construction with Packer and rolling deployment through CloudFormation and an Auto Scaling group.
What it assumes
Assumes basic EC2, AMI, IAM, Systems Manager, CloudFormation, and Auto Scaling knowledge while defining the replacement principle directly.
What you can do after
Operate reproducible EC2 deployments by building AMIs with Packer and rolling them out through CloudFormation.
How it connects
Connects immutable servers with AMIs, EC2, Packer, CloudFormation, Auto Scaling, containers, and Dockerfiles.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Amazon Web Services in Action, Third Edition: An in-depth guide to AWS. The section links point to the parts of the book it draws on.