Repository navigation
feat(launcher): export headless Provision + BuildLinuxBootstrap (lagotto#19 enabler) - #113
Merged
Merged
Conversation
…tto#19) SDK consumers of spawn's launch path (lagotto's capacity-poller Lambda, cohort) previously called the low-level aws.Client.Launch directly. But the spored bootstrap user-data — which installs spored, runs the spawn:command tag, and enforces on-complete/pre-stop/idle/TTL in-instance — was built by buildUserData, unexported in package cmd and wired to CLI flag globals. So those instances launched "naked": no spored, nothing read the tags. (lagotto#19 issues #2/#3.) New pkg/launcher: - BuildLinuxBootstrap(BootstrapConfig): the spored bootstrap as a pure, headless function of (username, public key, plugins, custom user-data). All behavior is tag-driven at boot, so it needs no disk / no platform.Detect / no CLI globals. Verified byte-for-byte identical to the old inline script. - Provision(ctx, client, LaunchConfig, Options): the headless launch minimum — auto-detect AMI when empty, set up the spored IAM profile when empty, build the bootstrap, then Launch. Empty PublicKey is valid (SSM-only / keyless, for the Lambda); the spored role attaches AmazonSSMManagedInstanceCore so the instance is still reachable. cmd/launch.go: buildUserData now delegates to launcher.BuildLinuxBootstrap (it keeps only the CLI-side concerns — on-disk key resolution and --user-data @file reading). No behavior change to `spawn launch`. lagotto will consume launcher.Provision next; this is the spawn-side enabler.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This was referenced Jun 12, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
SDK consumers of spawn's launch path — lagotto's capacity-poller Lambda today, cohort (#108) later — call the low-level
aws.Client.Launchdirectly. But the spored bootstrap user-data (installs spored, runs thespawn:commandtag, enforceson-complete/pre-stop/idle/TTL in-instance) was built bybuildUserData, unexported in packagecmdand wired to CLI flag globals. So those instances launch naked: no spored, nothing reads the tags.That's the root cause behind lagotto#19 issues #2 (Command not executed) and #3 (on_complete/pre_stop ignored) — see the root-cause writeup. (TTL still fires:
Launchtagsspawn:ttl-deadline, so the out-of-band reaper catches these — no cost leak.)What
New
pkg/launcher(exported, headless):BuildLinuxBootstrap(BootstrapConfig)— the spored bootstrap as a pure function of(username, public key, plugins, custom user-data). All runtime behavior is driven by thespawn:*EC2 tagsbuildTagswrites, so it needs no disk, noplatform.Detect, no CLI globals. Verified byte-for-byte identical to the old inline script (diffed the extracted heredoc againstgit HEAD).Provision(ctx, client, LaunchConfig, Options)— the headless launch minimum: auto-detect AMI when empty (lagotto#19 Feature request: --tag / --tags flag for custom EC2 instance tags #1), set up the spored IAM profile when empty, build the bootstrap, thenLaunch. EmptyPublicKeyis valid (SSM-only / keyless — the Lambda has no SSH key on disk); the spored role attachesAmazonSSMManagedInstanceCore, so the instance is still reachable, andspawn connectcan inject a key over SSM later.cmd/launch.go:buildUserDatanow delegates tolauncher.BuildLinuxBootstrap, keeping only the CLI-side concerns (on-disk key resolution,--user-data@filereading). No behavior change tospawn launch.Tests
BuildLinuxBootstrap: username validation, base64 key encoding, keyless/empty-key path, plugin injection, custom-user-data ordering, core-content invariants (installs spored, runs command tag, starts daemon).Provision: missing-field + Windows rejection, caller-AMI preservation, and a full end-to-end against substrate (AMI auto-detect → IAM → Launch).make checkgreen.Next
lagotto's
Spawner.Spawn()will calllauncher.Provisioninstead ofclient.Launch(closes lagotto#19, after a spawn release). Then a follow-up adds SSM key-injection tospawn connectfor these keyless spores.