1Baking vs Bootstrapping
There are two main ways to configure an EC2 instance. Bootstrapping uses User Data scripts to install software *after* the instance launches. It's flexible but slow. Baking creates a Custom AMI with the software already installed. It's very fast to boot (crucial for Auto Scaling) but requires creating a new AMI every time you update the software.
2The Golden Image Pipeline
Modern DevOps teams use tools like HashiCorp Packer or AWS EC2 Image Builder to automate the creation of AMIs. Whenever a patch is released, a pipeline automatically boots a base AMI, installs the patch, creates a new Custom AMI, and updates Auto Scaling groups.
3Step-by-Step Breakdown
What is an AMI?. An Amazon Machine Image (AMI) is a master image used to create virtual servers (EC2 instances). It contains the OS and pre-installed software.
AMI Components. An AMI consists of an EBS snapshot (the root volume), launch permissions, and block device mappings.
Quick Start AMIs. AWS provides 'Quick Start' AMIs. These are maintained by AWS and include popular OS choices like Amazon Linux 2, Ubuntu, and Windows Server.
Custom AMIs. You can create your own Custom AMI from a running or stopped EC2 instance. This 'bakes' your software and settings into the image.
Golden Images. A 'Golden Image' is a heavily customized, fully configured AMI used by organizations to ensure all new servers meet security and software standards immediately upon boot.
AMI Region Check. Are AMIs global or region-specific?
- →Global
- →Region-specific (You must copy them to use in other regions)
- →AZ-specific
Copying AMIs. Because AMIs are bound to the Region where they were created, you must explicitly copy an AMI to another region if you want to deploy identical servers globally.
Marketplace AMIs. The AWS Marketplace allows you to buy AMIs with commercial software pre-installed (e.g., firewalls, proprietary databases), often billed hourly.
Community AMIs. Users can share their custom AMIs publicly. Use caution: only use Community AMIs from trusted publishers to avoid malware.
Completion. You can now bake and share server templates.
