Skip to content

fix: permissions boundary and least-privilege IAM for Lambda scope - #11

Merged
javi-null merged 11 commits into
mainfrom
fix/permissions-boundary
Apr 6, 2026
Merged

fix: permissions boundary and least-privilege IAM for Lambda scope#11
javi-null merged 11 commits into
mainfrom
fix/permissions-boundary

Conversation

@javi-null

@javi-null javi-null commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Move IAM config (use_dedicated_role, role_name_template, role_policies) from NRN to scope-configurations providers
  • Scope IAM permissions: CloudWatch Logs to function's own log group, ECR to same-account repos
  • Set ManagedBy=custom-scope-role tag on all AWS resource creation (required by IAM policy)
  • Pass iam_permissions_boundary from providers to Terraform IAM module
  • Inject ManagedBy into provider default_tags for full coverage
  • Fix VPC subnet/security group data missing in destroy context
  • Skip Secrets Manager cleanup when parameters strategy is env
  • Add fetch_scope_configuration to scope build_context
  • Remove dead scripts: delete_iam_role, rollback_iam_policies and their tests

javi-null and others added 11 commits March 27, 2026 11:18
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>
@javi-null
javi-null merged commit 47e50d0 into main Apr 6, 2026
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.

1 participant