Skip to content

fix: re-arm EC2Launch before warm-AMI imaging so password is retrievable (#153) - #154

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/153-warm-ami-rearm-ec2launch
Jun 14, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/153-warm-ami-rearm-ec2launch

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Closes #153. Reported by the Windows 11 deploy tester: warm AMI launches fine, but spawn connect --rdp and the EC2 console can't retrieve the Administrator password ("Password is not available. The instance was launched from a custom AMI…").

Root cause

EC2Launch v2 generates the GetPasswordData-retrievable Administrator password in its setAdminAccount task, which runs once (run-once marker). The warm-AMI build (#98) waits for that password as its "first boot done" gate, then images the seed — but never clears the run-once state. So the warm AMI carries "already specialized" state and every launch from it returns no password. CLI and console hit the same EC2 API → both fail.

Fix

Before CreateAMI, buildWarmAMI now runs over SSM:

& "$Env:ProgramFiles\Amazon\EC2Launch\EC2Launch.exe" reset -c
  • reset -c clears EC2Launch's run-once state (+ logs) so setAdminAccount runs again on the warm AMI's next boot → fresh retrievable password per launch.
  • No Sysprep / no generalize — keeps the deliberate non-generalized single-instance warm image (Windows: create a warm/golden AMI from the imported one to skip Sysprep first-boot on every launch #98).
  • reset doesn't shut the instance down, so we image immediately after.
  • Image captured with NoReboot:true (was false): a reboot during imaging would let the seed consume the just-re-armed run-once task before the snapshot captures it, defeating the re-arm.

Running the reset needs SSM, so the warm build now hard-requires the seed's SSM agent to come Online (was best-effort, "image anyway") and fails loudly if it doesn't — a warm AMI that can't hand out a password is worse than a slow base AMI. The SSM wait uses the same generous --warm-timeout window.

Verified reset vs sysprep semantics against the AWS EC2Launch v2 docs (reset re-enables setAdminAccount without generalizing; doesn't shut down).

Tests

TestEC2LaunchRearmCommand pins the command (uses reset, passes -c, the EC2Launch v2 path, and crucially does not sysprep). The orchestration itself is AWS-heavy (Tier 1/2 live). make check green.

Validation

Needs a live re-test by the tester: re-run spawn image import (default warm) → launch the new warm AMI → spawn connect --rdp should now retrieve + decrypt the password. (The previously-built warm AMI is still broken — it predates this fix — so a fresh import is required.)

…ble (#153)

The warm-AMI build (#98) imaged the seed after EC2Launch had already run its
one-time setAdminAccount task, so instances launched from the warm AMI returned
"Password is not available. The instance was launched from a custom AMI..." for
both `spawn connect --rdp` and the EC2 console.

buildWarmAMI now runs `EC2Launch.exe reset -c` over SSM before CreateAMI, which
clears EC2Launch's run-once state so setAdminAccount regenerates a retrievable
Administrator password on the warm AMI's next boot — without generalizing
(no Sysprep), keeping the non-generalized single-instance image. The image is
captured with NoReboot:true so the re-armed (not-yet-run) state is preserved;
a reboot during imaging would let the seed consume the run-once task first.

Running the reset requires SSM, so the warm build now hard-requires the seed's
SSM agent to come Online (was best-effort) and fails loudly otherwise — a warm
AMI that can't hand out a password is worse than a slow base AMI.

Verified the reset semantics against AWS EC2Launch v2 docs.
@scttfrdmn
scttfrdmn merged commit 6c92abe into main Jun 14, 2026
2 checks passed
@scttfrdmn
scttfrdmn deleted the fix/153-warm-ami-rearm-ec2launch branch June 14, 2026 00:12
@codecov

codecov Bot commented Jun 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 36 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/image.go 0.00% 36 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Warm AMI hands out no Administrator password — EC2Launch not re-armed before imaging (GetPasswordData: "Password is not available")

1 participant