Skip to content

Managed egress proxy for --no-public-ip bootstraps (no NAT gateway, no mirrors) #1515

Closed

Description

@scttfrdmn

Problem

A --no-public-ip instance has no route to the internet unless its subnet routes 0.0.0.0/0 to a NAT gateway. Today the bootstrap needs the internet in three places:

A NAT gateway costs about $33/month per AZ before its $0.045/GB data charge. The owner does not want users pushed onto it, and does not want spore.host mirroring third-party artifacts.

The preflight check also refuses a route to a NAT instance that the user runs themselves. pkg/aws/private_network.go counts only a NAT gateway as a way out (around lines 232–238 and defaultRoute).

Design (owner-approved direction, 2026-11-02)

A spore.host-managed egress proxy in the user's own VPC, on the same ownership model as the self-hosted reaper (pkg/reaperdeploy). spore.host creates, tags, upgrades and deletes it, and it lives in the user's account.

  • One per VPC, created on demand. The first --no-public-ip launch whose bootstrap needs the internet creates one small instance (t4g.nano) in a public subnet of that VPC, using an auto-assigned public IPv4 address rather than an EIP. Later launches in that VPC reuse it.
  • A forward HTTPS proxy, not NAT. There are no route table changes, so other instances in the subnet get no egress. The member bootstrap sets https_proxy and http_proxy only for its own downloads (curl, apt). The proxy:
    • accepts connections only from spawn's instance security groups and has no inbound internet ports;
    • allows CONNECT only to the destinations spawn needs: efa-installer.amazonaws.com, awscli.amazonaws.com, and the regional Ubuntu archive mirrors. The list is derived from code, not hand-kept.
  • Configurable idle expiry, relaunched on demand (owner decision). The proxy's spored deletes it, and its SG, after an idle period with no proxied traffic. The period is configurable, with a default (proposed: 14 days). If a later launch needs the proxy again, it is simply recreated. TTL always terminates, and the reaper is the backstop.
  • Lifecycle commands: spawn egress-proxy status | delete | upgrade. delete is the named deleter, so nothing outlives an explicit delete or the idle expiry.
  • Patching. Unattended OS security updates, with a reboot in a maintenance window.
  • Version skew. Each launch that uses the proxy compares the proxy's spawn version with its own. If the proxy is older, the launch replaces it, which is cheap at this size. This avoids the "Lambdas never upgrade" problem.
  • Opt-in vs default. Some users choose private subnets for compliance reasons, so creating a path to the internet must be visible. Proposal: the preflight says what needs the internet and offers --bootstrap-egress proxy. A config default lets a user opt in once.

Rough cost: about $3/month for the instance plus about $3.60/month for its public IPv4, so roughly $6–7/month per VPC while it exists. It costs nothing once it has expired.

Limits

  • The VPC needs a public subnet with an internet gateway. A fully isolated VPC cannot use any proxy. The preflight must detect this and say so.
  • One proxy per VPC. That makes it a single AZ, so a proxy AZ outage blocks bootstraps that need it. That is acceptable for a bootstrap-time dependency, and is noted rather than solved.

