Skip to content

docs(snapshot): document EBS-direct perms + --iam-policy-file build path (#579) - #583

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/579-snapshot-build-perms-docs
Sep 9, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/579-snapshot-build-perms-docs

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #579.

Problem

spawn snapshot create --help recommends building large snapshots "from AWS CloudShell or a small in-region EC2 instance." The obvious in-region instance is spawn launch, but such an instance runs as the shared spored-instance-role, which is denied at two points:

  1. No read on arbitrary user S3 buckets (s3:ListBucket/s3:GetObject).
  2. ebs:StartSnapshot/PutSnapshotBlock/CompleteSnapshot are not in its policy.

So the documented path can't be satisfied by a spawn launch instance, and that prerequisite was stated nowhere.

What I did — options 1 + 3 (documentation), plus documenting the existing --iam-policy-file path

No new flag, no change to the spored-instance-role baseline.

I verified that --iam-policy-file already provides a working path: cmd/launch_single.go:ensureIAMProfile passes iamPolicyFile into IAMRoleConfig.PolicyFile, and CreateOrGetInstanceProfile (pkg/aws/iam.go) attaches that JSON as an inline policy on a dedicated spawn-instance-<hash> role/profile — not spored-instance-role. So a user can give exactly one instance the EBS-direct + source-bucket perms today. A bespoke --for-snapshot-build flag would be redundant (and a standing IAM-surface change I deliberately avoided), so I documented the existing supported path instead.

Changes:

  • Option 1 + 3 — spawn snapshot create --help (Long) now states the command runs with the caller's credentials (not a spawn-managed instance), lists the required actions (ebs:StartSnapshot/PutSnapshotBlock/CompleteSnapshot + ec2:DescribeSnapshots + source-bucket read), and notes a stock spawn launch instance (spored-instance-role) lacks them.
  • docs/reference-data-volumes.md mirrors the note with a "Credentials the builder needs" subsection and a worked spawn launch --iam-policy-file … example.
  • examples/iam/snapshot-build-policy.json — ready-to-edit scoped policy (three ebs: actions on snapshot/*, ec2:DescribeSnapshots, and source-bucket read with a YOUR-SOURCE-BUCKET placeholder).
  • The required actions were confirmed against the actual build path in pkg/aws/snapshot_build.go (StartSnapshot/PutSnapshotBlock/CompleteSnapshot + DescribeSnapshots waiter; tags ride on StartSnapshot, so no ec2:CreateTags).

Tests

  • New cmd/snapshot_test.go: TestSnapshotBuildPolicyExampleWellFormed asserts the example policy is well-formed JSON and contains the four required actions (fails if the example drifts or breaks).

Checks

  • make check — pass.
  • make gen-docs + make check-docs — regenerated docs-gen/snapshot.md, clean.
  • Stray lambda/autoscale-orchestrator/autoscale-orchestrator binary reverted; no nested lambda go.mod drift (no dependency/lambda code touched).

@codecov

codecov Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…cument --iam-policy-file path (#579)

snapshot create runs with the caller's credentials and needs the EBS-direct
actions (ebs:StartSnapshot/PutSnapshotBlock/CompleteSnapshot + ec2:DescribeSnapshots)
plus source-bucket read. A stock 'spawn launch' instance (spored-instance-role)
has none of these, so the documented in-region build path failed with
AccessDenied and the prerequisite was unstated.

- snapshot create --help (Long) + docs/reference-data-volumes.md now spell out
  the required permissions and that the command uses the caller's creds, not a
  spawn-managed instance.
- Document the existing, supported way to build from a spawn-launched instance:
  pass --iam-policy-file with a scoped policy (no new flag / standing grant).
- Add examples/iam/snapshot-build-policy.json (ready-to-edit) + a JSON-validity
  test guarding it contains the required actions.

Fixes #579
@scttfrdmn
scttfrdmn force-pushed the fix/579-snapshot-build-perms-docs branch from 530f187 to 638c17f Compare September 9, 2026 18:58
@scttfrdmn
scttfrdmn merged commit 1a05a87 into main Sep 9, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/579-snapshot-build-perms-docs branch September 9, 2026 19:10
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.

snapshot create: a spawn launch instance (spored-instance-role) can't build a snapshot — lacks source-bucket S3 read and ebs:StartSnapshot

1 participant