Repository navigation
feat(setup-account): --remove/--offboard, and provision the user lifecycle-lease policy (#1656, #1666) - #1669
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Contributor
Author
|
Owner decision (2026-11-20): IAM verification (dev): a real
The test policy and role were deleted. |
scttfrdmn
marked this pull request as ready for review
November 20, 2026 19:04
…cycle-lease policy (#1656, #1666) spawn setup-account now also creates spore-host/spawn-user-lifecycle, the customer-managed policy granting CLI users the lease actions spawn's creators, doctor and reaper teardown --if-idle-for call on table/spore-host-lifecycle (held to the call graph by an iamcoverage test). Tagged managed-by=spawn and permanent=true, never role=service. spawn setup-account --remove deletes the boundary and the user policy: report mode without --yes; refused while any role or user has the boundary as its permissions boundary (named), and in the infra account; user policy detached, older versions then the policy, boundary last after a re-read. --offboard also deletes spore-portal-onboard (refusing a foreign or CloudFormation-made role). spawn doctor and the mark's diagnostic name the policy. Part of spore-host/spore-host#752.
…, like the boundary (#1666) Owner decision: spore-host/spawn-user-lifecycle is permanent; only spawn setup-account --remove removes it. footprintspawn classes it permanent by ARN or name (IsUserLifecyclePolicy), so an untagged one (tagging refused at create) is kept too; TestUserLifecyclePolicyIsPermanent. Wording everywhere that called the boundary the one permanent piece now says exactly two: the boundary and the user lifecycle policy (help text of setup-account, cleanup, footprint and teardown, docs-gen, CHANGELOG, comments, and the cleanup keep reason, which named #1656 as unimplemented).
scttfrdmn
force-pushed
the
feat/1656-setup-account-remove
branch
from
November 20, 2026 19:05
58fab11 to
2b580bc
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.
Closes #1656. Closes #1666. Part of the leave-no-trace epic, spore-host/spore-host#752 (Phase 3).
spawn setup-accountprovisions the user lease permissions (#1666)spawn setup-accountnow also creates the customer-managed policyspore-host/spawn-user-lifecycle. It grants these actions onarn:aws:dynamodb:*:<account>:table/spore-host-lifecycle, with the account written in rather than a policy variable (#1069):dynamodb:ConditionCheckItem,CreateTable,DeleteItem,DescribeTable,GetItem,PutItem,TagResourceandUpdateItem.How the list is held:
lifecyclemark.UserActions():RequiredActionsplus the newVerdictReadActions(GetItem).TestUserLifecyclePolicyGrantsWhatTheLeaseCallersCall, holds it equal to the DynamoDB actions that three callers reach in the call graph:lifecyclemark.Mark,lifecyclemark.Probe(spawn doctor) and(*lifecycle.Client).Get(reaper teardown --if-idle-for).GetItemforScanfails the test.Tags and lifecycle:
spore-host:managed-by=spawn,spore-host:permanent=trueandspore-host:component=user-lifecycle. It is never taggedspore-host:role=service.permanent, so no idle teardown deletes it. Its name also matches no teardown pattern.aws iam attach-group-policy ... --policy-arn <arn>.The
spawn doctor"idle teardown" warning and the mark's diagnostic line now name the policy and its ARN. They no longer say spore.host doesn't provision it.Owner decision (confirmed):
spore-host/spawn-user-lifecycleis permanent account setup, like the boundary. It keeps thepermanent=truetag, and--removeis the only way it goes.footprintspawn.Classifyalso classes itpermanentby ARN or name (IsUserLifecyclePolicy, mirroringfootprint.IsBoundary), so a copy created untagged, when tagging was refused, is kept too.TestUserLifecyclePolicyIsPermanentcovers this: disabling the rule fails 3 of its cases. Help text, docs-gen, the CHANGELOG and comments that called the boundary "the one permanent piece" now name exactly two pieces: the boundary and the user lifecycle policy. Thecleanup --instance-roleskeep reason also no longer says #1656 is unimplemented.spawn setup-account --remove(#1656)--yes,--removeonly prints the numbered plan.spore-host/spawn-instance-boundaryas its permissions boundary (ListEntitiesForPolicy,PolicyUsageFilter=PermissionsBoundary). The refusal names each role or user;DeletePolicy.--offboard, the onboard role.DeletePolicy.--offboard(only valid with--remove) also deletesspore-portal-onboard: its inline policies, then its managed attachments, then the role.Purpose=spore-portal-onboard.aws:cloudformation:stack-name(the quick-create), naming the stack to delete.--yesand--offboardwithout--removeare usage errors.The new IAM actions are in
cli-iam-actions.md:iam:ListEntitiesForPolicy,DeletePolicy,DetachGroupPolicy,DetachUserPolicy,DetachRolePolicy,ListRolePolicies,ListAttachedRolePolicies,DeleteRolePolicy,DeleteRoleandTagPolicy.Tests (hermetic: no AWS)
pkg/testutil.IAMAccountis a new in-memory IAM account. It enforces that IAM refuses to delete a policy that is attached or has versions, refuses to delete a role that still has policies, and caps versions at five. It deliberately does not refuse to delete a policy that is in use as a boundary, so only spawn's guard can.pkg/aws/iam_account_setup_test.gocovers:${in it;--offboard's order;cmd/setup_account_test.gocovers create plus re-run, the infra account, access denied, report mode,--yes,--offboard, the in-use refusal, the infra refusal and the flag errors. There are also tests inpkg/doctorandpkg/lifecyclemark.Revert check: two mutations that compile, run separately:
ExecuteAccountRemoval's re-check failsTestRemoveRechecksTheBoundaryBeforeDeletingIt;TestRemoveRefusesWhileTheBoundaryIsInUse.Gates
make check, run from a space-free copy at/private/tmp: all checks passed.make gen-docs,make cli-iam-actionsandmake api-snapshotwere run and committed. The API snapshot has additions only, inpkg/aws.setup-accountwas updated intest/e2e/tier0_coverage_test.go.semgrep scan --config=auto --erroron the changed files: 0 findings.Not done here: a real
CreatePolicy/PutRolePolicy/ simulation of the user policy document. No AWS was touched in this work.Companion docs: spore-host/spore-host (principle page and
iam-permissions.md), spore-host/lagotto#339.