Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
- Add support to get AWS credentials via assume role
- Add support to auto-create ALBs on scope create
- Fix race condition on IAM role creation when multiple scopes are created concurrently

## [1.12.0] - 2026-06-08
- Fix: do not inject file parameter as env vars
Expand Down
2 changes: 1 addition & 1 deletion k8s/scope/iam/create_role
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ for ((i=0; i<$POLICIES_COUNT; i++)); do
POLICY_NAME="inline-policy-$((i+1))"
log debug "📝 Attaching inline policy: $POLICY_NAME"

TEMP_POLICY_FILE="/tmp/inline-policy-$i.json"
TEMP_POLICY_FILE="$OUTPUT_DIR/inline-policy-$i.json"
echo "$POLICY_VALUE" > "$TEMP_POLICY_FILE"

aws iam put-role-policy \
Expand Down
52 changes: 52 additions & 0 deletions k8s/scope/tests/iam/create_role.bats
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,58 @@ teardown() {
assert_contains "$output" "✅ Successfully attached inline policy: inline-policy-1"
}

# =============================================================================
# Test: Inline policy document is written under OUTPUT_DIR, not /tmp
# (regression: shared /tmp path collided across concurrent create_role runs)
# =============================================================================
@test "create_role: inline policy document is written under OUTPUT_DIR" {
export IAM='{
"ENABLED": "true",
"PREFIX": "test-prefix",
"ROLE": {
"BOUNDARY_ARN": null,
"POLICIES": [
{"TYPE": "inline", "VALUE": "{\"Version\":\"2012-10-17\",\"Statement\":[]}"}
]
}
}'

aws() {
case "$*" in
*"eks describe-cluster"*)
echo "https://oidc.eks.us-east-1.amazonaws.com/id/ABCDEF1234567890"
;;
*"sts get-caller-identity"*)
echo "123456789012"
;;
*"iam create-role"*)
echo '{"Role": {"Arn": "arn:aws:iam::123456789012:role/test-prefix-test-scope-123"}}'
;;
*"iam put-role-policy"*)
# Emit the args so the test can assert on the --policy-document path
echo "PUT_ROLE_POLICY_ARGS: $*"
;;
*)
return 0
;;
esac
}
export -f aws

run bash -c 'source "$SCRIPT"'

assert_equal "$status" "0"
assert_contains "$output" "--policy-document file://$OUTPUT_DIR/inline-policy-0.json"

# Guard against the shared /tmp path regression
if echo "$output" | grep -q "file:///tmp/inline-policy"; then
uses_tmp="true"
else
uses_tmp="false"
fi
assert_false "$uses_tmp" "inline policy document under /tmp"
}

# =============================================================================
# Test: Unknown policy type shows warning
# =============================================================================
Expand Down
Loading