Back to Terraform

EC2 Service Delivery: Launch Templates, Auto Scaling and ALB Health

November 6, 2026 Wasil Zafar 31 min read

Release compute capacity through immutable inputs, observable readiness and controlled replacement

Table of Contents

  1. Separate Image Build, Instance Bootstrap and Application Release
  2. Model EC2, EBS, Instance Profiles and Launch Templates
  3. Connect Scaling Groups to ALB Targets and Health
  4. Plan Image and Template Upgrades as a Service Change
  5. Measure a Controlled Replacement and Its Teardown

Separate Image Build, Instance Bootstrap and Application Release

An EC2 service is released three times before it answers a request. An image carries the operating system and runtime, a bootstrap script turns that generic image into a specific member, and an application artifact carries the code. Each layer changes on its own schedule, and only two of them are visible to Terraform.

A golden image is a versioned disk, not a running server. It is an AMI: an immutable snapshot of a root volume plus the metadata needed to launch it. Rebuilding it is a build job with a log and a digest, and the output is referenced by id, never edited in place.

LayerProduced byConsumed asTerraform visibilityRollback unit
ImagePacker or an image pipelineAMI id in a launch templatethe reference onlyprevious AMI id
Bootstrapthe service repositoryscript executed by cloud-initfull text in plan and stateprevious template version
ApplicationCI buildversioned artifact fetched at boota version string in a parameterprevious artifact version
Configurationparameter or config serviceenvironment at startkey names, not valuesprevious parameter revision

The image build belongs outside the state file. A builder that runs inside apply turns a reproducible artifact into a side effect, and a failed build then leaves half-created infrastructure behind. Packer, CodeBuild or any pipeline can produce the AMI; what matters is that the build is repeatable, tagged and auditable without a plan.

Terraform pins a reference, not a build. The launch template holds an image id that points at an artifact produced elsewhere. When the reference changes, capacity is replaced; when the build changes but the id does not, nothing happens, which is exactly why a rebuild must produce a new id.

An image id is regional, so a multi-region service builds per region. The id that a template names in one region means nothing in the next, and a copy step is part of the release rather than an operational afterthought. Whichever route you choose, the release record needs one entry per region, because a rollout that succeeded in one region says nothing about the other.

Bootstrap should fit on one screen. User data is capped at 16 KB, and the limit is a design signal: install the agent, fetch the artifact version, write configuration, start the unit. A script that clones a branch or runs migrations is a deployment hiding inside a boot.

The artifact is what makes rollback cheap. With the application baked into the image, every release is an image build plus a whole-fleet replacement. With the application as a versioned artifact, rollback is a version number and a restart, and the image changes only when the runtime or operating system does.

Provenance is the contract between pipelines. Both artifacts should carry the same release identifier, build number and source commit, so a running instance traces back to one pipeline run. Tags are the cheapest carrier: they survive in the AMI catalog and the artifact store, and they cost nothing to query.

Figure 1 follows the two build paths into a single launch contract.

