An EC2 Auto Scaling group references a launch template by version. What is the practical difference between pinning it to $Latest, $Default, or a specific version number?
answer
- versions are immutable, never edited
- publishing is not releasing
- the next launch may be unattended
- running instances hold no live link
- quote the dollar sign in your shell
basics
~20 sLaunch template versions are immutable, so changes create new versions. $Latest means every new instance uses the newest version the moment it exists; $Default uses whichever version you explicitly promoted; a pinned number is fully deterministic. Running instances are never altered.
solid answer
~50 sA launch template version is immutable — you never edit one, you create a new version from a source version. The Auto Scaling group stores which version it should launch from, and that reference is where the risk lives. `$Latest` means the next instance the group launches picks up whatever version was created most recently, including one someone published but never tested — and that next launch may be an unattended health-check replacement at three in the morning. `$Default` decouples publishing from releasing: you create version 7 freely, then separately promote it to default when you are ready. A pinned number, typically written by your deployment tooling, is the most deterministic and the friendliest to change review. In all three cases, publishing a version changes nothing about instances already running; the fleet only converges when new instances launch, or when you deliberately roll the group with an instance refresh.
code
bash · 15 lines# 1. Publish a new version derived from version 6 (versions are immutable)
aws ec2 create-launch-template-version \
--launch-template-id lt-0123456789abcdef0 \
--source-version 6 \
--launch-template-data '{"ImageId":"ami-0abcdef1234567890"}'
# 2. Nothing is live yet. Promote it when you are ready.
aws ec2 modify-launch-template \
--launch-template-id lt-0123456789abcdef0 \
--default-version 7
# 3. The group launches new instances from the default version
aws autoscaling update-auto-scaling-group \
--auto-scaling-group-name web-asg \
--launch-template LaunchTemplateId=lt-0123456789abcdef0,Version='$Default'go deeper
Know that launch template versions are numbered and immutable, that a change means creating a new version, and that the group decides which version new instances get.
Explain the three reference forms and the practical consequence of each, and be clear that publishing a version changes nothing until an instance is actually launched.
Argue the release-safety angle: separate publishing from releasing, keep the version visible in review, and know that the next launch is frequently an unattended replacement rather than a watched deploy.
Own the fleet-consistency policy across many groups and accounts — who is allowed to promote a default, how a rollback is executed under pressure, and whether an intentionally mixed fleet is a canary strategy or an accident waiting to be diagnosed.
## Templates are versioned; versions are immutable A launch template describes how to build one EC2 instance: image, instance type, key pair, security groups, IAM instance profile, block device mappings, user data, metadata options and so on. You cannot modify a version once it exists. Every change produces a new numbered version, usually derived from an existing one: ```bash aws ec2 create-launch-template-version \ --launch-template-id lt-0123456789abcdef0 \ --source-version 6 \ --launch-template-data '{"ImageId":"ami-0abcdef1234567890"}' ``` That immutability is the feature. Every instance in your fleet can be traced back to an exact, unchangeable description of how it was built, which is what makes an incident timeline reconstructable. ## The three ways an Auto Scaling group can point at a version The group's launch template specification carries a `Version` field, and it accepts three forms. **A specific number** (`"3"`). Fully deterministic. The group launches version 3 until something explicitly changes the group. This is what infrastructure tooling usually writes, because the version number then appears in a diff and can be reviewed and rolled back like any other change. **`$Default`.** The group launches whatever version is currently marked default on the template. Promotion is a separate, deliberate act: ```bash aws ec2 modify-launch-template \ --launch-template-id lt-0123456789abcdef0 --default-version 7 ``` This separates *publishing* a version from *releasing* it, and gives you a single lever — flip the default back to 6 — for rolling back what new launches will use. Many teams like it because the release action lives on the template rather than on every group that consumes it, which matters when several groups share a template. **`$Latest`.** The group launches whichever version has the highest number. Convenient for a development environment, genuinely dangerous in production: the moment anyone creates a version — perhaps to test a change, perhaps by accident — it is armed. The next launch is often not a deployment you are watching but an automatic replacement of a failed instance or a scale-out at peak, so a broken version can enter the fleet unattended and then repeatedly, as each broken instance fails its health check and is replaced by another broken instance. ## Publishing a version does not touch running instances This is the part candidates most often get wrong in both directions. Creating a version does not restart anything, and it does not queue anything. Existing instances continue running exactly as launched; they hold no live link to the template. Convergence happens only through *replacement*: - **Organically**, as scale-out and health-check replacements gradually launch instances on the new version — which leaves you with a mixed fleet for an unpredictable amount of time. - **Deliberately**, by starting an instance refresh, which rolls the group by replacing instances in controlled batches with a minimum healthy percentage you choose. A mixed fleet is not automatically bad — it is how a canary happens — but it must be *intended*. Unintended mixed fleets are the source of the classic "only some requests fail" incident, because roughly a third of the instances carry a change nobody meant to release. ## Wiring the group ```bash aws autoscaling update-auto-scaling-group \ --auto-scaling-group-name web-asg \ --launch-template LaunchTemplateId=lt-0123456789abcdef0,Version='$Default' ``` Note the single quotes: `$Default` and `$Latest` are literal strings AWS interprets, and an unquoted `$` will be eaten by your shell as an empty variable — a small, real, and frequently-hit trap. ## Why launch templates rather than launch configurations Launch configurations were the original mechanism and are the legacy one. They are immutable with no version concept at all, so any change means creating a whole new configuration and repointing the group. They also do not support the newer Auto Scaling capabilities — a mixed-instances policy, for example. AWS stopped supporting the creation of new launch configurations at the end of 2023, and new work should use launch templates unconditionally. If an interviewer asks "launch template or launch configuration", the answer is simply that launch configurations are legacy and versioning is the reason. ## Choosing in practice Use `$Default` when a human or a release pipeline should decide when a built version goes live, and especially when several groups consume the same template. Use a pinned number when your infrastructure-as-code tool owns the change and you want the version visible in a code review. Reserve `$Latest` for environments where an unreviewed change going live is an inconvenience rather than an incident.
- You have published and promoted a new launch template version. How do you get the forty instances already running onto it?Start an instance refresh on the group. It replaces instances in batches while honouring a minimum healthy percentage you choose, waits an instance warmup between batches, and can be set to roll back automatically if it fails. Without it the fleet converges only as scale-out and health-check replacements happen, leaving you mixed for an unpredictable period.
- Why is $Latest specifically risky for a group that has a health-check-driven replacement loop?Because a launch triggered by a health check is unattended. If the newest version is broken, the replacement instance is also broken, fails its own health check, and is replaced again — you get a self-sustaining loop that churns instances and shrinks healthy capacity while nobody is watching a deployment.
saying these in an interview costs you the question
- Thinks publishing a template version restarts running instances
- Believes a launch template version can be edited in place
- Says $Latest and $Default are the same thing
- Uses launch configurations for new work
- Assumes the group automatically rolls the fleet onto a new version