fix: avoid IAM inline policy temp file collision on concurrent scope creation#195
Merged
Merged
Conversation
agustincelentano
approved these changes
Jul 2, 2026
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
k8s/scope/iam/create_rolewrote inline policy documents to a fixed path/tmp/inline-policy-$i.json, keyed only by the policy index. When multiple scopes were created concurrently on the same agent, distinctcreate_roleruns overwrote each other's file between theechoand theaws iam put-role-policycall — sending the wrong policy JSON to IAM.The fix moves the temp file into
$OUTPUT_DIR, the per-command sandbox the agent already provides (and which the script already uses fortrust-policy.json), eliminating the race without PIDs,mktemp, or locks.Changes
k8s/scope/iam/create_role:/tmp/inline-policy-$i.json→$OUTPUT_DIR/inline-policy-$i.jsonk8s/scope/tests/iam/create_role.bats: new regression test asserting the--policy-documentpath is under$OUTPUT_DIRand never/tmpCHANGELOG.md: unreleased entryTest plan
bats tests/iam/create_role.bats— all 14 tests pass (new test [fix]: Parameters VAULT_ADDR and VAULT_TOKEN default values #10 covers the fix)