Skip to content

feat(windows): full connect — launch defaults, RDP, SSH-over-SSM (#95) - #99

Merged
scttfrdmn merged 2 commits into
mainfrom
feat/95-windows-connect
Jun 11, 2026
Merged

scttfrdmn merged 2 commits into
mainfrom
feat/95-windows-connect

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Makes spawn handle the whole Windows lifecycle: launch sensibly, connect by both
RDP and SSH-over-SSM. Verified end-to-end on a real imported Win11 instance.

Launch (cmd/launch.go, pkg/aws/client.go)

  • Default --os windows to m7i.xlarge and reject burstable t-instances
    for Windows — Sysprep first boot starves on burst CPU credits (~20 min on
    t3.large in testing). Default applied before launchMode so --os windows with
    no --instance-type takes the flags path instead of dropping to the wizard.
  • Managed Windows security group opening RDP 3389 + SSH 22, CIDR-restrictable
    via --allow-cidr (default 0.0.0.0/0 with a warning). Previously Windows fell
    back to the default SG → RDP impossible.
  • Windows readiness waits on WaitForPasswordData (the real post-Sysprep
    "usable" signal), not an SSH-22 probe; success/DNS hints show
    spawn connect <name> --rdp, not a bogus Linux ssh ec2-user@.

Connect (cmd/connect.go)

  • New spawn connect --rdp: decrypts the Administrator password and opens
    Remote Desktop — direct to the public IP, or --via-ssm (auto when no public
    IP) over an AWS-StartPortForwardingSession tunnel to localhost:--rdp-port.
    rdpClientCommand picks mstsc / open-rdp / xfreerdp per OS.
  • Reuses existing primitives (WaitForPasswordData/DecryptWindowsPassword,
    findSSHKey, the SSM start-session shell-out). Default (no --rdp) intact.

SSM agent (buildWindowsUserData)

  • Ensure AmazonSSMAgent is installed + Automatic + started. Stock Windows
    Server AMIs ship it running, but the imported client AMI baked it without
    auto-start, so SSM never registered.

Verified live (instance terminated + leak-checked)

  • m7i.xlarge default, SG opens 22+3389, spawn:os/ttl tags, password-readiness.
  • spawn connect win -- <ps> → ran over SSM (returned hostname / nt authority\system).
  • spawn connect win --rdp → decrypted password + launched RDP client.
  • spawn connect win --rdp --via-ssm → "Port 13389 opened", local port forwards to 3389.

Tests: burstable guard, RDP command per-OS, default-type-non-burstable.
make check + e2e tier0 green.

Note: SSM registers only after the imported AMI's ~30+ min Sysprep first boot —
the warm-AMI optimization (#98) is the real per-launch perf fix and pairs with this.

Closes #95.

Make spawn handle the whole Windows lifecycle: launch sensibly, connect by both
RDP and SSH-over-SSM. A live test of an imported Win11 client AMI surfaced the
gaps this fixes.

Launch (cmd/launch.go, pkg/aws/client.go):
- Default --os windows to m7i.xlarge and REJECT burstable t-instances for Windows
  (guardWindowsInstanceType): Sysprep first boot starves on burst CPU credits
  (~20+ min on t3.large in testing).
- Open a managed Windows security group (CreateOrGetWindowsSecurityGroup) with
  RDP 3389 + SSH 22, CIDR-restrictable via --allow-cidr (default 0.0.0.0/0 with a
  warning). Previously Windows fell back to the default SG so RDP was impossible.
- Windows readiness waits on WaitForPasswordData (the real post-Sysprep "usable"
  signal), not an SSH-22 probe that won't answer; the success/DNS hints now show
  `spawn connect <name> --rdp` instead of a bogus Linux `ssh ec2-user@`.

Connect (cmd/connect.go):
- New `spawn connect --rdp` for Windows: decrypts the Administrator password and
  opens Remote Desktop — direct to the public IP, or `--via-ssm` (auto when no
  public IP) over an AWS-StartPortForwardingSession tunnel to localhost:--rdp-port.
  rdpClientCommand picks mstsc/open-rdp/xfreerdp per OS; credentials are printed.
- Reuses existing primitives (WaitForPasswordData/DecryptWindowsPassword,
  findSSHKey, the SSM start-session shell-out). Default (no --rdp) behavior intact.

SSM agent (buildWindowsUserData):
- Ensure AmazonSSMAgent is installed, set Automatic, and started. Stock Windows
  Server AMIs ship it running, but the imported client AMI bakes it without
  auto-start after Sysprep, so SSM never registered and SSH-over-SSM failed.

Tests: burstable/guard, RDP command per-OS, default-type-non-burstable.
make check + e2e tier0 green. Live verification (launch + both connect paths) next.

Refs #95.
The Windows instance-type default must be set BEFORE launchMode() runs:
launchMode treats an empty --instance-type as "go to the wizard (TTY) or pipe
mode", so `spawn launch <name> --os windows` with no --instance-type never
reached the flags path and dropped into the interactive wizard. Apply the
default to the instanceType var up front; the later validation just errors for a
genuine non-Windows omission now.

Refs #95.
@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 18.82845% with 194 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/launch.go 31.31% 68 Missing ⚠️
cmd/connect.go 17.94% 64 Missing ⚠️
pkg/aws/client.go 0.00% 62 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 1d5b0b2 into main Jun 11, 2026
2 of 3 checks passed
@scttfrdmn
scttfrdmn deleted the feat/95-windows-connect branch June 11, 2026 17:05
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.

SSM/spored doesn't come online on a launched imported Windows client AMI

1 participant