Skip to content

[exploration] Windows AMI support — what's needed for connection & monitoring? #55

Closed

Description

@scttfrdmn

Summary (exploration, not yet a commitment)

Launching a Windows instance on EC2 is mechanically the same as Linux (RunInstances with a Windows AMI). What's fundamentally different is how we connect to it and how spored monitors it. This issue is to scope what a Windows path would actually require, before deciding whether to build it.

What's different on Windows

Connection:

  • No SSH by default — Windows uses RDP (port 3389) and/or WinRM / SSM Session Manager.
  • Initial credential is the Administrator password, retrieved via GetPasswordData + decrypted with the private key (not an SSH key login). spawn connect's SSH model doesn't map.
  • connect --command (one-shot exec) would need WinRM or SSM RunCommand instead of SSH.

spored / monitoring:

  • spored is a Linux systemd daemon. Windows needs it as a Windows Service (or a scheduled task), and the bootstrap is PowerShell user-data (<powershell>...</powershell>), not bash.
  • Idle detection, completion-file watching, TTL enforcement, cost accounting — the logic ports (it's Go), but every OS touchpoint (process/CPU sampling, service management, paths, the completion file) needs a Windows implementation.
  • The spored install script (curl from S3 + systemd) is entirely Linux-shaped.

Other:

Questions to answer in this exploration

  1. Connection model: RDP, WinRM, or standardize on SSM Session Manager (no inbound ports, works for both exec and interactive)? SSM is likely the cleanest fit and would also benefit Linux.
  2. Does spored become a cross-platform binary with a Windows service wrapper, or a separate agent?
  3. Minimum viable: maybe just launch + cost/TTL via tags + terminate (no in-instance agent) as a first step, deferring full spored parity?
  4. How much of connect/status/extend can be made transport-agnostic (SSM) vs needs Windows-specific code?

Context

Exploration request. Output should be a recommendation (SSM-first?) + a phased scope, not code. Depends conceptually on the multi-OS work and the cost audit (#51).

Activity

  1. added
    enhancement
    on Jun 3, 2026
  2. scttfrdmn commented on Jun 8, 2026

    @scttfrdmn
    ContributorAuthor

    Spike results (real Windows launch, 2026-06-08)

    Launched a Windows Server 2022 instance (ami-0909cee4864578472, t3.large, dev account) to validate the connection + monitoring assumptions end-to-end. Instance terminated immediately after; zero leaks verified across regions. Recommendation: SSM-first.

    What worked out of the box ✅

    • SSM agent is preinstalled on the stock Windows Server 2022 AMI. With only AmazonSSMManagedInstanceCore attached to the instance profile, describe-instance-information showed PingStatus=Online essentially as soon as the instance booted. No bootstrap needed for connectivity.
    • One-shot exec via SSM RunCommand (AWS-RunPowerShellScript) works — ran PowerShell remotely, got stdout back (PSVersion, hostname, nt authority\system). This is the Windows equivalent of connect --command.
    • Interactive connect: connectViaSessionManager (already in cmd/connect.go) uses aws ssm start-session, which is OS-agnostic and works on Windows today — no SSH, no inbound 3389.
    • ec2:GetPasswordData returned the encrypted Administrator password blob (684 chars) ~immediately — the RDP credential path is viable (decrypt with the keypair private key).

    What's broken / Linux-shaped today ❌

    1. buildUserData (cmd/launch.go:1966) unconditionally emits a #!/bin/bash script. Windows EC2Launch only runs <powershell>/<script>-tagged user-data, so the bash spored-install is silently ignored. The platform.Detect() in launch is the client's OS (the laptop), not the target — there's no notion of target-instance OS. So a Windows launch today boots a bare instance with no spored at all → no TTL/idle/cost/completion enforcement (exactly the zombie risk; the reaper backstop is the only safety net, and it's account-wide tag-based so it does cover Windows).
    2. spored is Linux-only — systemd unit + bash install-spored.sh + /tmp/SPAWN_COMPLETE. The Go logic ports, but every OS touchpoint (service mgmt, PowerShell user-data, CPU/process sampling, paths, completion file) needs a Windows impl, and it must ship as a Windows Service built for windows/amd64.
    3. Keypair for password decrypt: spawn registers the EC2 keypair from the user's existing SSH public key (spawn-key-<user>). Windows GetPasswordData decryption requires the RSA private key — if the user's key is ED25519, EC2 password decrypt won't work. spawn would need to ensure an RSA keypair for Windows launches and track the private key.

    Recommended phasing

    • Phase 1 (MVP, small): target-OS awareness in launch (--os windows or detect from AMI platform). For Windows: skip the bash spored bootstrap, attach AmazonSSMManagedInstanceCore, route connect + connect --command through SSM (start-session / RunCommand — already mostly present). Lifecycle = TTL/terminate via tags + the server-side reaper backstop (Server-side TTL reaper: out-of-band backstop so a spore can never outlive its deadline (even if spored is dead) #70), no in-instance agent yet. This alone gives launch + connect + bounded cost.
    • Phase 2: spored as a cross-platform binary with a Windows Service wrapper + PowerShell user-data; port idle/CPU/completion to Windows. Full parity (idle-stop, completion-file, pre-stop).
    • Phase 3: RDP credential helper (GetPasswordData + decrypt + emit .rdp), polish.

    Cross-cutting

    Net: the connection story is largely already here (SSM). The real build is target-OS-aware launch (Phase 1) and spored-on-Windows (Phase 2).

  3. scttfrdmn commented on Jun 8, 2026

    @scttfrdmn
    ContributorAuthor

    Phase 2 (spored on Windows) now tracked separately in #77. Phase 1 (target-OS-aware launch + SSM connect + TTL/reaper lifecycle) remains the prerequisite.

  4. scttfrdmn commented on Jun 8, 2026

    @scttfrdmn
    ContributorAuthor

    Phase 1 shipped in #82, released as v0.37.3.

    Verified end-to-end on real AWS (launch auto-detect/tag/key/warning; connect decrypted the live Administrator password + SSM; one-shot RunCommand; no-TTL guard; Linux regression).

    Remaining for full Windows parity: #77 (spored on Windows → in-instance idle/completion/pre-stop). Phase 1 leaned on the reaper backstop deliberately. Optional polish: .rdp file emission + auto-launch mstsc.

  5. added
    area:windows
    on Jun 12, 2026
  6. scttfrdmn commented on Oct 19, 2026

    @scttfrdmn
    ContributorAuthor

    Exploration complete and both phases shipped: Phase 1 (target-OS-aware launch, SSM/RDP connect) in #82, released v0.37.3; Phase 2 (spored as a Windows service) is #77, closed as completed and released in v0.38.1.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:windowsenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions