Repository navigation
fix: launch attaches an instance profile with no access to the workload's bucket (#550) - #559
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…ad's bucket (#550) spawn has two independent IAM instance-profile resolution paths that a given `spawn launch` invocation lands on based solely on whether it passed any IAM configuration: CreateOrGetInstanceProfile (scoped to what was asked for) when any --iam-role/--iam-policy/--iam-policy-file flag (or a task/pool-worker's built-in policy) is present, or SetupSporedIAMRole (a fixed shared spored-instance-profile with no data-bucket access) when none is. Two outwardly identical launches can therefore silently diverge, and the wrong one 403s on its first S3 call minutes into a paid run. This documents the mechanism at both call sites in pkg/aws/iam.go, adds `--instance-profile NAME` to bypass all resolution (single-instance, sweep, and batch-queue launch paths), and surfaces the resolved profile in `spawn launch`'s own output and `spawn task diagnose` (list/status already showed it). A full launch-time bucket-reachability preflight (the issue's #1 suggestion) is not included: outside `spawn task run` (which already scopes its own profile from TaskSpec Inputs/Outputs), spawn has no signal today for which bucket a plain `spawn launch` invocation's workload needs, so there is nothing to preflight against without inventing new required input this fix intentionally does not add.
scttfrdmn
force-pushed
the
fix/550-iam-profile-bucket-access
branch
from
September 2, 2026 23:26
7f08f8e to
a9cf129
Compare
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.
Summary
Fixes #550.
spawn launchhas two independent IAM instance-profile resolution paths, and which one a given invocation lands on is decided entirely by whether that call passed any IAM configuration — not by any property of the workload or account:--iam-role/--iam-policy/--iam-policy-file, orspawn task run's built-in scoped S3 policy, or a pool worker's SQS+S3 policy) callCreateOrGetInstanceProfile, which creates/reuses a profile scoped to exactly what was asked for.spawn launch,spawn resume, a batch queue with no--iam-role, a sweep row with noiam_role:) callSetupSporedIAMRole, which always returns the same fixed sharedspored-instance-profile— no data-bucket access beyond whatever was separately attached to that exact role name.Two outwardly-identical
spawn launchinvocations can therefore silently diverge, and the one that lands on the shared profile 403s on its first S3 call minutes into a paid run, deep inside a detached provisioning script — reading as a missing object rather than a missing permission.What's in this PR (issue's suggested fixes, in order)
spawn task run(which already knows its buckets fromTaskSpec.Inputs/Outputs/S3ReadWriteand already scopes its own profile correctly), spawn has no signal today for which bucket a plainspawn launchinvocation's workload needs. There's no existing--s3/bucket flag to preflight against, and inventing one as a side effect of this fix would be exactly the kind of scope creep the issue asks to avoid. Not implemented in this pass — flagged here as a narrower follow-up if it's wanted (it would need its own flag design).--instance-profile NAMEattaches an existing profile verbatim, bypassing all--iam-role/--iam-policy/--iam-policy-fileresolution and thespored-instance-profiledefault — wired into the single-instance, sweep, and batch-queue launch paths.spawn launch's own output (TUI success box +-o json) now prints the resolvediam_instance_profile— previously invisible anywhere exceptec2:DescribeInstances.spawn task diagnosealso gained anIAM profile:line (spawn list/spawn statusalready showed it).pkg/aws/iam.gonow states the exact mechanism (which callers hit which function, and why) directly onCreateOrGetInstanceProfileandSetupSporedIAMRole, plus a CHANGELOG entry.spawn-instance-<hash>profiles — noted, not implemented. A comment ongenerateRoleNamedocuments that these are a deliberate safe-reuse default, not an oversight, and that garbage-collecting them is a different (IAM-deletion) risk class deserving its own issue — per the task's explicit instruction not to implement GC here.Test plan
test/e2e/tier0_iam_profile_test.go), run against Substrate:TestTier0_IAMProfileResolution_ConsistentAcrossIdenticalLaunches— two bare launches with no IAM flags resolve to the same profile.TestTier0_IAMProfileResolution_SameIAMFlagsConsistent— two launches with the same--iam-policy-file(fresh emulator accounts) resolve to the same profile name.TestTier0_InstanceProfileFlag_AttachesVerbatim—--instance-profileattaches the named profile with no resolution.TestTier0_InstanceProfileFlag_BeatsIAMRoleFlags—--instance-profilewins over--iam-rolewhen both are given.git stash), confirmed the two--instance-profiletests fail withunknown flag: --instance-profile; restored the fix, all 4 pass.TestTier0_Sweep*,TestTier0_IAM*) still green — 30/30 tests pass.go test -tags e2e_tier0 ./test/e2e/...).make checkclean (fmt, vet, staticcheck warnings pre-existing/unrelated, short tests).make gen-docs/make check-docs—docs-gen/launch.mdregenerated and committed with the new flag.lambda/*/) all build cleanly with nogo.moddrift.CHANGELOG.md## [Unreleased]updated with### Added/### Fixedentries referencing launch attaches an instance profile with no access to the workload's bucket, and the failure surfaces minutes later as a 403 on a paid instance #550.🤖 Generated with Claude Code