Separate Image Build, Instance Bootstrap and Application Release
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
    S["Source commit"] --> I["Image build
Packer, outside Terraform"] S --> P["Artifact build
CI, versioned output"] I --> A["AMI
tagged release id"] P --> R["Artifact store
immutable version"] A --> T["Launch template
image id pinned"] R --> B["Bootstrap
fetch version at boot"] T --> G["Auto Scaling group"] B --> G G --> L["ALB target group"] A -.->|"rebuilt, same tag"| X1["Two images, one name"] R -.->|"latest tag moved"| X2["Old code, clean plan"] B -.->|"script too large"| X3["Truncated boot"] classDef primary fill:#132440,color:#ffffff,stroke:#0b172b; classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a; classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f; classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420; classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f; class S,G,L primary; class I,P,A,R,T,B secondary; class X1,X2,X3 danger;

Figure 2 draws the same separation as boundaries: the build side produces bits, and the runtime side only references them.

Build, registry and runtime boundaries for one EC2 release Build pipeline Source commit tag, branch, build id Image build Packer step, logs kept Artifact build CI package, digest No AWS resource is created here. A failed build leaves no capacity. Immutable registry AMI one id per build Artifact version addressable by digest Mutable tag a pointer, not a release Ids and digests are the contract. Tags are for humans, not plans. Runtime account Launch template image id, version N Scaling group min, max, desired Target group health decides membership Instances are created here, and none of them enter state. Terraform holds the reference: image id, template version, artifact version.

A rebuilt tag is not a new release. Mutable tags defeat the arrangement: the pointer stays the same, the digest changes, and a plan that compares pointers reports nothing. Reference artifacts by immutable version or digest, and let the tag remain a convenience for humans.

SymptomCollapsed layerFirst evidence
Fleet runs old code after a green refreshartifact version is outside the release recorddigest of the running artifact
One instance boots, its peers do notbootstrap depends on a hand-edited filecloud-init output on the failing member
Plan is empty but behaviour changedfloating tag or image aliasimage id and digest compared by hand
Apply fails partway through a releaseimage built inside applybuild log missing from the pipeline
Rollback needs a new buildapplication baked into the imageno previous artifact version to select

Terraform owns the contract, not the workshop. It records which image, which bootstrap and which artifact version a service should run. The build systems record how those bits were produced, and the release record joins the two.

Model EC2, EBS, Instance Profiles and Launch Templates

Five objects carry the compute contract. An instance is the running server, a volume is its disk, an instance profile is its identity, a launch template is the recipe, and a scaling group keeps a population alive. The first four are inputs you write; the fifth creates instances you never address directly.

ObjectTerraform resourceIdentityDurable stateReplaced when
EC2 instanceaws_instanceprovider-assigned idroot disk and processesimage, type, subnet or disk
EBS volumevolume resource or device mappingvolume id in one zonedatasize, type, encryption, zone
Instance profileaws_iam_instance_profileaccount-scoped namerole associationrole or name change
Launch templateaws_launch_templatename plus numbered versionsimage, script, mappingsname change; edits add versions
Scaling groupaws_autoscaling_groupgroup namedesired populationtemplate reference or zones

An instance id is assigned, not authored. Terraform creates an instance and records the id the API returns; inside a scaling group no instance appears in state at all. A member can be failing while the plan is clean, which is why health evidence has to come from the balancer.

A static name tag makes every member look alike. The template's tag_specifications apply one set of tags to every instance it launches, so a name copied from a single server gives the whole fleet one identity. Keep the shared tags for ownership and cost allocation, and let the instance id and the balancer's target list carry the per-member identity that an operator actually needs.

Replacement is a property of the resource, not of the change. The provider schema decides which arguments force a new instance, and the plan states the reason. Image, instance type, subnet and root disk replace; tags and security group membership update in place.

ArgumentPlan actionConsequence for a service
imagereplacenew member from the new image
instance typereplacecapacity lost unless a group replaces it
subnetreplacenew address, possibly a new zone
user datain place unless replacement is requestednew text in state, old script still running
security group membershipin placerules change without a restart
root block devicereplacedisk rebuilt from the image

A launch template is a recipe with versions. Editing it replaces nothing: the provider creates a new numbered version and leaves the earlier ones intact. That is the right model for a service, because the previous version stays a rollback target, but it also means an edit is not a release. Launch configurations are the legacy alternative and should not be the input for new work.

The schema is the contract, not a remembered example. With Terraform 1.17.1 and hashicorp/aws 6.72.0 pinned, the provider schema shows which argument is computed, optional or force-new before anything is planned. Reading it once per provider upgrade is cheaper than discovering a changed default during a release.

The default version is not automatically the newest. Unless update_default_version is set, the template's default stays where it was. A group that resolves to $Default therefore launches the old recipe while state and console both show that a newer version exists.

Two references decide what runs. The group names a template and a version, and the choice between a literal number and a moving alias is the difference between a reviewed release and a surprise. An alias such as $Latest resolves at launch time, so old and new members of one group can quietly run different recipes; a literal number is boring, and boring is the property you want in production.

An instance profile is a role wearing a launch-time name. The profile wraps one role, the template names the profile, and the instance receives short-lived credentials from the metadata service. That chain is why the profile exists before the template and why a missing profile fails at launch rather than at plan.

Metadata access is an attack surface with a hop limit. Requiring session tokens blocks the simplest request forgery, and the hop limit decides whether containers can reach the service. Both are template settings, so both belong in the reviewed recipe rather than in a console default.

Secrets never belong in user data. The script is stored in state, shown in the console and readable from the metadata service by any process on the instance; a password in it is a password in four places. The instance role should read the value at boot, and the template should hold only the parameter name.

Secret locationVisible toStored in stateRotation cost
user dataevery process on the instanceyes, in clearnew version and replacement
template taganyone who may describe ityestag edit, no restart
parameter storethe role that reads itthe name onlynew parameter revision
secrets servicethe role that reads itthe ARN onlyrotate without a rebuild
image layeranyone who may launch the imagenorebuild and replace

EBS is part of the recipe, not an afterthought. The root volume is created from the image snapshot, and any additional volume is declared in the device mapping. Size, type, encryption and delete-on-termination are decided there, and a mapping that omits them inherits defaults nobody reviewed.

The root volume deletes with the instance; an added volume may not. delete_on_termination defaults to true for the root device and to false for extra volumes, which is how a lab leaves a bill behind. Write the flag on every mapping, and treat an unencrypted snapshot as a blocker rather than a warning.

Encryption is a property of the volume, not of the account. An account default covers new volumes, but it does not prove which key was used or that an older snapshot is encrypted at all. Naming the key in the mapping makes the plan state it, so a missing grant fails where you can read it rather than at the first launch.

Figure 3 follows those objects through a plan and shows where each failure branch starts.

Model EC2, EBS, Instance Profiles and Launch Templates
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
    C["Edit the template"] --> V{"Image, type or script changed?"}
    V -->|"no, resource tags only"| U["In-place update
no new version"] V -->|"yes"| T["New numbered version
earlier versions kept"] T --> D{"Group names a literal version?"} D -->|"no, alias"| E["Group keeps resolving to the old default"] D -->|"yes"| G["Group configuration updated"] G --> F{"Instance refresh started?"} F -->|"no"| H["Old members keep serving"] F -->|"yes"| I["New member launched"] I --> J{"Profile attached and metadata reachable?"} J -->|"no"| X1["Launch fails or credentials absent"] J -->|"yes"| K{"Target health check passes?"} K -->|"no"| X2["Batch stalls, rollback triggers"] K -->|"yes"| L["Member in service"] L --> M["Release complete"] T -.->|"mapping omits encryption"| X3["Unencrypted volume"] T -.->|"version still referenced"| X4["Delete rejected"] classDef primary fill:#132440,color:#ffffff,stroke:#0b172b; classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a; classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f; classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420; classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f; class C,G,V,D,F,J,K primary; class U,T,E,I secondary; class L,M ok; class H warn; class X1,X2,X3,X4 danger;

The plan is the only place replacement is visible. The summary counts changes; the body says which argument forces replacement and why. Read the reason before approving, because a replacement inside a scaling group leaves no state entry to inspect afterwards.

Connect Scaling Groups to ALB Targets and Health

Registration and health are two different decisions. The scaling group decides how many instances exist; the target group decides which of them receive traffic. A green group with an unhealthy target group serves nothing, and a healthy target group with an empty group serves nothing either.

SignalOwnerDefaultWrong value looks like
minimum and maximum sizescaling groupmaximum requiredno room to surge, or a floor below the promise
target registrationscaling group target listnoneinstances run and never receive traffic
health check typescaling groupEC2 status onlya failing application keeps serving errors
health check grace periodscaling group300 secondshealthy members replaced during boot
deregistration delaytarget group300 secondsclients reset at scale-in
health thresholdstarget group30s interval, five healthy, two unhealthyslow admission or flapping

The group registers targets; an attachment would register them twice. Naming the target group in target_group_arns is the declarative path: every instance that joins is registered and every instance that leaves is deregistered. A separate attachment resource for the same pair creates a second owner and, at destroy, a registration that outlives the group.

Health check type decides who may kill an instance. The default check reads EC2 status, which knows the hypervisor and the network but not the application. Setting health_check_type to ELB makes the target group's verdict authoritative, so a member returning errors is replaced instead of retained.

Grace period covers boot, not readiness. A member may fail checks for the grace period before the group counts it, and boot, package install and the first artifact download all happen inside that window. Set it from observed boot time plus a margin, not from the provider default.

Admission is a budget of intervals. A new target is healthy after the healthy threshold passes, and a failing one leaves after the unhealthy threshold. Both costs are the interval multiplied by the count, so a fast check buys responsiveness and pays in probe traffic and false alarms.

Zone balance is a property of the group, not of the balancer. The group launches into the subnets it is given and rebalances across them as members are replaced, so a list with two subnets in one zone looks redundant and protects nothing. Spread the subnets, then check the per-zone healthy count during a replacement, because a total that looks correct can hide one zone serving everything.

Figure 4 places those budgets on one timeline, from launch to termination.

Readiness, draining and headroom on one timeline One member Launch pending Grace boot and install Admission checks pass In service receives traffic Drain in-flight only End exit Capacity band max want min headroom for a surge or a zone surge member floor held Requests 200 steady brief 503 before admission resets when drain is shorter than the slowest request The floor is min healthy percentage, not the desired count. Health checks stop new traffic. They do not finish the old request.

Draining is the part that loses requests. At scale-in the balancer stops sending new requests and waits for in-flight ones up to deregistration_delay, then the instance terminates. If that delay is shorter than the slowest request, the client sees a reset that no health check reported.

Keep-alive changes what draining can see. A long-lived connection can carry new requests after deregistration begins, so the delay must exceed the idle timeout as well as the request duration. Connection handling at the edge and at the target are separate settings, and only one of them lives in the target group.

Headroom is the distance between desired and maximum. A rolling replacement needs room to add a member before removing one, and a group whose maximum equals its desired count has nowhere to go. Surge capacity is also the budget for a zone loss, so size the maximum from the failure you intend to survive.

Slow start is a ramp, not a health check. A target group can send an increasing share of requests to a newly healthy target over a configured window, which matters when the first requests after boot are expensive because a cache is cold or a runtime is still warming. It changes how load arrives, not whether a member is admitted, and a target that fails health still leaves regardless of the ramp.

Instance refresh is a batch job with a health gate. It replaces members in batches, waits for each batch to pass health checks and warm up, and stops if the batch does not converge. min_healthy_percentage is the floor it may not cross, so it is also the availability promise during a release.

Refresh preferenceWhat it controlsCommon mistake
rolling strategyreplaces in place while keeping capacityassuming the surge is free
minimum healthy percentagethe floor during replacementsetting 100 with no room to launch
instance warmuptime before health countsshorter than the real boot
skip matchingleaves already-correct members aloneforcing a full replacement for a tag change
auto rollbackreverts a failed batchtreating it as an application rollback

A refresh is not a Terraform operation. Changing the version on the group updates the group's configuration; members keep running the old recipe until a refresh runs. The plan will report an in-place update while the fleet looks untouched.

Plan Image and Template Upgrades as a Service Change

A version bump is a service change with a rollout, not a one-line diff. The plan can show an in-place update to a group while every member still runs the old recipe. The release is the combination of a new version, a refresh, a health gate and evidence.

ChangePlan showsApply replaces membersRequired action
new image id in the templatein-place template updatenonew version plus refresh
new template versionin-place group updatenorefresh with a capacity check
new instance typein-place group updatenorefresh sized to the new type
edited bootstrapnew template versionnorefresh, then verify boot
raised minimum sizein-place updatesometimes, through scalingwatch quota and headroom
new health pathin-place target group updatenowatch the healthy count

A literal version is a reviewed release; an alias is a moving target. Writing a version number into the group makes the plan show the exact change and keeps rollback to the previous number. Using a moving alias keeps state unchanged when a new version appears, because the alias string is identical.

Every recipe change is already a version, so the template is its own audit trail. Version numbers record what changed and when, and the group's reference names exactly one of them. That history is more reliable than a chat message and cheaper than a changelog, and it is the reason a literal number in the group is worth the small extra toil.

The default version is the trap in the middle. A group that omits the version does not fall back to the newest one; it resolves to the template's default, and that default only moves when the template promotes each update. Reading a provider default as "latest" is how a fleet ends up launching an old recipe while the newest version sits unused.

Deleting a version is a dependency problem. A version still referenced by a group cannot be removed, and a template cannot be deleted while a group points at it. create_before_destroy on the template lets the replacement exist before the old resource is removed, which is what makes a rename or an image-only template change survivable. Retention still has to be planned: keep the previous version for rollback until the new one has served a full cycle.

Quota is part of the release plan. A rolling replacement needs vCPU quota for the surge capacity and an instance type that both zones will accept; a quota equal to the steady-state footprint turns a safe refresh into a stalled batch. Request the increase before the change window and record the approved limit in the release record.

Order the release around the artifact, not the template. Publish the image, publish the artifact, create the template version, then refresh. Refreshing before the artifact exists produces members that boot, pass a liveness check and fail their first real request.

Figure 5 compares the two reference styles and the state each leaves behind.

Pinned version versus moving alias Pinned version Template version 7 created group names the number Plan shows the version change reviewable before apply Refresh replaces in batches floor is minimum healthy Evidence and rollback target timestamps, healthy counts, version 6 Moving alias Template version 7 created group still says the alias Plan reports no change the alias string is identical Fleet keeps version 6 new capacity may differ from old Discovered during an incident two recipes in one group, no record of when Same template, two outcomes: a reviewed release, or an invisible no-op.

Rollback is a version, not a rebuild. Because old template versions and old artifacts remain, rollback points the group at the previous version and refreshes again. That is faster than rebuilding an image, and it is possible only if retention was decided before the incident.

A second target group is the alternative when a refresh is too slow. A blue/green release registers a new group behind the same listener and moves traffic with weights. It costs a second fleet during the cutover and needs a listener rule change, which is a different review from a refresh.

Warm pools trade money for boot time. Pre-initialised members in a stopped state shorten the wait for a healthy instance, at the cost of storage while they wait. They change the refresh timeline, not the health contract, so the release evidence stays the same.

Measure a Controlled Replacement and Its Teardown

Measure the replacement, not the apply. The useful record is a timeline: when the new version appeared, when the first member launched, when it passed health, when traffic moved, and when the last old member left. A plan summary contains none of those timestamps.

Capacity is the first measurement. Poll the group's instance count and the target group's healthy count together. A healthy count that drops below the floor during a batch is an availability event even when the release succeeds.

Request behaviour is the second. A steady request loop with a closed connection records status and latency through the whole rollout. Errors clustered at the drain step point at the delay; errors at admission point at the health path or the boot.

Teardown is part of the measurement. Old volumes, snapshots, images, template versions and target groups survive a successful release unless something removes them. The audit is a list, and it is the same list the next release inherits.

A release record should fit on one screen. It holds the image id and digest, the template version, the artifact version, the refresh start and end, the lowest healthy count, and the version to roll back to. A missing field is what the next incident spends its first ten minutes reconstructing.

EvidenceSourceWhat it proves
template version per memberdescribe-instances, or a boot-time tagwhich recipe the member launched from
image id per memberinstance identity documentwhich image actually booted
target health transitionstarget health APIwhen a member entered or left service
healthy count over timegroup metrics or a polling loopwhether the floor held
request status and latencyrequest loop or access logswhat clients experienced
leftover volumes and imagesinventory by tagwhat teardown still owes

Manual change is invisible and temporary. A fix applied over a session manager survives until the next replacement and then disappears, because the new member is built from the recipe. That is not a reason to avoid the fix during an incident; it is a reason to treat the next refresh as the test of whether the fix reached the image, the bootstrap or the artifact.

Lab

Measure a Controlled Replacement and Its Teardown

Status: design-only. No AWS account or credential was used to produce this article, and these steps were not executed here. Versions: Terraform CLI 1.17.1, hashicorp/aws 6.72.0, verified 6 November 2026.

Prerequisites. A sandbox account guarded by an allowed account id, a VPC with two subnets in two Availability Zones, an ALB with one target group, permission to manage EC2, IAM, ELBv2 and Auto Scaling, and a budget alarm. Start from a service already serving traffic through a launch template.

Minimal setup. One template version serving the current release, a group with a floor of two and a ceiling of four, an ELB health check on the application path, and a request loop that closes each connection.

ObjectLab value
Launch templateversion 1, image id pinned, instance profile attached
Scaling groupminimum 2, maximum 4, desired 2, ELB health check
Target groupapplication health path, 30-second interval, two-member floor
Refreshrolling, 75 percent minimum healthy, warmup above observed boot
Request loopone request per second, Connection: close
  1. Baseline. Record the healthy count, the template version each member was launched from, and the error rate over five minutes. Do not change anything until the baseline is boring.
  2. Record the reference. Write down the current template version number and image id. These two values are the rollback target.
  3. Publish a new release. Build a new image and artifact out of band, and record both digests. Confirm the artifact is fetchable before touching the template.
  4. Create the template version. Add the new image and artifact version, and note the number the provider created. Do not promote it by default yet.
  5. Plan. Expect an in-place update to the group with the explicit version number, and no instance replacement in the plan body. A replacement here means an argument, not a version, forced it.
  6. Refresh. Start the refresh and record t0. Watch the healthy count rather than the group's desired count.
  7. Poll both counts. Every ten seconds, record instances in service and targets healthy. Note the first new member, the lowest healthy count, and the return to the desired number.
  8. Read the request log. Expect a flat error rate; a short burst of 503s before admission is normal, resets at the end of a batch are not.
  9. Verify the defaults. Confirm the maximum size, grace period and deregistration delay are what the plan said, not what the console drifted to.
  10. Roll back. Point the group at the previous version, refresh, and confirm the old version returns without a rebuild.
  11. Teardown. Destroy with a reviewed plan, then audit images, snapshots, volumes, addresses, template versions and target groups.

Expected observation. A sequence rather than a duration: version recorded, template version created, refresh started, first new member healthy, floor never crossed, last old member gone, rollback returned the previous version. Capture timestamps from the refresh and the request log so the two can be joined.

Failure checks. A 503 burst that outlives admission points at capacity headroom or a health path that disagrees with the application. Resets at the end of a batch point at a deregistration delay shorter than the slowest request. A member that never becomes healthy points at a missing artifact, a blocked health port or a warmup shorter than boot. A plan that replaces instead of updating points at an argument outside the version reference.

Cost dimensions. Instance hours including surge capacity, EBS per GB-month including retained snapshots, load balancer hours and capacity units, and data transfer. The lab is small, but the old images and volumes bill until they are removed.

Cleanup. Deregister the old AMIs and delete their snapshots, remove template versions after the group stops referencing them, delete the target group after the listener, and check for available volumes, unassociated addresses and leftover log groups. Delete saved plans, keep state out of Git, and keep the previous version until the rollback window closes.

References (verified 6 November 2026):

  • aws_launch_template: https://registry.terraform.io/providers/hashicorp/aws/6.72.0/docs/resources/launch_template
  • aws_autoscaling_group: https://registry.terraform.io/providers/hashicorp/aws/6.72.0/docs/resources/autoscaling_group
  • aws_lb_target_group: https://registry.terraform.io/providers/hashicorp/aws/6.72.0/docs/resources/lb_target_group
  • Launch template versions: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/manage-launch-template-versions.html
  • Instance refresh: https://docs.aws.amazon.com/autoscaling/ec2/userguide/asg-instance-refresh.html
  • Instance metadata service: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-instance-metadata-service.html
  • Target group health checks: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/target-group-health-checks.html
  • Deregistration delay: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html

Next in the Series

In S3 as Infrastructure: Bucket Ownership, Policies, Encryption and Data Lifecycle, we'll explore Provision secure storage settings while keeping object data and destructive retention decisions separately owned.