fix: permissions boundary and least-privilege IAM for Lambda scope - #11
Merged
Conversation
Introduces iam_permissions_boundary variable so the np-agent can attach a permissions boundary when creating the Lambda execution role, preventing privilege escalation at runtime. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…and remove dead scripts Read use_dedicated_role, role_name_template, role_policies, and dedicated role ARN/name from the scope-configurations provider instead of NRN. Remove rollback_iam_policies and delete_iam_role (both unused in workflows, lifecycle managed by Terraform). Simplify networking_healthy diagnose check to use Lambda resource-based policy instead of NRN-stored API Gateway ID. Drop stale NRN references from rollback_alias error messages and create_iam_role NRN write. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…build_context Source fetch_scope_configuration so scope-level workflows have access to provider data (AWS account, region, VPC, scope-configurations). Replace raw echo calls with log info/debug for consistency with the rest of the codebase. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
IAM policy requires this tag on every Create* API call or the action is denied. Update all Terraform module locals and the create_iam_role CLI call to use ManagedBy=custom-scope-role instead of ManagedBy=terraform. Align test assertions accordingly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
build_destroy_context was initializing TOFU_VARIABLES as empty JSON without VPC data. setup_compute reads subnet_ids and security_group_ids from TOFU_VARIABLES, so scope deletion failed when vpc_enabled=true. Convert the comma-separated env vars from fetch_scope_configuration into JSON arrays so the destroy path matches the create path. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
delete_sm_secret was calling aws secretsmanager list-secrets on every scope deletion regardless of the parameters strategy. Guard with a PARAMETERS_STRATEGY check so AWS calls are only made when the scope actually uses secretsmanager for parameters. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add scripts to accelerate least-privilege iteration: - sync-role-policies.sh: copies policies between roles across accounts - add-permission.sh: adds missing permissions to sandbox role and logs them for the production change request - permissions-log.md: tracks permissions discovered during iteration Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
ManagedBy=custom-scope-roletag on all AWS resource creation (required by IAM policy)iam_permissions_boundaryfrom providers to Terraform IAM moduleManagedByinto providerdefault_tagsfor full coverageenvfetch_scope_configurationto scope build_contextdelete_iam_role,rollback_iam_policiesand their tests