Skip to content

Use the Windows AMI for launch-windows by default - #32

Draft
claude[bot] wants to merge 1 commit into
mainfrom
bugfix/launch-windows-default-ami
Draft

claude[bot] wants to merge 1 commit into
mainfrom
bugfix/launch-windows-default-ami

Conversation

@claude

@claude claude Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Before: bastion launch-windows with the default --ami windows launched an Amazon Linux 2023 instance, not Windows Server 2019. With --rdp, no Windows password is ever produced, so the command fails after the instance is already running.

After: launch-windows launches from the Windows Server 2019 Base image (/aws/service/ami-windows-latest/Windows_Server-2019-English-Full-Base) as the flag help says. launch and port-forward behave as before: amazon-linux still picks the x86_64 or arm64 AL2023 image to match the instance type.

How: GetAndValidateAmi overwrote every named alias with the output of GetArchitecture, which only ever returns amazon-linux or amazon-linux-arm64, so the windows entry in the amis map could never be reached. Architecture detection was added in #16 for Amazon Linux. Alias resolution now lives in a small amiParameterForAlias helper. Amazon Linux aliases, and unrecognised names (unchanged fallback), are still resolved by architecture. Any other named alias, currently just windows, maps straight to its own SSM parameter. AMI IDs (ami-...) and SSM parameter paths (/...) are handled exactly as before.

Verification

  • go build ./... and go vet ./bastion/ are clean, and gofmt -l . reports nothing.
  • Added bastion/ami_test.go, which tests alias resolution with a stubbed architecture lookup: windows is not replaced, amazon-linux follows x86_64/arm64, unknown names fall back to architecture detection, and lookup errors are passed back. go test ./bastion/ passes on Go 1.24. The code only uses APIs that exist in Go 1.16, the version CI uses.
  • Not tested against AWS. Please verify that bastion launch-windows in an account launches an instance whose Platform is windows.

No version file to bump: the release version comes from the git tag through ldflags/goreleaser.

GetAndValidateAmi replaced every named alias with the result of
architecture detection, which only returns Amazon Linux aliases. The
"windows" alias (the launch-windows default) was therefore unreachable
and Windows bastions were launched from an Amazon Linux 2023 image.

Only Amazon Linux aliases (and unrecognised names, as before) are now
resolved by instance architecture; other named aliases map directly to
their SSM parameter. Adds unit tests for the alias resolution.
@claude
claude Bot requested a review from tarunmenon95 September 30, 2026 13:32
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.

1 participant