Sub-tasks

  • Preflight: count a 0.0.0.0/0 route to a NAT instance or ENI as a way out, and report the proxy option when there is none.
  • Proxy: AMI/user data for the proxy (AL2023 arm64), with the allowlist derived from code and spored with the idle-expiry policy.
  • Launch: find-or-create in the launch path (CLI and sweep orchestrator), with a version check and replacement when skewed.
  • Bootstrap: member bootstrap proxy env, scoped to spawn's own fetches.
  • CLI: spawn egress-proxy status|delete|upgrade. The reaper must cover proxy instances.
  • Live test: a no-NAT VPC, Ubuntu --mpi --efa 2-node, plus AL2023; verify idle expiry and relaunch.
  • Mirror retirement: once this ships, retire the AWS CLI regional mirror (bootstrap: Ubuntu in a private subnet cannot install the AWS CLI (awscli.amazonaws.com unreachable), so it now fails closed #1494), meaning the release step, the AWSCLIMirror release-role policy and the bucket objects, so one mechanism covers everything.

Considered and rejected

  • A temporary NAT instance plus a route: it changes a shared route table, gives egress to everything in the subnet, conflicts with existing default routes, and leaves the most damage if teardown fails.
  • A spore.host-hosted proxy via PrivateLink: every user pays for an interface endpoint (about $7/month per AZ plus data), spore.host would run a shared egress service, and it needs a cross-account allowlist per user account.
  • Mirroring: the owner prefers not to, and it cannot cover apt.

Activity

  1. added this to the v0.157.0 milestone on Nov 3, 2026
  2. added
    enhancement
    area:launch
    area:lifecycle
    area:networking
    on Nov 3, 2026
  3. scttfrdmn commented on Nov 3, 2026

    @scttfrdmn
    ContributorAuthor

    Owner decision (2026-11-02): the proxy is opt-in. spawn never creates it implicitly.

    • How to opt in: pass --bootstrap-egress proxy, or set a config default once.
    • Without opting in: when a launch needs internet access, the preflight lists what it needs and names the flag, and the launch stops. It never creates the proxy.
  4. scttfrdmn commented on Nov 3, 2026

    @scttfrdmn
    ContributorAuthor

    Build plan for v0.157.0

    Phases in order. Each one is a PR, and each PR that touches user data gets a live run with a CLI built from its branch before it merges.

    1. Preflight (in progress). Count a working NAT instance as a way out, using ec2:DescribeInstances only, so users need no new IAM. A route to an instance counts only if the instance is running, has source/dest check off, has a public IPv4, and sits in a subnet whose default route is an IGW. Otherwise the launch is refused with the exact reason.
    2. The proxy is a mode of spored, not squid or tinyproxy. Proposal: spored egress-proxy, a small Go forward proxy.
      • Why spored:

        • No third-party package to patch.
        • Proxy upgrades become spored upgrades, so a version-skew check is the spawn version.
        • spored already enforces TTL, idle and terminate, so idle expiry is just "no proxied connection for N".
        • The allowlist lives in code, derived from the same source as the bootstrap's fetch list.
      • It must handle two kinds of traffic:

        • HTTPS CONNECT (EFA installer, AWS CLI);
        • plain-HTTP GET forwarding, because Ubuntu's EC2 apt mirrors (*.ec2.archive.ubuntu.com) are http:// by default.

        The host allowlist applies to both.

      • Network access: SG ingress only from spawn's instance SGs on the proxy port, and no other ingress.

    3. Find or create. Wire this into the CLI launch path and the sweep orchestrator.
    4. Bootstrap. Members set http_proxy, https_proxy and no_proxy (169.254.169.254, .amazonaws.com endpoints that have VPC endpoints, and the VPC CIDR) only around spawn's own fetches. That covers curl, apt (Acquire::http::Proxy) and the EFA installer's internal apt/dnf. The user's job is never proxied implicitly.
    5. spawn egress-proxy status | delete | upgrade. Also: reaper coverage, and the docs and IAM table.
    6. Live test. In a no-NAT VPC: Ubuntu --mpi --efa with 2 nodes, plus AL2023. Then shorten the idle period to check that expiry deletes the instance and SG, and that the next launch relaunches the proxy.
    7. Retire the AWS CLI mirror (bootstrap: Ubuntu in a private subnet cannot install the AWS CLI (awscli.amazonaws.com unreachable), so it now fails closed #1494): the release step, the AWSCLIMirror release-role policy, and the bucket objects.
  5. scttfrdmn commented on Nov 3, 2026

    @scttfrdmn
    ContributorAuthor

    Phase 1 is merged: #1516 (64bc8e5c). The --no-public-ip preflight now accepts a working NAT instance, using ec2:DescribeInstances only, so users need no new IAM.

    • The routed interface must have source/destination check off.
    • At least one interface must have a public IPv4 address and sit in a subnet routed to an internet gateway, so a two-interface NAT passes.
    • Each failed check is named in the refusal.

    It hasn't run against real AWS yet. The phase 6 live test covers it. Phase 2, the spored egress proxy, is in progress.

  6. scttfrdmn commented on Nov 3, 2026

    @scttfrdmn
    ContributorAuthor

    Phase 2 is merged: #1517 (2c0abab9). It adds the spored egress-proxy subcommand, with a standard-library forward proxy in pkg/egressproxy.

    • What it forwards: HTTPS CONNECT to port 443 only (raw tunnel, no TLS interception), and plain-HTTP GET/HEAD to port 80 only.
    • Allowed sites: a code-derived allowlist, egressproxy.Allowlist, where a wildcard matches exactly one label. Tests fail if the EFA or AWS CLI origins drift off it.
    • Address guard: a host that resolves to any non-public address is refused, including IMDS, private ranges and IPv6-embedded forms. It then dials only the vetted IP, so DNS rebinding can't redirect it.
    • Idle expiry: this replaces spored's other idle signals and terminates through the existing TTL path, never stop. Activity is persisted, and on restart it takes the later of the persisted time and the instance's launch time, so patch reboots don't reset the clock.

    Next is phase 3: find-or-create, the opt-in flag and config, and the security group.

  7. scttfrdmn commented on Nov 3, 2026

    @scttfrdmn
    ContributorAuthor

    Owner decision (2026-11-03): the proxy rotates under the reaper's ceiling.

    The reaper force-terminates any spawn instance older than REAPER_MAX_AGE. That's 168h live, measured from launch time, and it has no tag exemption by design. So a proxy can't live past it, and the earlier 14-day idle default is withdrawn.

    • Hard max life: a proxy lives for the reaper ceiling minus a margin, about 6 days, derived in code from the same constant pkg/ttl gates on. Its spawn:ttl-deadline is launch time plus max life, so the reaper backstop covers it with no exemption.
    • Idle expiry: configurable, default 3 days, and capped at the max life. spored enforces it, as in feat(spored): egress-proxy mode — allowlisted forward proxy with idle-terminate (#1515 phase 2) #1517. The --idle default changes from 336h.
    • Find-or-create: it replaces a proxy that's within a margin of its max life, so a member's bootstrap never relies on a proxy about to be reaped. The old proxy keeps serving until its own deadline.
    • Patching and upgrades: in-place patching is dropped. Each rotation boots a fresh AL2023 AMI with the current spored, and a version mismatch also triggers replacement.
    • Cost: a relaunch of about 1–2 minutes on the first launch after a rotation.
  8. 30 remaining items

  9. scttfrdmn commented on Nov 5, 2026

    @scttfrdmn
    ContributorAuthor

    Phase 7 merged: #1529 (fd421346). It retires both the AWS CLI mirror and the EFA installer mirror in code. Live results are on #1529.

    Live step 1 is done (2026-11-04): I removed the inline policy AWSCLIMirror from GitHubActions-spore-host-release (966362334030). Before deleting it, I confirmed main's release workflow no longer writes spawn/awscli/; only the origin-verify step remains.

    • Inline policies: AWSCLIMirror, SpawnBinariesS3Upload and spored-signing-kms-sign before; SpawnBinariesS3Upload and spored-signing-kms-sign after. Both remaining policies are byte-identical to the snapshot. Attached policies: none, unchanged.
    • Simulation after removal:
      • s3:PutObject on spawn-binaries-us-east-1/spawn/awscli/*: implicitDeny
      • s3:DeleteObject on spawn/awscli/*: implicitDeny
      • s3:ListBucket with prefix spawn/awscli/: implicitDeny
      • s3:PutObject on spawn/current/spored-linux-arm64: allowed, so the normal release upload is unaffected.
    • Removed document, for the record: {"Version":"2012-10-17","Statement":[{"Sid":"MirrorObjects","Effect":"Allow","Action":["s3:PutObject","s3:DeleteObject"],"Resource":"arn:aws:s3:::spawn-binaries-*/spawn/awscli/*"},{"Sid":"ListMirrorPrefix","Effect":"Allow","Action":"s3:ListBucket","Resource":"arn:aws:s3:::spawn-binaries-*","Condition":{"StringLike":{"s3:prefix":["spawn/awscli/*","spawn/awscli/"]}}}]}

    Still to do, after the next release:

    • Step 2: delete spawn/awscli/ from the 11 spawn-binaries-* buckets. v0.156–v0.158 still try the mirror first.
    • Step 3: CI-deploy the sweep orchestrator, since the bootstrap body changed from 73d1876b… to baa047b3….
  10. modified the milestones: v0.159.0, v0.160.0 on Nov 5, 2026
  11. scttfrdmn commented on Nov 5, 2026

    @scttfrdmn
    ContributorAuthor

    Phase 7 is complete. v0.159.0 is released and deployed (record on #1530). The 22 mirror objects under spawn/awscli/ are deleted from all 11 buckets, and the AWSCLIMirror policy was removed earlier. spawn no longer mirrors any third-party artifact.

    Remaining for #1515 (v0.160.0): sweep and orchestrator support for --bootstrap-egress proxy.

  12. scttfrdmn commented on Nov 5, 2026

    @scttfrdmn
    ContributorAuthor

    Owner decision (2026-11-05): for detached sweeps, the orchestrator can create the proxy.

    • Submit: at --detach submit time, the CLI finds or creates a proxy for each distinct (region, VPC) among the members.
    • Before each launch batch: the sweep orchestrator checks the proxy again with deploy.Evaluate. If the proxy is gone, or won't be reusable (too close to its deadline, or a version mismatch), the orchestrator creates a new one. This is a non-blocking "ensure proxy" phase that spans re-invocations, because the readiness wait doesn't fit in one step.
    • IAM: SpawnSweepCrossAccountRole gains the proxy's actions: RunInstances for the proxy, PassRole on spored-instance-profile, SG create/authorize/revoke, and ssm:SendCommand/GetCommandInvocation for the readiness probe. spawn provisions these, not the user.
    • Testing constraint: the account trust boundary forbids SpawnSweepCrossAccountRole in 942542972736, so detached-sweep proxy support is live-tested in spore-host-dev (435415984226).

    Plan:

    • PR A: foreground sweeps. The CLI finds or creates per (region, VPC), and members get the proxy address and clients SG.
    • PR B: detached sweeps, the orchestrator's ensure phase, and the cross-account role IAM. That includes a real PutRolePolicy on a throwaway role and a code-only deploy.
  13. scttfrdmn commented on Nov 6, 2026

    @scttfrdmn
    ContributorAuthor

    All of #1515 is done and live-verified.

    Follow-ups are tracked separately in v0.161.0: #1520, #1521, #1524, #1528, #1532 and #1535.

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:launcharea:lifecyclearea:networkingcomponent:spawnenhancement

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions