From 2861e9adf335d22954faad63e34d0b1dbf3aa6f3 Mon Sep 17 00:00:00 2001 From: Rubab Khan Date: Sat, 7 Nov 2026 22:37:41 -0800 Subject: [PATCH] ## Summary MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This branch carries four workstreams: 1. **Security remediation.** Every finding from an automated security code review was verified against the code. The confirmed ones are fixed, each with tests. 2. **Eval results UI.** Sweeps started from the UI now show the same cross-arm, per-tier summary tables as `results/matrix.md`, and the page offers a `matrix.md` download. 3. **Dependency upgrades.** This includes `mcp` / `mcp-types` 2.3.0, which was previously blocked by `strands-agents`. 4. **Documentation.** There is a new `docs/agent-architecture.md` with three figures. The existing architecture figures are realigned with the deployed infrastructure. ## Security remediation ### Gateway and identity - The Gateway REQUEST interceptor fails closed on malformed or unparseable bodies. - The interceptor keeps the detail of configuration errors, and it no longer caches an empty allowlist. - The SPA client allowlist is enforced on the API channel. It is read from an SSM parameter and wired only to the routed tools. - `principal_type` is forwarded on the agent channel. ### Pagination - Cursors are now opaque and bound to the caller. They are encrypted with a dedicated KMS key under an encryption context naming the caller's tenant, the rep and the issuing operation. - A cursor that is malformed, tampered with, or presented by another caller or to another operation is rejected as a validation error. - A KMS refusal returns a 5xx and is no longer misreported as an auth or validation failure. - Paging resumes after the last row returned. - Search metadata is filtered by the caller's scope, and listing-scope checks are enforced. ### Writes and proposals - `update_*` writes are conditional. A lost race reports `fields_changed`, and `log_activity` now does the same. - Approve and rebase re-check: - the primary-contact reference; - cascades; - the stage machine. - Revert re-checks stage moves. - Revert refuses to restore a primary contact that is dangling or no longer referenced. - Store transport errors map to `ServiceBusy`. Stalled batch reads back off. - Handler denials are logged. ### Agents and runtime - Runtime session events are bounded. - `pipeline_aggregate` is bounded. - Free-text fields and chat prompts have length caps. - The vendor SDK transport and its loggers are locked down. The logger lock-down now lives in a stdlib-only module, which keeps `httpx2` and `pyyaml` out of the Lambda zip import closures. ### Browser and session - CloudFront enforces a Content-Security-Policy. A shared CSP-violation trap is added to the browser journeys. - Sign-out revokes the refresh token and resets the user's settings. A settings save that lands after sign-out is discarded. - Reading an eval run requires full visibility. ### Infrastructure (Terraform) - A pagination-cursor CMK, with grants to the paginating action Lambdas. - An SSM parameter for the API client allowlist. - A CloudFront response-headers policy carrying the CSP. - New grant rows in the action-role matrix, including an index-only `Query` for `approve_proposal`. ### Not changed, by decision - No finding was addressed by requiring MFA. MFA stays optional. - One finding was reviewed and declined as not warranting a behaviour change. ## Eval results UI - `TierComparisonSummary` shows the cross-arm tier comparison tables from the backend matrix renderer. Inline code spans render as `` elements; no raw HTML is injected. The stored tier-comparison input is validated before rendering. - The **Download matrix.md** button serves the same rendered markdown as the CLI artifact. - New browser journey `21-tier-comparison`. Journey 08 is updated for the download control. ## Dependency upgrades | Area | Changes | |---|---| | Python | `mcp` / `mcp-types` 2.1.1 → 2.3.0, `strands-agents` 1.62.0 → 1.64.0, `boto3`/`botocore` 1.43.121 → 1.43.125, `anthropic` 2.3.0 → 2.6.0, `openai` 3.41.0 → 3.46.0, `ruff` 0.17.3 → 0.17.4, `types-PyYAML` | | Frontend | `vite` 8.3.6, `tailwindcss` / `@tailwindcss/postcss` 4.3.5, `@vitejs/plugin-react` 6.2.1, `vitest` / `@vitest/coverage-v8` 5.1.0, `eslint` 10.14.0, `jsdom` 31.0.0, `globals` 17.14.0 | | Relay | `@aws-sdk/client-bedrock-agentcore` / `client-ssm` 3.1163.0, `vitest` 5.1.0 | | Browser journeys | `@playwright/test` 1.65.0 | - `requirements.txt` and every npm lockfile are regenerated alongside these. - `mcp` 2.3.0 omits the empty `_meta` object from `tools/call` requests that 2.2.0 and earlier sent. The MCP compatibility test's recorded request shape is updated to match. - The plan fixtures are regenerated. - The `iam_roles` and `lambda_actions` smoke expectations are updated for the new grant rows. ## Smoke, scripts and runbook - **IAM simulation of KMS key policies.** These policies use `Resource: "*"`, so the smoke harness substitutes the key ARN before simulating them. - **Gateway array-body check.** The Gateway itself answers a JSON-RPC array body with a tool error (`isError: true`), without invoking the interceptor or any target. The smoke row now passes on a JSON-RPC error or `isError: true`. It fails on any tool output without `isError`. - **MCP secret rotation.** `rotate_mcp_client_secret.py` rolls back a newly added secret whose add response cannot be read. It deletes every secret except the old one and writes no file. - **Canary gate, demo seeder and smoke harness.** All three treat `ServiceBusy` wrapping a connection error as unreachable. - **Runbook additions:** - resetting a lost MCP client secret through Cognito; - the command for the remote canary-tenant emptiness check. ## Documentation - `docs/agent-architecture.md` covers: - the AgentCore deployment; - the supervisor → subagents → tools workflow; - a single chat turn, with a figure for each of these. - The architecture figures are cross-checked against the deployed stack and updated: - the deployment figure shows both interceptors; - the network figure shows the cursor and state-backend CMKs, and the CSP; - the user-plane figure shows the allowlist SSM parameter; - the test ladder shows the `make verify` targets. - `docs/security-baseline.md` adds: - the allowlist parameter; - refresh-token revocation; - the length caps; - the eval-read visibility rule; - the KMS row for the cursor key. - `README.md` and `docs/development.md` are refreshed to match. ## Testing - `make verify` (lint, format, type-check, unit, stub, integration, gates, shellcheck): green. The unit suite is 15,790 passed. - Local reproduction of the GitLab and GitHub CI jobs, plus a fresh-clone run: green. GitLab CI on the pushed branch: passed. - Against a deployed dev stack: - the full post-deploy verification (Layers 4–6) had 0 failures, with only previously documented deferrals; - all browser journeys 01–21 passed; - the MCP client probe passed on `mcp` 2.3.0; - the canary tenant was confirmed empty. - No live model sweep was run. Eval changes were exercised with the stub sweep. ## Upgrade notes - Run `terraform apply`, which creates the cursor KMS key, the allowlist SSM parameter and the CSP headers policy. - Pagination cursors issued before the upgrade are not accepted. Clients should restart the listing. --- README.md | 14 +- docs/agent-architecture.md | 144 +++ docs/development.md | 2 +- docs/eval-methodology.md | 4 +- docs/figures/README.md | 2 +- .../agent-architecture-chat-turn.drawio | 43 + docs/figures/agent-architecture-chat-turn.svg | 3 + .../agent-architecture-deployment.drawio | 41 + .../figures/agent-architecture-deployment.svg | 3 + .../agent-architecture-workflow.drawio | 39 + docs/figures/agent-architecture-workflow.svg | 3 + docs/figures/development-test-ladder.drawio | 2 +- docs/figures/development-test-ladder.svg | 2 +- docs/figures/readme-aws-user-plane.drawio | 6 +- docs/figures/readme-aws-user-plane.svg | 2 +- .../security-baseline-aws-network.drawio | 4 +- .../figures/security-baseline-aws-network.svg | 2 +- docs/runbook.md | 63 +- docs/security-baseline.md | 47 +- frontend/package-lock.json | 1116 +++++------------ frontend/package.json | 18 +- frontend/src/auth/AuthProvider.test.tsx | 248 ++++ frontend/src/auth/AuthProvider.tsx | 2 + frontend/src/auth/CognitoAuthSession.test.ts | 150 +++ frontend/src/auth/CognitoAuthSession.ts | 18 +- .../src/components/tuning/sessionTuning.ts | 60 +- frontend/src/hooks/usePageContext.ts | 2 +- frontend/src/pages/evals/EvalArtifactList.tsx | 34 +- .../src/pages/evals/EvalDashboardPage.tsx | 2 + frontend/src/pages/evals/EvalRunClient.ts | 69 +- frontend/src/pages/evals/README.md | 8 +- .../evals/TierComparisonSummary.test.tsx | 273 ++++ .../src/pages/evals/TierComparisonSummary.tsx | 132 ++ .../evals/__fixtures__/tierComparison.json | 489 ++++++++ .../src/pages/evals/evals.artefacts.test.tsx | 94 +- frontend/src/pages/evals/evals.test.tsx | 2 +- frontend/src/pages/evals/types.ts | 23 + frontend/src/test/responseShapes.test.ts | 5 +- infra/main.tf | 189 ++- infra/modules/frontend_cdn/README.md | 27 +- infra/modules/frontend_cdn/cloudfront.tf | 65 +- infra/modules/frontend_cdn/variables.tf | 20 + infra/modules/lambda_action/README.md | 12 +- infra/modules/lambda_action/main.tf | 42 +- .../table_action_role_matrix.json | 3 +- infra/modules/lambda_action/variables.tf | 39 + infra/user_settings.tf | 4 +- pyproject.toml | 16 +- requirements.txt | 48 +- scripts/check_canary_tenant_empty.py | 30 +- scripts/check_handler_grant_coverage.py | 132 +- scripts/check_lambda_adapter_isolation.py | 9 +- scripts/check_plan_security_baseline.py | 251 +++- scripts/check_toolspec_parity.py | 2 +- scripts/plan_fixtures.py | 2 +- scripts/rotate_mcp_client_secret.py | 52 +- scripts/seed_demo_tenant.py | 30 +- scripts/smoke/api_routes.py | 443 ++++++- scripts/smoke/cloudfront.py | 371 +++++- scripts/smoke/cognito_claims.py | 110 +- scripts/smoke/eval_sfn.py | 138 +- scripts/smoke/gateway_tools.py | 192 ++- scripts/smoke/harness.py | 35 +- scripts/smoke/iam_roles.py | 233 +++- scripts/smoke/lambda_actions.py | 785 +++++++++++- scripts/smoke/store_principal_deny.py | 227 +++- src/agents/runtime_entrypoint.py | 122 +- src/agents/runtime_server.py | 7 +- src/agents/tool_dispatch.py | 6 +- src/crm/audit.py | 71 +- src/crm/cursor.py | 289 +++++ src/crm/domain/allowlists.py | 23 +- src/crm/domain/references.py | 57 + src/crm/envelope.py | 107 +- src/crm/errors.py | 6 + src/crm/handlers/_common.py | 26 +- src/crm/handlers/approve_proposal.py | 41 + src/crm/handlers/cascade_rules.py | 3 +- src/crm/handlers/create_opportunity.py | 13 +- src/crm/handlers/eval_trigger.py | 52 +- src/crm/handlers/list_activities.py | 17 +- src/crm/handlers/list_audit_records.py | 26 +- src/crm/handlers/list_proposals.py | 24 +- src/crm/handlers/log_activity.py | 52 +- src/crm/handlers/pipeline_aggregate.py | 42 +- src/crm/handlers/submit_proposal.py | 18 +- src/crm/handlers/update_account.py | 27 +- src/crm/handlers/update_activity.py | 27 +- src/crm/handlers/update_contact.py | 27 +- src/crm/handlers/update_opportunity.py | 27 +- src/crm/handlers/wire.py | 83 +- src/crm/proposals.py | 32 +- src/crm/search.py | 155 +-- src/crm/store/store.py | 74 +- src/crm/toolspec/definitions.py | 51 +- src/crm/toolspec/page_context.py | 4 +- src/eval/artefacts.py | 24 +- src/eval/matrix.py | 92 +- src/eval/runs.py | 64 +- src/gateway/identity_interceptor.py | 48 +- src/providers/sdk_loggers.py | 35 + src/providers/sdk_transport.py | 34 +- src/relay/package-lock.json | 406 +++--- src/relay/package.json | 6 +- src/relay/src/index.ts | 16 +- src/relay/src/requests.ts | 34 + src/relay/tests/index.test.ts | 42 + src/relay/tests/requests.test.ts | 73 ++ tests/conftest.py | 63 + tests/e2e/browser/fixtures/auth.ts | 21 +- tests/e2e/browser/fixtures/cspTrap.ts | 48 + tests/e2e/browser/journeys/01-signin.spec.ts | 11 +- .../journeys/08-eval-dashboard.spec.ts | 39 +- .../tier-comparison.spec.ts | 458 +++++++ tests/e2e/browser/journeys/README.md | 1 + tests/e2e/browser/package-lock.json | 24 +- tests/e2e/browser/package.json | 2 +- tests/fixtures/plans/compliant.base.ndjson | 157 +-- tests/integration/test_approval_regression.py | 61 +- tests/integration/test_listing_scope_ddb.py | 8 +- tests/integration/test_openai_multiround.py | 12 +- tests/integration/test_prompt_cap_contract.py | 188 +++ .../test_search_scope_metadata_ddb.py | 295 +++++ .../test_tier_comparison_ui_contract.py | 254 ++++ .../test_update_conditional_ddb.py | 244 ++++ tests/integration/test_user_settings_store.py | 8 +- tests/unit/test_audit.py | 184 +++ tests/unit/test_check_canary_tenant_empty.py | 118 +- .../unit/test_check_handler_grant_coverage.py | 99 ++ tests/unit/test_cursor.py | 772 ++++++++++++ tests/unit/test_e2e_browser_scaffold.py | 88 +- tests/unit/test_envelope.py | 313 ++++- tests/unit/test_envelope_groups.py | 12 +- tests/unit/test_eval_artefacts.py | 190 +++ tests/unit/test_eval_trigger.py | 135 +- tests/unit/test_eval_trigger_authz.py | 125 +- tests/unit/test_eval_trigger_repeats.py | 8 +- tests/unit/test_field_length_caps.py | 271 ++++ tests/unit/test_handler_error_logging.py | 240 ++++ tests/unit/test_handlers_apigw_proxy.py | 48 + tests/unit/test_identity_interceptor.py | 103 ++ tests/unit/test_infra_api.py | 146 ++- tests/unit/test_infra_cdn.py | 21 +- tests/unit/test_infra_csp.py | 373 ++++++ tests/unit/test_infra_cursor_key.py | 699 +++++++++++ tests/unit/test_infra_eval_sfn.py | 6 +- tests/unit/test_infra_inline_policy_budget.py | 2 + tests/unit/test_infra_user_settings.py | 9 + tests/unit/test_lambda_env_contract.py | 18 +- tests/unit/test_listing_scope.py | 55 +- tests/unit/test_matrix_tier_comparison.py | 163 ++- tests/unit/test_pipeline_aggregate_budget.py | 175 +++ tests/unit/test_plan_fixtures.py | 8 +- tests/unit/test_plan_security_baseline.py | 61 +- tests/unit/test_proposal_decision_channel.py | 4 +- tests/unit/test_proposal_integrity.py | 446 +++++++ tests/unit/test_proposal_payload_allowlist.py | 5 +- tests/unit/test_rotate_mcp_client_secret.py | 114 ++ tests/unit/test_runs_lock.py | 16 +- tests/unit/test_runtime_entrypoint.py | 227 +++- tests/unit/test_runtime_server.py | 11 +- tests/unit/test_scan_residue_coverage.py | 8 + tests/unit/test_sdk_transport.py | 226 +++- tests/unit/test_search_accounts.py | 29 + tests/unit/test_search_ceiling.py | 254 +++- tests/unit/test_smoke_api_routes.py | 514 +++++++- tests/unit/test_smoke_cloudfront.py | 423 ++++++- tests/unit/test_smoke_cognito_claims.py | 171 ++- tests/unit/test_smoke_eval_sfn.py | 193 ++- tests/unit/test_smoke_gateway_tools.py | 190 ++- tests/unit/test_smoke_harness.py | 21 + tests/unit/test_smoke_iam_roles.py | 320 ++++- tests/unit/test_smoke_lambda_actions.py | 599 ++++++++- tests/unit/test_smoke_mcp_client_compat.py | 5 +- tests/unit/test_smoke_store_principal_deny.py | 223 +++- tests/unit/test_store_transport_errors.py | 258 ++++ tests/unit/test_tool_actor.py | 29 +- tests/unit/test_update_conditional.py | 382 ++++++ 178 files changed, 18317 insertions(+), 1748 deletions(-) create mode 100644 docs/agent-architecture.md create mode 100644 docs/figures/agent-architecture-chat-turn.drawio create mode 100644 docs/figures/agent-architecture-chat-turn.svg create mode 100644 docs/figures/agent-architecture-deployment.drawio create mode 100644 docs/figures/agent-architecture-deployment.svg create mode 100644 docs/figures/agent-architecture-workflow.drawio create mode 100644 docs/figures/agent-architecture-workflow.svg create mode 100644 frontend/src/auth/AuthProvider.test.tsx create mode 100644 frontend/src/auth/CognitoAuthSession.test.ts create mode 100644 frontend/src/pages/evals/TierComparisonSummary.test.tsx create mode 100644 frontend/src/pages/evals/TierComparisonSummary.tsx create mode 100644 frontend/src/pages/evals/__fixtures__/tierComparison.json create mode 100644 src/crm/cursor.py create mode 100644 src/crm/domain/references.py create mode 100644 src/providers/sdk_loggers.py create mode 100644 src/relay/tests/requests.test.ts create mode 100644 tests/conftest.py create mode 100644 tests/e2e/browser/fixtures/cspTrap.ts create mode 100644 tests/e2e/browser/journeys/21-tier-comparison/tier-comparison.spec.ts create mode 100644 tests/integration/test_prompt_cap_contract.py create mode 100644 tests/integration/test_search_scope_metadata_ddb.py create mode 100644 tests/integration/test_tier_comparison_ui_contract.py create mode 100644 tests/integration/test_update_conditional_ddb.py create mode 100644 tests/unit/test_cursor.py create mode 100644 tests/unit/test_field_length_caps.py create mode 100644 tests/unit/test_handler_error_logging.py create mode 100644 tests/unit/test_infra_csp.py create mode 100644 tests/unit/test_infra_cursor_key.py create mode 100644 tests/unit/test_pipeline_aggregate_budget.py create mode 100644 tests/unit/test_proposal_integrity.py create mode 100644 tests/unit/test_store_transport_errors.py create mode 100644 tests/unit/test_update_conditional.py diff --git a/README.md b/README.md index 6ae528d..6465b92 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ This is a demo and a research instrument, not a production CRM. ![Concept overview: the React SPA (served from S3 via CloudFront), external MCP clients and the in-app Strands agents reach one enforcement boundary in the CRM action Lambdas through the apigw, gateway and agent identity channels; decode_identity, the input validator, authz and store.py lead to tenant-partitioned DynamoDB; the toolspec generates the validator, the MCP tool definitions and the agent tool registry; the eval run_sweep drives agent turns and writes results](docs/figures/readme-concept-overview.svg) -![AWS user plane: the browser runs the React SPA it downloads through CloudFront. CloudFront's default behaviour serves the built SPA's static files from a private S3 bucket (OAC, SSE-KMS), which is where the UI is hosted; CloudFront also sends /api/* through a VPC origin, internal ALB and execute-api endpoint to the private REST API and the CRM action Lambdas on DynamoDB, and sends /agent/* to the relay Lambda, the AgentCore Runtime and Amazon Bedrock; Cognito signs users in](docs/figures/readme-aws-user-plane.svg) +![AWS user plane: the browser runs the React SPA it downloads through CloudFront. CloudFront's default behaviour serves the built SPA's static files from a private S3 bucket (OAC, SSE-KMS), which is where the UI is hosted; CloudFront also sends /api/* through a VPC origin, internal ALB and execute-api endpoint to the private REST API and the CRM action Lambdas on DynamoDB, which read their API client allowlist from Parameter Store, and sends /agent/* to the relay Lambda, the AgentCore Runtime and Amazon Bedrock; every behaviour carries an enforced security-headers and CSP policy; Cognito signs users in](docs/figures/readme-aws-user-plane.svg) ![AWS agent plane: MCP clients get a Cognito token and call two AgentCore Gateways; the CRM tools Gateway runs an identity interceptor and invokes one action Lambda per tool, the chat Gateway runs its own interceptor and invokes chat_with_supervisor, which calls the AgentCore Runtime; the Runtime invokes the action Lambdas and Bedrock models and pulls its image from ECR, built by CodeBuild; eval_trigger starts the eval_sweep state machine, whose sweep_task sends eval turns to the Runtime and whose sweep_control writes artefacts to S3](docs/figures/readme-aws-agent-plane.svg) @@ -45,14 +45,17 @@ This is a demo and a research instrument, not a production CRM. - **Agents.** `src/agents/supervisor.py` handles each chat turn with direct read tools and four subagents: research, mutation, analytics and composer. High-risk changes go through a proposal that a user approves or rejects. No tool lets an agent commit one directly. + `docs/agent-architecture.md` describes the deployment, the agent workflow and one chat turn. - **Relay.** `src/relay/` is a small Node.js Lambda. It verifies the Cognito token, calls the AgentCore Runtime with SigV4 and streams its server-sent events back unchanged. - **Models.** Every model call goes through Amazon Bedrock, signed with IAM credentials. The project reads and accepts no vendor or Bedrock API key. - **Tenants.** Data is partitioned by tenant, and every index partition key includes the tenant. - **Hardening.** Every Lambda and the API stage run active X-Ray tracing. Every CloudFront behaviour - carries the AWS-managed security-headers policy (HSTS, `X-Content-Type-Options`, `X-Frame-Options`, - `Referrer-Policy`, `X-XSS-Protection`). Every versioned bucket under `infra/` expires noncurrent + carries the module's security-headers policy (HSTS, `X-Content-Type-Options`, `X-Frame-Options`, + `Referrer-Policy`, `X-XSS-Protection`) with an enforced `Content-Security-Policy`. The CSP allows + scripts only from the site itself plus the inline theme script, by hash, and allows connections + only to the site and Cognito. Every versioned bucket under `infra/` expires noncurrent versions (the state-backend buckets that `infra/bootstrap_state_backend.sh` creates have no lifecycle rule), and the CloudTrail buckets have ACLs disabled. The smoke checks send their HTTP requests through one opener that refuses any URL scheme but `https`; the JWKS fetch in @@ -391,7 +394,8 @@ completion, task completion over repeats (a task counts when it passed in a stri repeats), accuracy, cost and latency per completed task, invocations, tokens and self-corrected retries at that tier. It is measurement only: columns are not sorted by any result, and no difference or ratio between them is computed. `matrix.json` (`tier_comparison`) and `matrix.csv` -(`summary_*` columns) carry the same figures. `docs/eval-methodology.md` defines every row. +(`summary_*` columns) carry the same figures. `docs/eval-methodology.md` defines every row. The +eval dashboard's results page shows the same tables and offers the run's `matrix.md` as a download. Every model family is sent the same prompts: `config/agent_prompts/` (supervisor and subagent) and `config/answer_style.yaml`. Each arm's provenance records `prompt_bundle_sha256`, a digest over the @@ -535,6 +539,8 @@ docs/ guides **Develop** +- [`docs/agent-architecture.md`](docs/agent-architecture.md): where the agents run, how the + supervisor, subagents and tool tier divide a turn, and one chat turn end to end - [`docs/development.md`](docs/development.md): environment, test tiers, gates and contributor rules - [`.github/workflows/README.md`](.github/workflows/README.md): the CI workflows and their parity with GitLab CI diff --git a/docs/agent-architecture.md b/docs/agent-architecture.md new file mode 100644 index 0000000..f9aa970 --- /dev/null +++ b/docs/agent-architecture.md @@ -0,0 +1,144 @@ +# Agent architecture + +See also: [documentation map](../README.md#documentation) · [security baseline](security-baseline.md) · [MCP client guide](mcp-client-guide.md) · [relay artefact](relay-artefact.md) · [evaluation methodology](eval-methodology.md) · [agent prompts](../config/agent_prompts/README.md) + +How the CRM assistant is built: where its parts run, how a chat turn moves through them, and how a +supervisor, its subagents and the tool tier divide the work. Each statement names the tracked source +it comes from. Read the source when the two disagree. + +## Overview + +- **One turn orchestrator.** `src/agents/turn_driver.py` (`drive_turn`) runs every turn. The deployed + AgentCore Runtime and the eval harness both call it. It holds no identity and makes no + authorization decision. Tool calls go through an identity-bound dispatch callable that its caller + injects. +- **Three model tiers.** The supervisor, subagent and tool tiers each resolve their own family, + model and effort (`src/providers/tier_tuning.py`). The models come from `config/models.yaml`, and + the tuning each model accepts comes from `config/model_capabilities.yaml`. +- **One enforcement boundary.** Agents reach CRM data only by invoking the same action Lambdas the + web app and MCP clients use (`src/agents/tool_dispatch.py`, `src/crm/dispatch.py`). Authorization + happens in those handlers (`src/crm/authz.py`), not in a prompt, the relay or the Runtime. +- **One tool definition.** The agents' tool registry (`src/agents/registry.py`) is generated from + `src/crm/toolspec/definitions.py`. That file also generates the handler validators and the Gateway + MCP tool definitions. Each tool definition lists the agent roles allowed to hold it. + +## Deployment view + +![Deployment view: the browser loads the React SPA through CloudFront from S3, signs in with Cognito, and sends /api/* to the private REST API and /agent/* to the relay Lambda's Function URL; the relay calls the AgentCore Runtime, which calls Amazon Bedrock models and invokes the CRM action Lambdas, which use DynamoDB; MCP clients reach the CRM tools Gateway, which invokes one action Lambda per tool, and the chat Gateway, whose chat_with_supervisor Lambda calls the Runtime; each Gateway runs its own identity interceptor Lambda; CodeBuild builds the Runtime image into ECR](figures/agent-architecture-deployment.svg) + +| Component | Role in the agent path | Source | +|---|---|---| +| Amazon CloudFront | `/agent/*` goes to the relay's `AWS_IAM` Function URL through a `lambda`-type OAC, with caching and compression off | `infra/modules/frontend_cdn/cloudfront.tf` | +| Relay Lambda (Node.js) | verifies the Cognito token in `X-Crm-Authorization`, calls `InvokeAgentRuntime` with SigV4, and re-emits the Runtime's SSE frames verbatim | `src/relay/src/index.ts`, `src/relay/src/jwt.ts`, `src/relay/src/runtime.ts` | +| AgentCore Runtime | the container serving `POST /invocations` and `GET /ping`; runs chat turns, eval turns and cancellation | `src/agents/runtime_server.py`, `src/agents/runtime_entrypoint.py`, `infra/modules/agentcore/` | +| Amazon ECR and AWS CodeBuild | CodeBuild builds the Runtime image and pushes it to ECR; the Runtime pulls it from there | `infra/modules/agentcore/ecr_codebuild.tf` | +| Amazon Bedrock | every model call, signed with the Runtime role's IAM credentials | `src/providers/factory.py`, `src/providers/sdk_transport.py` | +| CRM action Lambdas | one per tool; decode the caller's identity, validate input, authorize, and read or write DynamoDB | `src/crm/handlers/`, `src/crm/envelope.py`, `src/crm/store/store.py` | +| AgentCore Gateway (CRM tools) | MCP surface with one Lambda target per tool | `infra/modules/agentcore/gateway.tf`, `infra/modules/agentcore/gateway_targets.tf` | +| AgentCore Gateway (chat) | MCP surface exposing the assistant as the one tool `chat_with_supervisor` | `infra/modules/mcp_chat_gateway/`, `src/gateway/chat_target.py` | +| Identity interceptor Lambdas | the REQUEST interceptor, one function per Gateway running the same code. Each re-verifies the bearer token, removes caller-supplied identity keys and injects `_identity` | `src/gateway/identity_interceptor.py` | +| Amazon Cognito | the user pool whose tokens the relay, the API authorizer and the Gateways verify | `infra/modules/cognito/` | + +## Agent workflow + +![Agent workflow: the supervisor calls its direct read tools with arguments, and delegates to the research, mutation, analytics and composer subagents, each listed with the tools the registry grants it; each subagent's leaf calls go through the tool tier, formulate_and_invoke, which invokes the CRM action Lambdas; every delegation returns exactly one outcome to the supervisor: data, denied, tool_failure or no_match](figures/agent-architecture-workflow.svg) + +- **Supervisor** (`src/agents/supervisor.py`). It runs on the supervisor tier and holds two kinds of + tool. *Direct tools* (`DIRECT_TOOL_NAMES`) are the high-frequency reads the registry grants the + `supervisor` role; the supervisor model writes their arguments itself. *Subagent tools* + (`subagent_tool_schemas`) are one tool per subagent. Each takes a single `intent` string, and the + subagent sees only that intent, not the conversation. +- **Subagents** (`src/agents/subagents/`). `research`, `mutation`, `analytics` and `composer` each + have a purpose and the tools `tool_registry_for(role)` returns for that role. The figure lists + them as generated from the registry. Only `mutation` holds tools that write, and a change a person + must approve goes through `submit_proposal`. No tool lets an agent approve its own proposal. + `src/agents/subagent_runner.py` runs one delegation as a subagent-tier model loop over exactly + those tools. +- **Tool tier** (`src/agents/tool_actor.py`). Each of a subagent's leaf calls carries an intent. One + tool-tier model call (`formulate_and_invoke`) turns that intent into the tool's arguments and + dispatches the call. It returns the handler's response verbatim. The actor does not validate the + arguments; the handler does, and its `validation_failed` response comes back unchanged. +- **Outcomes.** `classify_tool_result` sorts every delegation result into exactly one + `SubagentOutcome` kind, and `SubagentOutcome.__post_init__` refuses any other combination: + + | Outcome | When | What the supervisor reports | + |---|---|---| + | `data` | successful results | the results, in call order, bounded by `bound_results` and marked `truncated` when cut | + | `denied` | an error with code `scope_denied` or `contact_departed` | the handler's denial message and the missing scope | + | `tool_failure` | any other error, including a tool-tier model that produced no usable call | the error message; no data is invented | + | `no_match` | `not_found`, or an empty `items` list | that nothing matched | + + `synthesize_reply` renders the outcome. A denial or a failure is never turned into data. A + `tool_failure` from a leaf call is cleared when a later call to the same tool succeeds; a denial is + never cleared (`src/agents/subagent_runner.py`). +- **Prompts.** The supervisor and subagent system prompts are `config/agent_prompts/supervisor.yaml` + and `config/agent_prompts/subagent.yaml` (`src/agents/agent_prompts.py`). Every model family gets + the same prompts. + +## Chat turn + +![One chat turn: the SPA posts to /agent/* with the Cognito token in X-Crm-Authorization; CloudFront's OAC signs the request to the relay; the relay verifies the token and calls InvokeAgentRuntime with the verified claims as _agent_identity; the Runtime decodes the identity and drives the turn; the supervisor calls Bedrock, calls direct read tools on the action Lambdas, and delegates to a subagent, whose subagent-tier and tool-tier model calls lead to leaf tool calls on the action Lambdas; the handler result returns verbatim, the subagent returns one outcome, and the Runtime streams SSE frames that the relay re-emits verbatim back through CloudFront](figures/agent-architecture-chat-turn.svg) + +1. The SPA posts the turn to `/agent/*`. It sends the Cognito token in `X-Crm-Authorization`, because + CloudFront's OAC signs the origin request and overwrites `Authorization` + (`infra/modules/frontend_cdn/cloudfront.tf`). +2. The relay verifies the token's signature, issuer, expiry and app client. The allowed client is + read from the SSM parameter named by `COGNITO_AUDIENCE_PARAMETER` (`src/relay/src/jwt.ts`). This is + the only authentication on the browser path. A rejected token gets a plain HTTP 401 before any + stream opens (`src/relay/src/index.ts`). +3. The relay calls `InvokeAgentRuntime` with SigV4 and puts the verified claims in the payload as + `_agent_identity` (`src/relay/src/runtime.ts`). It builds no identity and makes no authorization + decision. +4. The Runtime keeps only that channel from the authenticated payload (`_authenticated_payload` in + `src/agents/runtime_server.py`). It decodes the identity with `crm.envelope.decode_identity` + (`resolve_identity`) and resolves every tier's tuning before the turn starts, so a bad tuning + field fails fast (`resolve_tuning` in `src/agents/runtime_entrypoint.py`). +5. `drive_turn` runs the supervisor-tier loop. A direct read tool is dispatched with the supervisor's + own arguments. A subagent tool runs a delegation, and each leaf call in it goes through the tool + tier. +6. Every dispatch is a `lambda:InvokeFunction` on the tool's action Lambda. The event carries the + user's identity on the `agent` channel, built by `crm.envelope.identity_event`, which first strips + every identity key from the model-written arguments (`src/agents/tool_dispatch.py`). The handler + re-checks scope exactly as it does for the web app. +7. The Runtime streams one SSE frame per `AgentEvent` (`src/agents/events.py`: `tool_call`, + `tool_result`, `proposal`, `text_delta`, `usage`, `heartbeat`, `completed`, `error`). A + `heartbeat` goes out after each quiet interval, so an idle stream stays open. The relay forwards + each frame unchanged, including kinds its generated schema does not know. +8. The turn's caps (`CHAT_BUDGET` in `src/agents/budget.py`) bound tool calls and wall-clock time. + A turn that runs out of budget ends with a `budget_exhausted` error event and keeps the partial + work and usage. Events are recorded per session, so a client can resume a stream from a later + event (`InMemorySessionStore`, `src/agents/runtime_entrypoint.py`). Conversation history is kept + server-side, per session and owner (`src/agents/conversation_history.py`). + +An MCP client takes the same path from the Runtime onward. The chat Gateway's interceptor verifies +the caller's token. Then `chat_with_supervisor` claims or verifies the conversation, builds +`_agent_identity` from the verified identity, and invokes the Runtime (`src/gateway/chat_target.py`). + +## Identity channels + +`crm.envelope.decode_identity` (`src/crm/envelope.py`) accepts exactly one of three channels and has no +default. An event with no recognised channel raises `AuthenticationFailed`. + +| Channel | Key | Who writes it | Path | +|---|---|---|---| +| `apigw` | `requestContext.authorizer` claims | the API Gateway Cognito authorizer; the token must also be issued to an allowed app client | web app `/api/*` | +| `gateway` | `_identity` | the Gateway REQUEST interceptor, after it removes every caller-supplied identity key | MCP clients | +| `agent` | `_agent_identity` | the Runtime's tool dispatch, from the identity the relay or `chat_with_supervisor` forwarded; the eval harness writes it directly (`src/eval/harness.py`) | in-app agents | + +A model cannot change whose identity a tool call runs as. `identity_event` removes every key in +`IDENTITY_CHANNEL_KEYS` from the arguments before it writes the trusted channel. + +## Model tiers + +| Tier | Runs | Configured in | +|---|---|---| +| `supervisor` | routing, direct reads, the reply | `config/models.yaml` (per family), `src/agents/supervisor.py` (`SUPERVISOR_TIER`) | +| `subagent` | one delegation's loop | `config/models.yaml`, `src/agents/subagents/base.py` (`SUBAGENT_TIER`) | +| `tool` | one leaf call's arguments | `config/models.yaml`, `src/agents/tool_actor.py` (`TOOL_TIER`) | + +`config/models.yaml` names each family's model and default effort for each tier, and its +`default_family`. `config/model_capabilities.yaml` lists the effort values each model accepts. +`src/providers/factory.py` is the only place a family adapter is chosen. Both adapters reach Bedrock +through the vendor SDKs, signed with IAM credentials, and the project reads no API key. A user's saved +settings, or a turn's tuning block, can choose the family, model and effort per tier. A tier left unset +falls back as `config/models.yaml` describes. diff --git a/docs/development.md b/docs/development.md index 9c1b583..3e0a44b 100644 --- a/docs/development.md +++ b/docs/development.md @@ -39,7 +39,7 @@ git config core.hooksPath githooks # or: pre-commit install cask `drawio`, whose CLI is `drawio`), using `drawio -x -f svg --embed-svg-images --theme light`; see [`docs/figures/README.md`](figures/README.md). - Security-relevant pins: `cryptography` 50.0.2, `PyJWT` 2.15.1, `urllib3` 2.8.0 and - `pytest` 9.1.1 (`requirements.txt`); `vite` 8.3.5 and `tailwindcss` 4.3.3 (`frontend/package.json`; + `pytest` 9.1.1 (`requirements.txt`); `vite` 8.3.6 and `tailwindcss` 4.3.5 (`frontend/package.json`; Tailwind 4 needs Safari 16.4, Chrome 111 or Firefox 128, see [`frontend/README.md`](../frontend/README.md)); `hashicorp/aws` 6.71.0 (exact constraint) and `hashicorp/null` 3.3.2 (lock file only; no version constraint), in `infra/.terraform.lock.hcl`. diff --git a/docs/eval-methodology.md b/docs/eval-methodology.md index b1e6203..ee182e4 100644 --- a/docs/eval-methodology.md +++ b/docs/eval-methodology.md @@ -201,7 +201,9 @@ before the intro line, `## Reading these figures` and the per-arm sections, whic unchanged. `matrix.json` carries the same figures as its first key, `tier_comparison`, with `columns`, `tiers` (`supervisor`, `subagent`, `tool`) and `notes`. `matrix.csv` carries them as `summary_*` columns after every existing column, with each arm's values repeated on each of its task -rows. `eval.matrix.tier_comparison` builds all three from the arm records. +rows. `eval.matrix.tier_comparison` builds all three from the arm records. The summary tables +themselves come from `eval.matrix.tier_comparison_table`, which the CLI's `matrix.md` and the eval +dashboard both render. There are three tables, Supervisor, Subagent and ToolCall, each with one column per arm in run order. Columns are never re-sorted. A column is headed by the arm's family. When a family has more than one diff --git a/docs/figures/README.md b/docs/figures/README.md index 34ccd20..dea8ade 100644 --- a/docs/figures/README.md +++ b/docs/figures/README.md @@ -1,6 +1,6 @@ # Figures -See also: [documentation map](../../README.md#documentation). Pages embedding these figures: [README](../../README.md) · [development](../development.md) · [evaluation methodology](../eval-methodology.md) · [MCP client guide](../mcp-client-guide.md) · [relay artefact](../relay-artefact.md) · [runbook](../runbook.md) · [security baseline](../security-baseline.md) +See also: [documentation map](../../README.md#documentation). Pages embedding these figures: [README](../../README.md) · [agent architecture](../agent-architecture.md) · [development](../development.md) · [evaluation methodology](../eval-methodology.md) · [MCP client guide](../mcp-client-guide.md) · [relay artefact](../relay-artefact.md) · [runbook](../runbook.md) · [security baseline](../security-baseline.md) Each figure is a draw.io source (`.drawio`) next to its SVG export (`.svg`); the markdown pages link the SVG. Edit the source, then re-export; never edit an SVG by hand. diff --git a/docs/figures/agent-architecture-chat-turn.drawio b/docs/figures/agent-architecture-chat-turn.drawio new file mode 100644 index 0000000..c301138 --- /dev/null +++ b/docs/figures/agent-architecture-chat-turn.drawio @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/figures/agent-architecture-chat-turn.svg b/docs/figures/agent-architecture-chat-turn.svg new file mode 100644 index 0000000..ad61f23 --- /dev/null +++ b/docs/figures/agent-architecture-chat-turn.svg @@ -0,0 +1,3 @@ + + +CRM Agent Eval — one chat turn from the browserBrowser – React SPAAmazon CloudFrontRelay LambdaRuntime – supervisorRuntime – subagentand tool tierAmazon BedrockCRM action Lambda1. POST /agent/* with the Cognito tokenin X-Crm-Authorization2. OAC signs the request (SigV4)3. verify the token: issuer, keys, audience4. InvokeAgentRuntime (SigV4);verified claims as _agent_identity5. decode_identity, resolve tuning, drive_turn6. supervisor-tier model call7. direct read tool: lambda:InvokeFunction8. delegate: subagent tool with an intent9. subagent-tier and tool-tier model calls10. leaf tool: lambda:InvokeFunction (agent channel)11. handler result, verbatim12. one outcome: data, denied, tool_failure or no_match13. SSE frames, streamed as the turn runs: tool_call,tool_result, proposal, text_delta, usage, heartbeat,completed or error14. frames re-emitted verbatim, back through CloudFront \ No newline at end of file diff --git a/docs/figures/agent-architecture-deployment.drawio b/docs/figures/agent-architecture-deployment.drawio new file mode 100644 index 0000000..19cc5f5 --- /dev/null +++ b/docs/figures/agent-architecture-deployment.drawio @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/figures/agent-architecture-deployment.svg b/docs/figures/agent-architecture-deployment.svg new file mode 100644 index 0000000..41917a0 --- /dev/null +++ b/docs/figures/agent-architecture-deployment.svg @@ -0,0 +1,3 @@ + + +CRM Agent Eval — where the agents runAWS CloudBrowser –React SPAMCP clientAmazon Cognito –user poolAmazon CloudFrontAmazon S3 –SPA build (OAC)Amazon API Gateway –private REST APIAWS Lambda –relay (Function URL)AgentCore Gateway –CRM toolsAWS Lambda –identity interceptor(CRM tools Gateway)AgentCore Gateway –chatAWS Lambda –identity interceptor(chat Gateway)AWS Lambda –chat_with_supervisorAgentCoreRuntimeAmazon Bedrock –modelsAmazon ECR –Runtime imageAWS CodeBuild –image buildAWS Lambda –CRM action handlers(one per tool)Amazon DynamoDB –tenant-partitioned tablesHTTPSsign in/*/api/*/agent/*Cognito authorizerInvokeAgentRuntimeimagepushmodel callslambda:InvokeFunctionstore.pyMCPMCPREQUESTone target per toolREQUESTInvokeAgentRuntime \ No newline at end of file diff --git a/docs/figures/agent-architecture-workflow.drawio b/docs/figures/agent-architecture-workflow.drawio new file mode 100644 index 0000000..c7abd13 --- /dev/null +++ b/docs/figures/agent-architecture-workflow.drawio @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/figures/agent-architecture-workflow.svg b/docs/figures/agent-architecture-workflow.svg new file mode 100644 index 0000000..aa434bb --- /dev/null +++ b/docs/figures/agent-architecture-workflow.svg @@ -0,0 +1,3 @@ + + +CRM Agent Eval — supervisor, subagents and toolsSupervisor(supervisor tier)src/agents/supervisor.pyDirect read toolssearch_opportunitiessearch_accountsget_opportunityget_accountget_contactlist_activitiespipeline_aggregatelist_proposalslist_audit_recordsget_audit_recordget_page_contexttool call with argumentsDelegation outcome: exactly one ofdatatool results, verbatim and boundeddeniedthe denial and the missing scopetool_failurethe error; no data is inventedno_matchnothing matched, said plainlyreturned to the supervisorresearch subagent(subagent tier)search_opportunitiessearch_accountsget_opportunityget_accountget_contactlist_activitieslist_audit_recordsget_audit_recordmutation subagent(subagent tier)search_opportunitiessearch_accountsget_opportunityget_accountget_contactlist_activitieslist_proposalslist_audit_recordsget_audit_recordcreate_accountupdate_accountcreate_contactupdate_contactcreate_opportunityupdate_opportunitylog_activityupdate_activitycreate_notesubmit_proposalrebase_proposalanalytics subagent(subagent tier)search_opportunitiessearch_accountsget_opportunityget_accountlist_activitiespipeline_aggregatecomposer subagent(subagent tier)search_opportunitiessearch_accountsget_opportunityget_accountget_contactdraft_messagedelegation: one tool per subagent, given only an intentTool tier: formulate_and_invoketurns each leaf call's intent into argumentssrc/agents/tool_actor.pyAWS Lambda – CRM action handlers(agent identity channel)lambda:InvokeFunctionlambda:InvokeFunctionclassify_tool_result picks the kind; synthesize_reply turns it into the reply \ No newline at end of file diff --git a/docs/figures/development-test-ladder.drawio b/docs/figures/development-test-ladder.drawio index fa52e1e..c9a5c40 100644 --- a/docs/figures/development-test-ladder.drawio +++ b/docs/figures/development-test-ladder.drawio @@ -19,7 +19,7 @@ - + diff --git a/docs/figures/development-test-ladder.svg b/docs/figures/development-test-ladder.svg index c8a642b..4093407 100644 --- a/docs/figures/development-test-ladder.svg +++ b/docs/figures/development-test-ladder.svg @@ -1,3 +1,3 @@ -CRM Agent Eval — the test ladderLayer 1unit teststests/unit/(every gate andsmoke module too)needs:nothingLayer 2stub sweeps andintegration teststests/stub/tests/integration/needs:Docker(DynamoDB Local)Layer 3plan-time gatessecurity baselineagainst aTerraform planneeds:terraform andinitialised providersLayers 4-6smoke checksscripts/smoke/per-resource,integration, e2eneeds:deployed stack,credentials; billableT4browser journeystests/e2e/browser/through thedeployed SPAneeds:deployed stack;billablemake verify (make -k): Layers 1-3,offline, no AWS credential, no costlint, typecheck, test, test-stub, test-integration,test-relay, test-journeys-static, verify-shellcheck,verify-gates (scripts/run_gates.py)make verify-deployscripts/verify_deployment.sh--i-understand-this-is-billableplaywright test(its static gates,tsc and --list, runin make verify) \ No newline at end of file +CRM Agent Eval — the test ladderLayer 1unit teststests/unit/(every gate andsmoke module too)needs:nothingLayer 2stub sweeps andintegration teststests/stub/tests/integration/needs:Docker(DynamoDB Local)Layer 3plan-time gatessecurity baselineagainst aTerraform planneeds:terraform andinitialised providersLayers 4-6smoke checksscripts/smoke/per-resource,integration, e2eneeds:deployed stack,credentials; billableT4browser journeystests/e2e/browser/through thedeployed SPAneeds:deployed stack;billablemake verify (make -k): Layers 1-3,offline, no AWS credential, no costlint, format-check, typecheck, test, test-stub,test-integration, test-relay, test-journeys-static,check-cost-withheld, verify-gates (scripts/run_gates.py),verify-shellcheckmake verify-deployscripts/verify_deployment.sh--i-understand-this-is-billableplaywright test(its static gates,tsc and --list, runin make verify) \ No newline at end of file diff --git a/docs/figures/readme-aws-user-plane.drawio b/docs/figures/readme-aws-user-plane.drawio index abf293f..8159aaa 100644 --- a/docs/figures/readme-aws-user-plane.drawio +++ b/docs/figures/readme-aws-user-plane.drawio @@ -7,14 +7,14 @@ - + - + @@ -27,7 +27,7 @@ - + diff --git a/docs/figures/readme-aws-user-plane.svg b/docs/figures/readme-aws-user-plane.svg index 72eaf04..d6b459d 100644 --- a/docs/figures/readme-aws-user-plane.svg +++ b/docs/figures/readme-aws-user-plane.svg @@ -1,3 +1,3 @@ -CRM Agent Eval — user plane on AWSAWS CloudAWS RegionVPCPrivate subnetsRuntime subnets (no NAT route)Browser –React SPA,downloadedvia CloudFrontAmazon CloudFront –CDN, 3 behavioursdeferred, not enforced:AWS WAFTLS 1.2 min. (viewer)Amazon S3 – UI hostingbuilt React SPA (static files)private bucket, OAC, SSE-KMSAmazon API Gateway –private REST API(Cognito authorizer)AWS KMS –customer managed keysElastic Load Balancing –internal ALBVPC interface endpoint –execute-apiAWS Lambda –CRM action handlersAmazon DynamoDB –CRM tablesAWS Lambda –streaming relayAmazon Bedrock AgentCore –RuntimeAmazon Bedrock –modelsAWS Lambda –pre-token generationAmazon Cognito –user poolHTTPSdefault · OAC + SigV4serves the SPA files/api/* · VPC origincarries Cognito JWT/agent/* · OAC + SigV4Function URL (AWS_IAM)carries Cognito JWTHTTPSHTTPSprivate APILambda proxy(IAM)IAM · gatewayendpointSSE-KMSSigV4 · InvokeAgentRuntime(interface endpoint)SigV4 · bedrock-runtime(interface endpoint)HTTPS · OAuth code flowinvoke (IAM) \ No newline at end of file +CRM Agent Eval — user plane on AWSAWS CloudAWS RegionVPCPrivate subnetsRuntime subnets (no NAT route)Browser –React SPA,downloadedvia CloudFrontAmazon CloudFront –CDN, 3 behavioursdeferred, not enforced:AWS WAFTLS 1.2 min. (viewer)enforced:security headers + CSP(response-headers policy)Amazon S3 – UI hostingbuilt React SPA (static files)private bucket, OAC, SSE-KMSAmazon API Gateway –private REST API(Cognito authorizer)AWS KMS –customer managed keysElastic Load Balancing –internal ALBVPC interface endpoint –execute-apiAWS Lambda –CRM action handlersAmazon DynamoDB –CRM tablesAWS Systems Manager –Parameter Store(API client allowlist)AWS Lambda –streaming relayAmazon Bedrock AgentCore –RuntimeAmazon Bedrock –modelsAWS Lambda –pre-token generationAmazon Cognito –user poolHTTPSdefault · OAC + SigV4serves the SPA files/api/* · VPC origincarries Cognito JWT/agent/* · OAC + SigV4Function URL (AWS_IAM)carries Cognito JWTHTTPSHTTPSprivate APILambda proxy(IAM)IAM · gatewayendpointIAM · ssm:GetParameter(interface endpoint)SSE-KMSSigV4 · InvokeAgentRuntime(interface endpoint)SigV4 · bedrock-runtime(interface endpoint)HTTPS · OAuth code flowinvoke (IAM) \ No newline at end of file diff --git a/docs/figures/security-baseline-aws-network.drawio b/docs/figures/security-baseline-aws-network.drawio index 564a3a8..e5122dd 100644 --- a/docs/figures/security-baseline-aws-network.drawio +++ b/docs/figures/security-baseline-aws-network.drawio @@ -7,7 +7,7 @@ - + @@ -18,7 +18,7 @@ - + diff --git a/docs/figures/security-baseline-aws-network.svg b/docs/figures/security-baseline-aws-network.svg index b36efdb..005934a 100644 --- a/docs/figures/security-baseline-aws-network.svg +++ b/docs/figures/security-baseline-aws-network.svg @@ -1,3 +1,3 @@ -CRM Agent Eval — AWS network security baselineAWS CloudAWS RegionVPC (adopted; this stack adds endpoints, security groups, flow log, optional NAT)Public subnet (adopted)Private subnets – Lambda and endpoint ENIsRuntime subnets (no NAT route)Amazon CloudFront –/api/* VPC origindeferred, not enforced:AWS WAFTLS 1.2 min. (viewer)NAT gateway –optional, egress onlyAWS Lambda –all functions(SG: no ingress)Elastic Load Balancing –internal ALB (SG: in fromCloudFront VPC origin only)VPC interface endpointsbedrock-agentcore · bedrock-runtimeecr.api · ecr.dkr · execute-api *kms · lambda · logs · ssm · statesSG: 443 in from Lambda, Runtime, ALB* private DNS offAmazon Bedrock AgentCore –Runtime (SG: no ingress)Runtime resource policy:invoke by the invoker roles only;Deny unless aws:SourceVpce =our bedrock-agentcore endpoint(stage-2 toggle, off by default)VPC flow logs –ALL trafficVPC gateway endpoints –S3, DynamoDB (Lambdaand Runtime route tables)Amazon Cognito –user pool JWKSAmazon CloudWatch –Logs (CMK)AWS KMS – CMKs:DynamoDB, SPA bucket, logs,CloudTrail, eval artefactsAmazon DynamoDB –CRM tablesAmazon S3 –buckets, ECR layersAWS CloudTrail –multi-Region trailAmazon S3 –trail bucket (+ access logs)/api/* · VPC originHTTP 80 (in VPC)HTTPS 443execute-apiHTTPS 443HTTPS 443bedrock-runtime · ECRHTTPS 443 · Cognito JWKSfetch (relay, Gatewayinterceptors)HTTPS · internet egress(no inbound path)delivery(IAM role)SSE-KMSSSE-KMSIAMIAMSSE-KMS · log file validation \ No newline at end of file +CRM Agent Eval — AWS network security baselineAWS CloudAWS RegionVPC (adopted; this stack adds endpoints, security groups, flow log, optional NAT)Public subnet (adopted)Private subnets – Lambda and endpoint ENIsRuntime subnets (no NAT route)Amazon CloudFront –/api/* VPC origindeferred, not enforced:AWS WAFTLS 1.2 min. (viewer)enforced:security headers + CSP(response-headers policy)NAT gateway –optional, egress onlyAWS Lambda –all functions(SG: no ingress)Elastic Load Balancing –internal ALB (SG: in fromCloudFront VPC origin only)VPC interface endpointsbedrock-agentcore · bedrock-runtimeecr.api · ecr.dkr · execute-api *kms · lambda · logs · ssm · statesSG: 443 in from Lambda, Runtime, ALB* private DNS offAmazon Bedrock AgentCore –Runtime (SG: no ingress)Runtime resource policy:invoke by the invoker roles only;Deny unless aws:SourceVpce =our bedrock-agentcore endpoint(stage-2 toggle, off by default)VPC flow logs –ALL trafficVPC gateway endpoints –S3, DynamoDB (Lambdaand Runtime route tables)Amazon Cognito –user pool JWKSAmazon CloudWatch –Logs (CMK)AWS KMS – CMKs:DynamoDB, SPA bucket, logs,CloudTrail, eval artefacts,cursors, Terraform stateAmazon DynamoDB –CRM tablesAmazon S3 –buckets, ECR layersAWS CloudTrail –multi-Region trailAmazon S3 –trail bucket (+ access logs)/api/* · VPC originHTTP 80 (in VPC)HTTPS 443execute-apiHTTPS 443HTTPS 443bedrock-runtime · ECRHTTPS 443 · Cognito JWKSfetch (relay, Gatewayinterceptors)HTTPS · internet egress(no inbound path)delivery(IAM role)SSE-KMSSSE-KMSIAMIAMSSE-KMS · log file validation \ No newline at end of file diff --git a/docs/runbook.md b/docs/runbook.md index 6699d00..d64450c 100644 --- a/docs/runbook.md +++ b/docs/runbook.md @@ -532,6 +532,18 @@ Notes: available; a user who enrols is still challenged. - All three scripts write only the `demo` tenant. None can write `canary` or an `eval-` tenant. +To check that the deployed `canary` tenant is still empty, pass the outputs document and the table +prefix: + +```bash +.venv/bin/python3 scripts/check_canary_tenant_empty.py --outputs results/tf-outputs.json \ + --table-prefix crm-agent-eval --profile

--region +``` + +Exit 0 means the tenant was read and holds no row, and 1 means it holds rows or the store refused +the read. Without `--outputs` the check reads nothing and exits 3 (`[SKIP]`). The same happens +without `--table-prefix` (or `CRM_TABLE_PREFIX`), because the unprefixed tables do not exist. + ## Verification layers 4-6 ### Running @@ -612,17 +624,17 @@ interrupted earlier run left behind. | Module | Asserts | |---|---| -| `smoke/lambda_actions.py` | every action Lambda (from `ALL_TOOLS`) succeeds for an in-scope identity envelope and returns typed `scope_denied` (not a 500 or `not_found`) for an out-of-scope target; no response leaks `detail`; `create_opportunity`'s optional `primary_contact_id` is persisted when valid and refused with `validation_failed` when it belongs to another account. The listing tools (`search_opportunities`, `search_accounts`, `pipeline_aggregate`) are denied `scope_denied` naming `account:*` for an empty-book caller, and `explicit_out_of_book_filter_denied` checks that `search_opportunities` with an out-of-book `account_id` names `account:`. On the seeded departed contact: `departed_contact_update_refused` (409 `contact_departed`, missing scope `status:active`), `departed_contact_reactivation_allowed` (an update that sets `status`) and `departed_contact_restored` (set back to `departed`) | +| `smoke/lambda_actions.py` | every action Lambda (from `ALL_TOOLS`) succeeds for an in-scope identity envelope and returns typed `scope_denied` (not a 500 or `not_found`) for an out-of-scope target; no response leaks `detail`; `create_opportunity`'s optional `primary_contact_id` is persisted when valid and refused with `validation_failed` when it belongs to another account. The listing tools (`search_opportunities`, `search_accounts`, `pipeline_aggregate`) are denied `scope_denied` naming `account:*` for an empty-book caller, and `explicit_out_of_book_filter_denied` checks that `search_opportunities` with an out-of-book `account_id` names `account:`. On the seeded departed contact: `departed_contact_update_refused` (409 `contact_departed`, missing scope `status:active`), `departed_contact_reactivation_allowed` (an update that sets `status`) and `departed_contact_restored` (set back to `departed`). Pagination cursors on the five paginating tools: page 2 through the real `next_cursor` succeeds, and a tampered cursor, a cursor replayed by another rep or a cursor from another tool is refused 400 `validation_failed` `source: cursor`. `CRM_CURSOR_KMS_KEY_ARN` is set on exactly those five functions. The cursor key has rotation on, is symmetric and single-Region, and carries `data-classification`. `simulate-principal-policy` shows the five roles may Encrypt/Decrypt only under the `crm-cursor` context and nothing else on the key, and other roles are refused, explicitly under the live key policy. A long-text field one character over the cap is refused 400 | | `smoke/deployed_parity.py` | every deployed action Lambda plus the identity interceptor and pre-token-generation function has `CodeSha256` equal to its local zip's base64 SHA-256. Fail-closed on a missing build directory, zip or function. `--deploy-gate` is the form `deploy.sh` runs. Does not cover the relay | -| `smoke/api_routes.py` | private REST API: every route answers with a real Cognito token and returns 401 unauthenticated; every method names an authorizer and declares `COGNITO_USER_POOLS`; stage throttling is set; a `body-and-params` request validator exists and every method references it, with an `application/json` model on every POST | -| `smoke/iam_roles.py` | every execution role, via `iam simulate-principal-policy`: allowed its own actions, denied every other function's. Each non-own pair yields a `simulate:` row (denied, pass/fail) and an `explicit_deny:` row (a matching Deny; an implicit deny fails). Each own grant the matrix declares `leading_keys`/`key_prefix`, sweep roles included, also yields a `conditioned_scope_denied:` row that probes a foreign key independent of the HCL parser, and `conditioned_grants_parity` fails if the parsed and declared conditioned grants differ. `matrix_readable` fails, and no role is examined, when `table_action_role_matrix.json` is malformed. A role whose policies cannot be loaded fails `leading_keys:policies_unreadable`. A `leading_keys:` row fails when a `ForAllValues:*` LeadingKeys Allow also grants an action that carries no LeadingKeys context (the condition holds vacuously for it). A role that cannot be resolved skips its matrix. A tool's Query grant scoped by `local.tool_query_indexes` (revert_audit_record's child check) is simulated on its first index, with `index_only_base_table_denied::dynamodb:Query@
` asserting the base table is refused and `scoped_index_allowed::dynamodb:Query@
/` covering each further index. `own_table_denied::@
` asserts an explicit Deny for each action in `OWN_TABLE_DENIAL_PROBES` (revert_audit_record's PutItem and UpdateItem on notes; sweep_control's PutItem on each seed table, which it writes through `BatchWriteItem` only). A sweep grant carrying a `select_condition` (sweep_control's `demo` Query on `gsi_tenant`, `Select = COUNT` only) yields `extra_condition_allowed:` (COUNT allowed), `extra_condition_denied:` (each other `Select` value denied), `extra_condition_absent_denied:` (no `Select` denied, the key reported missing) and `extra_condition_sibling_allowed:` (the `eval-*` and `canary` grants on the same index still read rows) rows; an unreadable grant list fails `extra_conditions_readable`. `coverage_is_non_vacuous` bounds the run by a derived minimum check count | -| `smoke/gateway_tools.py` | Gateway `tools/list` names exactly the toolspec's tools; `schema_matches`, per tool: the schema `type`, property names, each property's `type` and the `required` set match (constraint keywords such as `enum`, `minLength` and `maximum` cannot be carried by the Gateway and are reported as a `skip`); `description_matches_toolspec`, per tool: the tool's own `description` is byte-identical to the toolspec's (fails on a differing or missing description; `defer` when the tool is absent from `tools/list`); `property_descriptions_match_toolspec`, per tool: every property in both the deployed schema and the toolspec has the same `description`, byte for byte (fails on a differing, missing or undeclared description; `defer` when the deployed properties cannot be read or no property is shared); every tool invokes; a caller-supplied `_identity` is discarded. Provisions its own service principal and `client_credentials` token. An expired token and an underscoped token are each refused, after a premise check on the token's own claims; it mints both itself (a second machine token, minted first and aged past its 5-minute lifetime, so the run takes up to about 5 minutes longer; and a real end-user access token whose user is deleted afterwards). Optional operator overrides: `CRM_SMOKE_EXPIRED_TOKEN`, `CRM_SMOKE_UNDERSCOPED_TOKEN`, and `--gateway-token`/`CRM_SMOKE_GATEWAY_TOKEN`, which also turns off both mints, so the two refusal rows then need the other two overrides | +| `smoke/api_routes.py` | private REST API: every route answers with a real Cognito token and returns 401 unauthenticated; every method names an authorizer and declares `COGNITO_USER_POOLS`; stage throttling is set; a `body-and-params` request validator exists and every method references it, with an `application/json` model on every POST. API client allowlist: every API-integrated function carries `CRM_API_ALLOWED_CLIENT_IDS_PARAMETER`, and none carries the old variable. The parameter is a `String` equal to the `cognito_spa_client_id` output and tagged `data-classification`. Its read grant is the exact ARN, and no project role may write it. A direct invoke of `get_account` with apigw claims that differ only in audience gives 401 for a foreign ID-token `aud` or access-token `client_id` and 2xx for the SPA client, and the refusal is logged with its reason | +| `smoke/iam_roles.py` | every execution role, via `iam simulate-principal-policy`: allowed its own actions, denied every other function's. Each non-own pair yields a `simulate:` row (denied, pass/fail) and an `explicit_deny:` row (a matching Deny; an implicit deny fails). Each own grant the matrix declares `leading_keys`/`key_prefix`, sweep roles included, also yields a `conditioned_scope_denied:` row that probes a foreign key independent of the HCL parser, and `conditioned_grants_parity` fails if the parsed and declared conditioned grants differ. `matrix_readable` fails, and no role is examined, when `table_action_role_matrix.json` is malformed. A role whose policies cannot be loaded fails `leading_keys:policies_unreadable`. A `leading_keys:
` row fails when a `ForAllValues:*` LeadingKeys Allow also grants an action that carries no LeadingKeys context (the condition holds vacuously for it). A role that cannot be resolved skips its matrix. A tool's Query grant scoped by `local.tool_query_indexes` (revert_audit_record's child check) is simulated on its first index, with `index_only_base_table_denied::dynamodb:Query@
` asserting the base table is refused and `scoped_index_allowed::dynamodb:Query@
/` covering each further index. `own_table_denied::@
` asserts an explicit Deny for each action in `OWN_TABLE_DENIAL_PROBES` (revert_audit_record's PutItem and UpdateItem on notes; sweep_control's PutItem on each seed table, which it writes through `BatchWriteItem` only). A sweep grant carrying a `select_condition` (sweep_control's `demo` Query on `gsi_tenant`, `Select = COUNT` only) yields `extra_condition_allowed:` (COUNT allowed), `extra_condition_denied:` (each other `Select` value denied), `extra_condition_absent_denied:` (no `Select` denied, the key reported missing) and `extra_condition_sibling_allowed:` (the `eval-*` and `canary` grants on the same index still read rows) rows; an unreadable grant list fails `extra_conditions_readable`. `coverage_is_non_vacuous` bounds the run by a derived minimum check count. Supplementary rows: the `sweep_task`, `pre_token_generation` and CodeBuild roles are refused cursor-key Encrypt/Decrypt under the valid context and refused reading or writing the API client-allowlist parameter. The `approve_proposal` role may Query opportunities' `gsi_account` only, not the base table or another index, and may not Scan | +| `smoke/gateway_tools.py` | Gateway `tools/list` names exactly the toolspec's tools; `schema_matches`, per tool: the schema `type`, property names, each property's `type` and the `required` set match (constraint keywords such as `enum`, `minLength` and `maximum` cannot be carried by the Gateway and are reported as a `skip`); `description_matches_toolspec`, per tool: the tool's own `description` is byte-identical to the toolspec's (fails on a differing or missing description; `defer` when the tool is absent from `tools/list`); `property_descriptions_match_toolspec`, per tool: every property in both the deployed schema and the toolspec has the same `description`, byte for byte (fails on a differing, missing or undeclared description; `defer` when the deployed properties cannot be read or no property is shared); every tool invokes; a caller-supplied `_identity` is discarded. Provisions its own service principal and `client_credentials` token. An expired token and an underscoped token are each refused, after a premise check on the token's own claims; it mints both itself (a second machine token, minted first and aged past its 5-minute lifetime, so the run takes up to about 5 minutes longer; and a real end-user access token whose user is deleted afterwards). Optional operator overrides: `CRM_SMOKE_EXPIRED_TOKEN`, `CRM_SMOKE_UNDERSCOPED_TOKEN`, and `--gateway-token`/`CRM_SMOKE_GATEWAY_TOKEN`, which also turns off both mints, so the two refusal rows then need the other two overrides. The Gateway refuses a JSON-RPC array body with a tool-error reply (`isError: true`), without invoking the interceptor or a target; `array_body_answers_no_tool_call` fails if any tool output comes back without `isError: true`, and proof that no tool ran is a `defer` | | `smoke/agents.py` | one real chat turn through CloudFront `/agent/*` → relay → Runtime, as a user it provisions on a disposable tenant with an empty book, naming a `demo` account that user cannot see (its listing calls are denied `account:*`): the turn completes, no `tool_result` carries the out-of-book account, every event kind is in the closed vocabulary, and the per-agent grid (`responds`, `no_surplus_tool`, `no_missing_tool`, `no_direct_high_risk_write`, and the mutation subagent's `outcome_discipline_*`). A grid row the stream cannot establish is a `defer` naming its reason (`GRID_DEFER_REASONS`: `stream_carries_no_advertised_tool_surface`, `tool_call_events_carry_no_role`, `relay_turn_cannot_select_an_outcome_trigger`), never a `pass`. One model-backed turn (`MODEL_TURN_ALLOTMENTS`), billable. `demo` is proved untouched | | `smoke/dynamodb_tables.py` | every table in `crm.store.schema`: customer-managed KMS encryption, PITR, every GSI present, `ACTIVE`, queryable and projecting what `crm.store.schema` declares (`tenant` on every index; `subject` on activities' and `body` on notes' `gsi_tenant`, which scoring reads for agent-created rows), a failure naming the missing attributes, every mandatory tag (`AppName = crm-agent-eval` included); schema and `dynamodb_table_names` output reconciled | | `smoke/dynamodb_principal_deny.py` | the DynamoDB principal boundary, read from the account. `table_policy_shape:
` and `key_policy_shape`: each table's resource policy and the DynamoDB CMK's key policy carry exactly the designed Deny statements, the data-plane allowlist equals the discovered project Lambda roles (each `crm-agent-eval-*` function whose role has a `-dynamodb-kms` inline policy) plus `crm_operator_principal_arns`, and the administration allowlist equals the operators plus the account root. `table_sse_enabled:
`: `ACTIVE`, no `InaccessibleEncryptionDateTime`, SSE `ENABLED`. `data_plane_roles_discovered`: at least one project Lambda role was found. `operator_data_plane_admitted`: the operator's `GetItem` on an absent key succeeds. `probe_denied:` (GetItem, Query on a GSI, conditional PutItem, conditional PutResourcePolicy, `kms:GenerateDataKey`): a run-scoped role `crm-agent-eval-probe-`, trusted by the operator only and holding its own Allow for those actions, is refused with "explicit deny in a resource-based policy"; success, an implicit deny, `ConditionalCheckFailedException` or `PolicyNotFoundException` fails. `probe_role_setup` appears only on failure, when creating, granting or assuming the probe role raised. No probe call can write data. The probe role is deleted in a `finally` (`probe_role_deleted`); if that row fails, delete the role by hand. Before the principal-boundary Deny is applied, the `probe_denied` rows fail and the shape rows fail or defer; after it, every row passes | -| `smoke/store_principal_deny.py` | the principal boundary on the state backend, the eval-artefacts key and bucket, the logs key, the CloudTrail key and bucket, and the frontend key and origin bucket; see "Store principal boundary" for its rows. `admin_simulated_denied` rows are a simulation of the live bucket document, not a call. The probe role is deleted in a `finally` (`probe_role_deleted`) | -| `smoke/cognito_claims.py` | MFA and password policy; `AllowAdminCreateUserOnly` true (`admin_create_user_only`); an unsigned `SignUp` refused with `NotAuthorizedException` (`self_signup_refused`); the V2 pre-token-generation trigger stamps `rep_id`, `book`, `full_visibility`, `tenant` into a real token. Provisions and deletes its own user. `CRM_SMOKE_COGNITO_USERNAME`/`CRM_SMOKE_COGNITO_PASSWORD` select an existing enrolled user instead | -| `smoke/cloudfront.py` | OAC-only S3 origin and a direct S3 request refused; `/*`, `/api/*`, `/agent/*` route to the right origins; a deep link returns the SPA document, a missing `*.js` does not, an unauthenticated `/api/*` returns 401/403. TLS 1.2 minimum reports `defer` (`missing_custom_acm_certificate`) | +| `smoke/store_principal_deny.py` | the principal boundary on the state backend, the eval-artefacts key and bucket, the logs key, the CloudTrail key and bucket, and the frontend key and origin bucket; see "Store principal boundary" for its rows. `admin_simulated_denied` rows are a simulation of the live bucket document, not a call. The probe role is deleted in a `finally` (`probe_role_deleted`). The cursor key joins the boundary: the probe role's `kms:Encrypt` with the valid context is explicitly denied, and live-key-policy simulations deny the probe and key administration while admitting an allowlisted role and an operator | +| `smoke/cognito_claims.py` | MFA and password policy; `AllowAdminCreateUserOnly` true (`admin_create_user_only`); an unsigned `SignUp` refused with `NotAuthorizedException` (`self_signup_refused`); the V2 pre-token-generation trigger stamps `rep_id`, `book`, `full_visibility`, `tenant` into a real token. Provisions and deletes its own user. `CRM_SMOKE_COGNITO_USERNAME`/`CRM_SMOKE_COGNITO_PASSWORD` select an existing enrolled user instead. The SPA client has token revocation enabled, and after `RevokeToken` a `REFRESH_TOKEN_AUTH` with the revoked token gets `NotAuthorizedException` | +| `smoke/cloudfront.py` | OAC-only S3 origin and a direct S3 request refused; `/*`, `/api/*`, `/agent/*` route to the right origins; a deep link returns the SPA document, a missing `*.js` does not, an unauthenticated `/api/*` returns 401/403. TLS 1.2 minimum reports `defer` (`missing_custom_acm_certificate`). An enforced `Content-Security-Policy` on `/`, an unauthenticated `/api/*` and `/agent/*`, identical everywhere and equal to the distribution's one custom response-headers policy (`Override`, `X-Frame-Options: DENY`). Its directives match the design, connect-src admits Cognito, and every inline script in the served `/` is allowed by hash | | `smoke/access_log_delivery.py` | log objects actually arrive in each access-log bucket under each expected prefix; an empty bucket is `defer` (`no_log_objects_delivered_yet`), since delivery takes hours | | `smoke/relay_iam.py` | the relay execution role's allow and deny simulation matrix with positive controls; every other role denied invoking the Runtime; `X1_chat_target_deny_covers_actions_nobody_enumerated` (a fabricated action on the Runtime, simulated as the chat-target role, is `explicitDeny`); the relay Function URL's `AuthType` is `AWS_IAM`; `R1[]` for each toolspec tool no agent uses (approve, reject, revert): the Runtime role is denied `lambda:InvokeFunction` on it (synthetic-Allow positive control) and its `InvokeActionLambdas` statement names no pattern matching it | | `smoke/runtime_bedrock_iam.py` | the Runtime role is allowed `bedrock:InvokeModel` and `InvokeModelWithResponseStream` on every `global.` inference profile in `config/model_capabilities.yaml`, and denied `bedrock:InvokeModel` on each retired profile in the module's `RETIRED_INFERENCE_PROFILES` | @@ -668,7 +680,7 @@ refuses to run under `demo`, and reports a teardown failure as its own failing c | `smoke/integration_proposal_chain.py` | proposal → approval → audit → revert, plus both outcomes of the delete-proposal cascade, the `after_payload` allowlist, a note-create revert in scope (`note_revert:*`: the note is deleted and its audit marked reversed), and an approved delete reverted in scope (`delete_revert:*`: the contact is restored from the before-snapshot and its audit marked reversed); and two out-of-book reverts (`out_of_book_revert:*`): a note-create audit and a contact-delete audit, seeded under the disposable tenant for an account outside the book, are each refused with 403 `scope_denied`, and the note, the absent contact and both audit records read back unchanged | its own MFA-enrolled user, ID token; with `--token`, `--account-id` is optional: when absent, the account is the lowest entry of the token's `custom:book` claim (an absent or empty claim fails) | | `smoke/integration_teardown_privilege.py` | `dynamodb:DeleteItem` simulates as denied for `sweep_control`'s role (the state machine's `Teardown` step) on every tenant-scoped table, each deny resting on positive controls (the action is expressible, the ARN matches teardown's own `Query` grant, and any matrix holder of `DeleteItem` is allowed it); the role holds `BatchWriteItem` and teardown's `Query` on each table (`worker_holds_*`); `teardown_was_not_vacuous`: the fixture corpus the seeder writes is non-empty. No sweep and no tenant write; the teardown itself is `eval_sfn`'s `tenant_emptied_by_the_workers_own_role` | the runner's own credentials (simulation only) | | `smoke/three_tier_chat.py` | one delegation-forcing turn invokes all three model tiers, attributed to the Runtime role in CloudTrail. The supervisor-tier invocation is the positive control for the role, the window and the supervisor family's CloudTrail event name only; it does not cover a lower tier on the other family. CloudTrail tells tiers apart only by inference profile, so the turn runs under the first `{tier: family}` mapping whose `config/models.yaml` models have three distinct profiles: all-anthropic, then an openai supervisor with anthropic subagent and tool, then the mixed-family mapping. The row detail names the mapping. When none has distinct profiles, the turn is not sent and `attribution_mapping_profiles_distinct` fails, naming each mapping's profiles. The delegation turn gets the mixed-family turn's cost and resolved-tier rows for its mapping, suffixed `:attribution`; a mixed-family turn (schema-3 tuning) completes with non-empty `cost_lines`, a positive `cost_usd` and `resolved_tiers` naming each tier's `config/models.yaml` model and effort, with a priced cost line per tier model; a schema-2 tuning carrying `temperature` is refused as one SSE `error` frame (`invalid_request`, naming `tuning.tiers..temperature`) with no `usage`, `completed` or `text_delta` frame; a second principal reusing another user's session id is refused (HTTP 400 through the relay), while the owner's own reuse succeeds; a delegation-forcing turn with every tier on openai gets the mixed-family turn's rows suffixed `:openai_supervisor`, including `supervisor_resolved_effort_is_:openai_supervisor` (the effort from `config/models.yaml`); for each family, the second of two supervisor turns sharing the stable prefix reports `cache_read_tokens > 0` on its supervisor cost line (`supervisor_prompt_cache_read_on_second_turn:`; the anthropic pair is the mixed-family seed and owner-reuse turns, the openai pair is the openai turn and a short probe turn), `defer` with `platform_reported_no_cache_tokens` when neither turn reports any cache token and `fail` when a write is reported but nothing is read; a `page_context` route planted with a run-unique marker, once longer than the route bound and once outside its character set, is refused with HTTP 400 and the relay's generic validation message with the marker absent from the response, against the probe turn's conforming `page_context` as the control (`page_context_over_bound_route_refused`, `page_context_off_charset_route_refused`; no model call). Five model-backed turns (`MODEL_TURN_ALLOTMENTS`); a turn past that share is not issued | provisioned users | -| `smoke/eval_sfn.py` | the `eval_sweep` state machine through `POST /api/eval_trigger`: a stub rehearsal at `REHEARSAL_REPEATS` repeats (single-flight 409; `unit_tenants_recorded`: the run's `eval_runs` row lists every (arm, repeat) unit tenant; `unit_tenants_seeded`: each holds rows while the run is running; `run_records_repeats`; `completed` with arms x repeats x tasks done, `SUCCEEDED` execution, `eval_results` rows reached the Runtime with one distinct `result_id` per item and an equal share at each `repeat_index`, artifacts pass `assert_artifacts` at tasks x repeats, each arm's `provenance.effort` is `DEFAULT_ARM_EFFORT` (one `arm_effort_is_default:` row per default-sweep family, in sweep order), each arm's models are `config/models.yaml`'s (one `arm_models_are_configured:` row per default-sweep family: `provenance.model_id` is the family's supervisor model and every tier's configured model id is that tier's model; an absent provenance or tier entry fails), `prompt_bundle_matches_repo` (every arm's `provenance.prompt_bundle_sha256` equals `agents.prompt_bundle.prompt_bundle_sha256()` of the checkout running the smoke; an absent digest fails), `artefact_url` presigns a recorded artefact that an https GET fetches (200) while plain http gets 403 `AccessDenied` and a tampered key 403 `SignatureDoesNotMatch` (the S3 error code is asserted, not only the status), the sweep tenant, `canary` and lock left clean, `demo` unchanged; `tenant_emptied_by_the_workers_own_role`: the run's `eval_runs` row is `torn_down` and the run tenant and every unit tenant read back empty, so the `Teardown` step emptied them under `sweep_control`'s own role) and a cancel proof on a second stub sweep at one repeat (`accepted`, then `cancelled` with a partial matrix and clean teardown, then `already_terminal`); least-privilege role simulations for `sweep_control`, `sweep_task`, the state machine role and `eval_trigger`, derived from the `infra/eval_sfn.tf` grant locals: every DynamoDB simulation of `sweep_control`'s role, allows and denies alike, sends `dynamodb:Select = COUNT` (the value its `demo` Query grants admit, so a deny is not the Select condition's doing), and a row answered with a context key missing never passes; an allow per conditioned grant value, denies for out-of-scope keys (a `demo` twin, a foreign key, and a minted-id twin such as `act-` for `act-eval-*`) and for `demo`/`canary` where a `gsi_tenant` grant does not admit them, and an explicit-Deny `*_denies_removed_*` row for each asserted action a role no longer holds on a table, such as the seed `PutItem` (incl. `trigger_allows_artifact_get` on the artefact prefix, and `trigger_denies_{get_outside_prefix,artifact_put,list_bucket}`); `machine_tracing_enabled` (the deployed state machine's `tracingConfiguration.enabled` is true); `machine_allows_{GetSamplingRules,GetSamplingTargets,PutTelemetryRecords,PutTraceSegments}` for the four SFN-XRAY-1 X-Ray actions on `*`, and `machine_denies_{BatchGetTraces,PutEncryptionConfig}` for X-Ray actions outside it. `--live-once --i-understand-this-is-billable` is the single live sweep, gated on a matching `--retention-verdict` | its own MFA-enrolled admin user with `full_visibility`, ID token | +| `smoke/eval_sfn.py` | the `eval_sweep` state machine through `POST /api/eval_trigger`: a stub rehearsal at `REHEARSAL_REPEATS` repeats (single-flight 409; `unit_tenants_recorded`: the run's `eval_runs` row lists every (arm, repeat) unit tenant; `unit_tenants_seeded`: each holds rows while the run is running; `run_records_repeats`; `completed` with arms x repeats x tasks done, `SUCCEEDED` execution, `eval_results` rows reached the Runtime with one distinct `result_id` per item and an equal share at each `repeat_index`, artifacts pass `assert_artifacts` at tasks x repeats, each arm's `provenance.effort` is `DEFAULT_ARM_EFFORT` (one `arm_effort_is_default:` row per default-sweep family, in sweep order), each arm's models are `config/models.yaml`'s (one `arm_models_are_configured:` row per default-sweep family: `provenance.model_id` is the family's supervisor model and every tier's configured model id is that tier's model; an absent provenance or tier entry fails), `prompt_bundle_matches_repo` (every arm's `provenance.prompt_bundle_sha256` equals `agents.prompt_bundle.prompt_bundle_sha256()` of the checkout running the smoke; an absent digest fails), `artefact_url` presigns a recorded artefact that an https GET fetches (200) while plain http gets 403 `AccessDenied` and a tampered key 403 `SignatureDoesNotMatch` (the S3 error code is asserted, not only the status), the sweep tenant, `canary` and lock left clean, `demo` unchanged; `tenant_emptied_by_the_workers_own_role`: the run's `eval_runs` row is `torn_down` and the run tenant and every unit tenant read back empty, so the `Teardown` step emptied them under `sweep_control`'s own role) and a cancel proof on a second stub sweep at one repeat (`accepted`, then `cancelled` with a partial matrix and clean teardown, then `already_terminal`); least-privilege role simulations for `sweep_control`, `sweep_task`, the state machine role and `eval_trigger`, derived from the `infra/eval_sfn.tf` grant locals: every DynamoDB simulation of `sweep_control`'s role, allows and denies alike, sends `dynamodb:Select = COUNT` (the value its `demo` Query grants admit, so a deny is not the Select condition's doing), and a row answered with a context key missing never passes; an allow per conditioned grant value, denies for out-of-scope keys (a `demo` twin, a foreign key, and a minted-id twin such as `act-` for `act-eval-*`) and for `demo`/`canary` where a `gsi_tenant` grant does not admit them, and an explicit-Deny `*_denies_removed_*` row for each asserted action a role no longer holds on a table, such as the seed `PutItem` (incl. `trigger_allows_artifact_get` on the artefact prefix, and `trigger_denies_{get_outside_prefix,artifact_put,list_bucket}`); `machine_tracing_enabled` (the deployed state machine's `tracingConfiguration.enabled` is true); `machine_allows_{GetSamplingRules,GetSamplingTargets,PutTelemetryRecords,PutTraceSegments}` for the four SFN-XRAY-1 X-Ray actions on `*`, and `machine_denies_{BatchGetTraces,PutEncryptionConfig}` for X-Ray actions outside it. `--live-once --i-understand-this-is-billable` is the single live sweep, gated on a matching `--retention-verdict` | its own MFA-enrolled admin user with `full_visibility`, ID token. The completed stub run's `status` carries `tier_comparison_table` with one column per arm, and `artefact_url` with `download: true` serves `matrix_md` as an attachment with the same bytes | | `smoke/admin_authz.py` | the eval run API's admin-only operations: no token refused; the admin group exists and the admin token carries it; a non-admin's `submit {mode: live, confirmed: false}`, `cancel` and `unlock` each return 403 `eval:admin`; an admin `cancel` of a terminal run returns `already_terminal` and changes nothing | two MFA-enrolled users it provisions, an admin and a non-admin with `full_visibility` | | `smoke/user_settings_api.py` | `POST /api/user_settings` keeps each user's tuning their own: defaults on `config/models.yaml`'s `default_family` before a save; a valid schema-3 `put` reads back; a `put` carrying `temperature` or naming a model no longer configured is 400 with the row unchanged; `GET /api/capabilities` names every `config/models.yaml` model and carries no `temperature`, and its `tiers..supervisor.tuning.effort` equals `config/models.yaml`'s (one `capabilities_supervisor_effort:` row per configured family); the served defaults match the config: `capabilities_default_family`, `capabilities_tier_model::` and `capabilities_tier_effort::` per configured cell, and `capabilities_assignable_tiers:` and `capabilities_selectable:` per `config/model_capabilities.yaml` model (Opus and Astra included); another user in the same tenant still sees defaults; a `put` naming another `rep_id` and an unsupported effort are 400 `validation_failed` with nothing changed; `reset` restores the defaults on the default family; least-privilege simulations for the `user-settings` role | two MFA-enrolled users under one tenant it provisions, each with a distinct run-scoped username | | `smoke/mcp_chat_gateway.py` | Gateway #2 exposes only `chat_with_supervisor` behind its JWT: no token is 401; a token whose signature is replaced is refused (401 or 403, with no `tools/list` result) while the same claims unaltered are answered; the chat-scoped user token is refused on Gateway #1 and a `gateway/invoke`-only token on Gateway #2; a user call and a `client_credentials` call are answered; a call carrying a `temperature` argument returns `isError` `invalid_request` with no answer or conversation id; another user's `conversation_id`, with or without a forged `_agent_identity`, is refused (`isError`, `error_kind` read from the MCP `result`). Two model-backed turns. Each smoke principal's `conversation#` items are found by owner, deleted and re-read | two users and the service principal it provisions | @@ -1234,6 +1246,7 @@ it later. Exit 0 means every resource is absent or pending deletion. A later dep | `cloudfront` reports TLS minimum as `defer` | `minimum_protocol_version` has no effect on the default `cloudfront.net` certificate; TLS 1.2 is not enforced without a custom ACM certificate | | `/agent/*` returns 401 | the relay rejected the Cognito token: it expired, or it was issued for a client the relay does not allow | | Gateway `tools/call` requests return JSON-RPC error `-32001`, logged as `gateway_auth_denied` with reason `PyJWKClientError`, for up to 30 s after a Cognito signing-key rotation | the Gateway interceptor (`src/gateway/identity_interceptor.py`, PyJWT 2.15 `PyJWKClient`) re-fetches the JWKS on an unknown `kid` at most once per 30 s cooldown, measured from its last fetch. Retry after the cooldown; a miss that persists means the `kid` is not in the pool's JWKS | +| Gateway requests return JSON-RPC error `-32001`, logged as `gateway_auth_denied` with reason `body_not_an_object`, `params_not_an_object` or `unexpected_error:` | the identity interceptor (`src/gateway/identity_interceptor.py`) refuses malformed requests and fails closed. `body_not_an_object`: the JSON-RPC body is not a JSON object (an array or a scalar, for example). `params_not_an_object`: a method other than `tools/list` sent `params` that is not an object. Fix the client to send one JSON-RPC request object with object `params`. `unexpected_error:` (logged at warning): the interceptor raised while handling the request, for example on a configuration error. No traceback is logged. Read the exception type, then check the interceptor's environment and its recent deploy. None of these reach a Lambda target | | A direct `InvokeAgentRuntime` call fails with `AccessDeniedException` | the Runtime uses IAM (SigV4) inbound auth. Its resource policies allow only the relay's, `sweep_task`'s and `chat_target`'s execution roles and explicitly deny the data-plane actions to every other principal, including same-account admins; call it through the relay | | `pip install -e .` fails with `requires a different Python` | the venv was built with a host `python3` that is not the `.python-version` pin; rebuild it as in "Prerequisites" | | `bootstrap_state_backend.sh` refuses `CRM_EXPECTED_ACCOUNT_ID ... is required` or `WRONG ACCOUNT` | set `CRM_EXPECTED_ACCOUNT_ID` (or `--expected-account-id`) to the account the backend belongs in, and pass the profile that resolves to it | @@ -1696,6 +1709,40 @@ Pass the previous `--secret-out` file as `--old-secret-file`. The file, when giv secret. The script exits 2 when the file is unreadable or empty, when the output is empty and no file is given, or when both are present and differ. +#### When the old secret is lost + +If the `cognito_mcp_client_secret` output is empty and no previous `--secret-out` file exists, the +script cannot run. Replace the secret by hand instead. Read the pool and client ids from the +`cognito_user_pool_id` and `cognito_mcp_client_id` outputs: + +1. List the secrets. Exactly one must be active: + `aws cognito-idp list-user-pool-client-secrets --user-pool-id --client-id --profile

--region --no-cli-pager`. + Note its `ClientSecretId`. +2. Add a Cognito-generated secret and write it straight to a `0600` file that does not yet exist, + in a `0700` directory outside any git work tree, so the value is never printed: + + ```bash + ( umask 077 && aws cognito-idp add-user-pool-client-secret --user-pool-id \ + --client-id --profile

--region --no-cli-pager \ + --query ClientSecretDescriptor.ClientSecretValue --output text \ + > ~/.local/state/crm-eval//mcp-client-secret.new ) + ``` + +3. Mint a `client_credentials` token with the new file (the recipe in + [`docs/mcp-client-guide.md`](mcp-client-guide.md)) and expect HTTP 200, retrying for a short while + since a new secret takes time to propagate. If it never mints, list + the secrets again, delete the new one with `delete-user-pool-client-secret`, remove the file, and + stop: the old secret is still active. +4. Delete the old secret: + `aws cognito-idp delete-user-pool-client-secret --user-pool-id --client-id --client-secret-id --profile

--region --no-cli-pager`. +5. Continue from step 2 of the rotation above: the refresh-only apply, `refresh_outputs.sh`, a + mint from the new file, `CRM_MCP_CLIENT_SECRET_FILE`, and a plan with no change to the user pool + client. + +The old secret is lost, so nothing can check that it is now refused. Every external +`client_credentials` client stops working at step 4 until its owner receives the new secret out of +band. + ## Migrate saved supervisor effort `scripts/migrate_supervisor_effort.py` moves every saved per-user supervisor effort of `low` to diff --git a/docs/security-baseline.md b/docs/security-baseline.md index 21252c6..94729be 100644 --- a/docs/security-baseline.md +++ b/docs/security-baseline.md @@ -7,7 +7,7 @@ change ships; `review-PASS` rows are recorded as review findings if absent. This `scripts/check_plan_security_baseline.py --self-check`, which fails when a row has neither a plan-time assertion nor a recorded reason it cannot be one, and by `tests/unit/test_verify_security_baseline.py`. -![AWS network baseline: the adopted VPC with its interface and gateway endpoints, security groups, optional egress-only NAT, flow logs, the Runtime resource policy's SourceVpce deny, KMS keys and CloudTrail; WAF and the viewer TLS 1.2 minimum are deferred](figures/security-baseline-aws-network.svg) +![AWS network baseline: the adopted VPC with its interface and gateway endpoints, security groups, optional egress-only NAT, flow logs, the Runtime resource policy's SourceVpce deny, KMS keys and CloudTrail; the CloudFront security-headers and CSP policy is enforced, while WAF and the viewer TLS 1.2 minimum are deferred](figures/security-baseline-aws-network.svg) | Control | Requirement | Verify | Class | |---|---|---|---| @@ -36,7 +36,50 @@ assertion nor a recorded reason it cannot be one, and by `tests/unit/test_verify | Logs | explicit retention; no secrets, tokens, or full payloads | log-group config + `scripts/check_log_redaction.py` | review-PASS | | Logs | KMS CMK on every log group (`kms_key_id` set, never null) | `check_plan_security_baseline.py --only logs` over the plan; `describe-log-groups \| jq '.logGroups[].kmsKeyId'` | review-PASS | | KMS | key usage, rotation, access policy documented | key policies and `enable_key_rotation` on every `aws_kms_key` under `infra/`, reviewed by hand | review-PASS | -| KMS | logs, CloudTrail, frontend and eval-artefacts CMK policies deny key use to every non-service principal outside the key's allowlist, and key administration to every principal outside `crm_operator_principal_arns` and the account root | `check_plan_security_baseline.py --only store`; Layer 4 smoke `store_principal_deny` | review-PASS | +| KMS | logs, CloudTrail, frontend, eval-artefacts and pagination-cursor CMK policies deny key use to every non-service principal outside the key's allowlist, and key administration to every principal outside `crm_operator_principal_arns` and the account root | `check_plan_security_baseline.py --only store`; Layer 4 smoke `store_principal_deny` | review-PASS | + +## Browser and API trust narrowing + +These controls narrow trust the stack already grants. Each fails closed when misconfigured. + +- **Content-Security-Policy.** Every CloudFront behaviour attaches the frontend module's own + response-headers policy, `aws_cloudfront_response_headers_policy.security_headers` in + `infra/modules/frontend_cdn/cloudfront.tf`. It keeps the managed security headers, with + `X-Frame-Options: DENY`, and adds an enforced (not report-only) CSP. `script-src` allows the site + and the inline theme script in `frontend/index.html` by its `sha256-` hash, which the root module + derives from that file at plan time. `connect-src` allows the site, the regional Cognito user-pool + endpoint and the hosted-UI domain. `'unsafe-inline'` appears only in `style-src`; no directive + allows `'unsafe-eval'`, and `frame-ancestors`, `base-uri` and `object-src` are `'none'`. A + misconfigured CSP makes the browser block the script or request. Plan time: + `tests/unit/test_infra_csp.py` and `tests/unit/test_infra_cdn.py`. +- **Pagination cursors.** `next_cursor` values are opaque and bound to the caller (`src/crm/cursor.py`). + The paginating tools encrypt the DynamoDB page key with AWS KMS under an encryption context naming + the purpose, tenant, rep and operation, so another caller or operation cannot replay or edit it. A + failed check is a `validation_failed` response with `source: cursor`. The key (`aws_kms_key.cursor` + in `infra/main.tf`) is a customer-managed key with rotation enabled. Its policy refuses any use + outside the `crm-cursor` context, and refuses key use and administration to every principal outside + the paginating tools' roles and `crm_operator_principal_arns`. Only those tools' functions carry + `CRM_CURSOR_KMS_KEY_ARN`. A deployed Lambda without it refuses every cursor. +- **API client audience.** On the `apigw` identity channel, `crm.envelope` also requires the + token to be issued to an allowed app client (`aud` on an ID token, `client_id` on an access token). + The allowed client ids come from the SSM parameter named by `CRM_API_ALLOWED_CLIENT_IDS_PARAMETER`, + read once per process. That parameter, `aws_ssm_parameter.api_allowed_client_ids` in `infra/main.tf`, + is a `String` named `//api/allowed-client-ids`, holding the SPA client id. A token from any other client gets `401`. An unset, unreadable or empty + allowlist admits nobody: the request fails as a server error, and neither a failed read nor an empty value is cached. + Unit: `tests/unit/test_envelope.py`. +- **Refresh-token revocation at sign-out.** Every app client has token revocation enabled + (`enable_token_revocation` in `infra/modules/cognito/main.tf`). Signing out of the SPA starts revoking the + refresh token and clears the cached Cognito tokens at once (`frontend/src/auth/CognitoAuthSession.ts`); + a failed revocation is logged to the browser console only, and the sign-out still completes. +- **Free-text length caps.** Every free-text string a tool accepts carries a `maxLength` + (`src/crm/toolspec/definitions.py`): 4000 characters for `description`, `notes`, `body` and `reason`, + 4000 for `cursor`, 1024 for the `revert_audit_record` reason, and 256 for any other string without a + limit of its own (such as `transaction_key`'s 128). The cap is in + the generated input validator and the Gateway tool schemas alike; a longer value is a `validation_failed` + response (`400`). +- **Eval run reads.** `eval_trigger`'s `estimate`, `status`, `list` and `artefact_url` actions need an admin + or full tenant visibility, as starting a stub sweep does; any other caller gets `403` naming the + `eval:trigger` scope (`artefact_url`: `eval:artefacts`). Live sweeps, `cancel` and `unlock` stay admin-only. ## Accepted wildcard and base-table grants diff --git a/frontend/package-lock.json b/frontend/package-lock.json index fa2cfb8..2404c38 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -31,7 +31,7 @@ }, "devDependencies": { "@eslint/js": "10.0.1", - "@tailwindcss/postcss": "4.3.3", + "@tailwindcss/postcss": "4.3.5", "@testing-library/jest-dom": "7.0.1", "@testing-library/react": "16.3.3", "@testing-library/user-event": "14.6.8", @@ -40,23 +40,23 @@ "@types/react": "19.3.0", "@types/react-dom": "19.3.0", "@typescript/native": "npm:typescript@7.0.2", - "@vitejs/plugin-react": "6.1.2", - "@vitest/coverage-v8": "5.0.5", + "@vitejs/plugin-react": "6.2.1", + "@vitest/coverage-v8": "5.1.0", "axe-core": "4.14.0", "esbuild": "0.28.2", - "eslint": "10.13.0", + "eslint": "10.14.0", "eslint-plugin-react-hooks": "7.1.1", "eslint-plugin-react-refresh": "0.5.7", - "globals": "17.13.0", - "jsdom": "30.1.3", + "globals": "17.14.0", + "jsdom": "31.0.0", "json-schema-to-typescript": "16.0.0", "postcss": "8.5.32", - "tailwindcss": "4.3.3", + "tailwindcss": "4.3.5", "tailwindcss-animate": "1.0.7", "typescript": "npm:@typescript/typescript6@6.0.2", "typescript-eslint": "8.72.1", - "vite": "8.3.5", - "vitest": "5.0.5" + "vite": "8.3.6", + "vitest": "5.1.0" }, "engines": { "node": "26.13.0" @@ -100,39 +100,6 @@ "url": "https://github.com/sponsors/philsturgeon" } }, - "node_modules/@asamuzakjp/css-color": { - "version": "7.1.7", - "resolved": "https://registry.npmjs.org/@asamuzakjp/css-color/-/css-color-7.1.7.tgz", - "integrity": "sha512-Q7ioeear07HwixdIitIn9KS1LZi97CEDFCSjPNm9v+y8KNbsu9q4Lrd4zUQW4faED+E7qxvfeVnbNRW46wFKuw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@csstools/css-calc": "^3.4.3", - "@csstools/css-color-parser": "^4.2.6", - "@csstools/css-parser-algorithms": "^4.0.2", - "@csstools/css-tokenizer": "^4.0.2", - "lru-cache": "^11.5.3" - }, - "engines": { - "node": "^22.22.2 || ^24.15.0 || >=26.0.0" - } - }, - "node_modules/@asamuzakjp/dom-selector": { - "version": "10.0.4", - "resolved": "https://registry.npmjs.org/@asamuzakjp/dom-selector/-/dom-selector-10.0.4.tgz", - "integrity": "sha512-A6f1nKy99I6tyoK82U6kBHvQQZmdHmTmPzJYPY/0eaOW0r8/qPmEOwjGHs+hL/vCgOwQTupu4LT1XtXNUuDruA==", - "dev": true, - "license": "MIT", - "dependencies": { - "bidi-js": "^1.1.0", - "css-tree": "^3.2.1", - "is-potential-custom-element-name": "^1.0.1", - "lru-cache": "^11.5.3" - }, - "engines": { - "node": "^22.22.2 || ^24.15.0 || >=26.0.0" - } - }, "node_modules/@aws-crypto/sha256-js": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/@aws-crypto/sha256-js/-/sha256-js-1.2.2.tgz", @@ -459,19 +426,6 @@ "node": ">=18" } }, - "node_modules/@bramus/specificity": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/@bramus/specificity/-/specificity-2.4.3.tgz", - "integrity": "sha512-0GEz8qJWokkUVYQYRukmkSHIFNoBH8QTreeHrAFbvz1XFYc3Y+puhMs8PQ5x8GNugiC2l5jvDBXKLbBIByeSBw==", - "dev": true, - "license": "MIT", - "dependencies": { - "css-tree": "^3.2.1" - }, - "bin": { - "specificity": "bin/cli.js" - } - }, "node_modules/@cacheable/memory": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/@cacheable/memory/-/memory-2.2.0.tgz", @@ -496,146 +450,6 @@ "keyv": "^5.6.0" } }, - "node_modules/@csstools/color-helpers": { - "version": "6.1.2", - "resolved": "https://registry.npmjs.org/@csstools/color-helpers/-/color-helpers-6.1.2.tgz", - "integrity": "sha512-grhRy3OKmniaAEKXMjua5z/EODX0MSqBGjunw8+j/3HQjOnahs2AGhvEOIYVUWcU6ScApbhLhVrQTX8XqrMrow==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/csstools" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - } - ], - "license": "MIT-0", - "engines": { - "node": ">=20.19.0" - } - }, - "node_modules/@csstools/css-calc": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/@csstools/css-calc/-/css-calc-3.4.3.tgz", - "integrity": "sha512-iex20d8CHVkyvg6B7UKV7uHnI2Bqo9g+EFfT9E0y+GvTvhZ/DwONJ+9aKb1dlqm0ZiGsL5RXjp0fCoJYnkeDjA==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/csstools" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - } - ], - "license": "MIT", - "engines": { - "node": ">=20.19.0" - }, - "peerDependencies": { - "@csstools/css-parser-algorithms": "^4.0.2", - "@csstools/css-tokenizer": "^4.0.2" - } - }, - "node_modules/@csstools/css-color-parser": { - "version": "4.2.6", - "resolved": "https://registry.npmjs.org/@csstools/css-color-parser/-/css-color-parser-4.2.6.tgz", - "integrity": "sha512-iiPQ3iRWwnJkeEn6RIu6SJPr7hYrLz6XZ9s/QZl+2/LI5KQVjpl2fdmDSZKuD4xP6GMmMPgHFFXg6k1Wkz0Trg==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/csstools" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - } - ], - "license": "MIT", - "dependencies": { - "@csstools/color-helpers": "^6.1.2", - "@csstools/css-calc": "^3.4.3" - }, - "engines": { - "node": ">=20.19.0" - }, - "peerDependencies": { - "@csstools/css-parser-algorithms": "^4.0.2", - "@csstools/css-tokenizer": "^4.0.2" - } - }, - "node_modules/@csstools/css-parser-algorithms": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/@csstools/css-parser-algorithms/-/css-parser-algorithms-4.0.2.tgz", - "integrity": "sha512-40cSKyMvK+tq4qz6Awrlye2WGuOKt3FwPgtGg6KTfbHOWNw+Rk1rzbAtZnZ6IBhsY491HLRnDXwoyBAijmmILA==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/csstools" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - } - ], - "license": "MIT", - "engines": { - "node": ">=20.19.0" - }, - "peerDependencies": { - "@csstools/css-tokenizer": "^4.0.2" - } - }, - "node_modules/@csstools/css-syntax-patches-for-csstree": { - "version": "1.1.15", - "resolved": "https://registry.npmjs.org/@csstools/css-syntax-patches-for-csstree/-/css-syntax-patches-for-csstree-1.1.15.tgz", - "integrity": "sha512-J0u7HkVl2nzSlhsiTOp4AmwcUQ3D+mGEEKfBy/7To5/y7F2OHwyLrXfrhR0SMgr4p5Lo+eaMVSeai24zUcBIxA==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/csstools" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - } - ], - "license": "MIT-0", - "peerDependencies": { - "css-tree": "^3.2.1" - }, - "peerDependenciesMeta": { - "css-tree": { - "optional": true - } - } - }, - "node_modules/@csstools/css-tokenizer": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/@csstools/css-tokenizer/-/css-tokenizer-4.0.2.tgz", - "integrity": "sha512-OoKoR0f76dCY666JlcbhmVTs2drYj1GUXZTYTcbUgJjh9Nv41aFfZ21bPQTERm5+L5cBDo466NltB2lplS5GBw==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/csstools" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - } - ], - "license": "MIT", - "engines": { - "node": ">=20.19.0" - } - }, "node_modules/@esbuild/aix-ppc64": { "version": "0.28.2", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.2.tgz", @@ -1428,9 +1242,9 @@ "license": "MIT" }, "node_modules/@oxc-project/types": { - "version": "0.154.0", - "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.154.0.tgz", - "integrity": "sha512-KYOUGQFlLWR+s4QMV2Q9ko38TZm7EdO87Qm7rvZLqk/webse/cDjtyxKhg/47l0byCbs/k46LT8qc4PKjAikzA==", + "version": "0.156.0", + "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.156.0.tgz", + "integrity": "sha512-1Duyg48TdJNdyhEB8Xn1L36bT9Pv6GUtlKjHxOys8xkaF/rQq3XJE+bAurSK/AgIz5mGFsb77cn9Pb20+WCScw==", "dev": true, "license": "MIT", "funding": { @@ -2152,9 +1966,9 @@ "license": "MIT" }, "node_modules/@rolldown/binding-android-arm-eabi": { - "version": "1.2.14", - "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.14.tgz", - "integrity": "sha512-aWR+XKH9+rW7m5fWq/5360J3mHycrx/o6xZM2DQFdJnTMdyP7/WzxPjhtLbVWdKo2y612/4U1bWqb3HQhiF7vg==", + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.16.tgz", + "integrity": "sha512-ia3DwAs0OsMGS7+IConptSiyk9pEXkOx/AbJ2n/lAGxH3QkWQus1t8d7gnAT38FCU2sQu8lUbeR6AiZFv4JxaA==", "cpu": [ "arm" ], @@ -2169,9 +1983,9 @@ } }, "node_modules/@rolldown/binding-android-arm64": { - "version": "1.2.14", - "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.14.tgz", - "integrity": "sha512-QiVxHofl6A8lQU7WAtOUY4QMVZXohxwz7WJJoeh8NBEUyKfIkMRKhYyq8az/1RypNiIXzNTtiS6KwHz0erxYRQ==", + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.16.tgz", + "integrity": "sha512-kx5wBiMB6E7TEvpl2B9gjLU004BkvEm2Dr941BFjx/SontPwSzNuQUIoVKxHHoSjpFIfHMmcguyLOtyn0hObRg==", "cpu": [ "arm64" ], @@ -2186,9 +2000,9 @@ } }, "node_modules/@rolldown/binding-darwin-arm64": { - "version": "1.2.14", - "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.14.tgz", - "integrity": "sha512-lTQOzHuBIooh3jIr5XINQkjPGEuGy+Dsy0meXDr6Sjty0b99kYgGh4uBC/8mJX1T0kC8d6S0aPP1Y+bHkh6aBw==", + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.16.tgz", + "integrity": "sha512-qslZrXnKJU4cUpjoAmtAo/KQM9e2IRMlmpig6Zpwj+8KWxW8v+nkAf9216Bsek9lOC1jvg2yCjygCFo2f83msQ==", "cpu": [ "arm64" ], @@ -2203,9 +2017,9 @@ } }, "node_modules/@rolldown/binding-darwin-x64": { - "version": "1.2.14", - "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.14.tgz", - "integrity": "sha512-hyMKEGatjmBYCs/Q4sbIcL/GqpFEqsX3wc+HYVQ/85A4rxc1o7rPm4DUI4GV4k/h0ITddwFSGpqQunI14GXjTA==", + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.16.tgz", + "integrity": "sha512-FdF+y48ND13eAyM2mQn+85kvAqNlvRWROy2rhgA463X/0Gv4vGtazZtfaF1mRBLscYvtOlh4QnLjOWiFzX69OQ==", "cpu": [ "x64" ], @@ -2220,9 +2034,9 @@ } }, "node_modules/@rolldown/binding-freebsd-x64": { - "version": "1.2.14", - "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.14.tgz", - "integrity": "sha512-u371GbXoVXrEgP20PwzoGNOdAOqAMhzo19JzzY+V4YmmnC+DTOoqdbMu+O+54emM59Mik/UdrtWgcuEDKWRPKA==", + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.16.tgz", + "integrity": "sha512-ddjqFM5e95AgLbUPtKIS7V1KTVlA0RUgCVr5mn+/IEhsdy3pr+Vuj/HZ7nlMN2FyxIwUktOH1LEPIQXO1v9y1Q==", "cpu": [ "x64" ], @@ -2237,9 +2051,9 @@ } }, "node_modules/@rolldown/binding-linux-arm-gnueabihf": { - "version": "1.2.14", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.14.tgz", - "integrity": "sha512-BqwKsdZQf6EqVWr8fv2MrDYzAvOZ7+NYFSJESRGs87fkseEhs0TU9TXgRJTkZoRRkxTizyEg1LKUXfU3/78uqg==", + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.16.tgz", + "integrity": "sha512-tHdKWbFkFBI687iim3LIyIvyL7j66VvQYkDPss5Stn/qyE2tWkR1YD0dXmXPFKKqT/o5ZEJVsaRsWS2meQwGOA==", "cpu": [ "arm" ], @@ -2254,9 +2068,9 @@ } }, "node_modules/@rolldown/binding-linux-arm64-gnu": { - "version": "1.2.14", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.14.tgz", - "integrity": "sha512-SD9kY8M009x/7s57Z1dgUVlP5+uYBgKQK0Tkr1WIWngrtUJmRCW1RJFMY7QDla2khXhmg2i5Io7MUjcmZNZ/KQ==", + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.16.tgz", + "integrity": "sha512-FJiLGAblPBMlBEdbOqw6kW6QcXDWAf/oJu7gYs9ZJZwmg+K+/zjFLxPTIY9izJUzxzc24FHvmseyA0IvJSl17w==", "cpu": [ "arm64" ], @@ -2274,9 +2088,9 @@ } }, "node_modules/@rolldown/binding-linux-arm64-musl": { - "version": "1.2.14", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.14.tgz", - "integrity": "sha512-BJ2CL19M6uuWesMgnqJzgxoI+N+eV7b0A9O9vLV42y+gitC41fNa8KElau1tHVzuLWX5GzEuxMPhAO0tQXQMkg==", + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.16.tgz", + "integrity": "sha512-hrJpblMsrQ58U9veWpbXzkhV5zStunds6HWLprqq1qauvgBr1E6P+24kLj6lSLI9vjRn/RYpjprhkHQPKGWpNg==", "cpu": [ "arm64" ], @@ -2294,9 +2108,9 @@ } }, "node_modules/@rolldown/binding-linux-ppc64-gnu": { - "version": "1.2.14", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.14.tgz", - "integrity": "sha512-4+Kl8daPV8NDHaD7mfCcc1pRM+Qg7ab8DyMm5FG5WoZgv4h2i3KFN1CybYBNbQqmuYm7ftJLvmMI1eHYJ22S/Q==", + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.16.tgz", + "integrity": "sha512-qJd/dC6j6CwLG9/s/RP2nb1RZ0GIgj7Ioj7x/SYa3RzjVrlzrmH0fhIOpfvqQDeIsdP0loi+kHaMhJzY1PBIaA==", "cpu": [ "ppc64" ], @@ -2314,9 +2128,9 @@ } }, "node_modules/@rolldown/binding-linux-s390x-gnu": { - "version": "1.2.14", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.14.tgz", - "integrity": "sha512-V/h8ePq1fKDrmtFMz6xcCN3DKvuvMRrwwD1q0PkBeeo4DpK64biaKvqWGVxqCeYKqeRk7gE7/iKPxLCn08O97A==", + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.16.tgz", + "integrity": "sha512-Vx7Xg5uUJuNcujJjI70OICaH0EYj80BtOLZTSN7uOYg8QOLlyKnaG0IW7Fn/J0IpJsaKzmDKMhOQv1JBM9m9vg==", "cpu": [ "s390x" ], @@ -2334,9 +2148,9 @@ } }, "node_modules/@rolldown/binding-linux-x64-gnu": { - "version": "1.2.14", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.14.tgz", - "integrity": "sha512-WxalXzgrLVpKC93xfpaJ3gCXUWzeCr+FRCbDVD2mUAy4L6Vo3lNVz0epUEUpxPWJkLNYUwM4OSIikv36OJ9mLg==", + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.16.tgz", + "integrity": "sha512-TNKhgE3uJTsTzatUSSYt0Kgo+Oa2uSlSjz4r1aEIea7HX6ULBym4fAlYUhG1i6pjNf2njfCUAfKwr6C3E9Xg1w==", "cpu": [ "x64" ], @@ -2354,9 +2168,9 @@ } }, "node_modules/@rolldown/binding-linux-x64-musl": { - "version": "1.2.14", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.14.tgz", - "integrity": "sha512-3G3tnAmTpdk9jO3GQtyHXqeFD2SlecfTws/Y3M2mmj9nMBwwuLT4kur8sZKeu7ENUHSpVO3cIsm5A52LEWWwlg==", + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.16.tgz", + "integrity": "sha512-7chXdpjXZ8qG0+mIxECN3cT9kvhZ3/oZhMX6Pp876P7CDrIy8nJswva6Mq357JR7eYXfuskwZxMeV1SzoZdHrA==", "cpu": [ "x64" ], @@ -2374,9 +2188,9 @@ } }, "node_modules/@rolldown/binding-openharmony-arm64": { - "version": "1.2.14", - "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.14.tgz", - "integrity": "sha512-qyr5XiNGxm2ytx17vvtcJ9nXn6v1gENETi503bJx3OGwZ1tSonj7BosxbMa/xeAfSl5iS9X6KjEWYXLu6v1L7Q==", + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.16.tgz", + "integrity": "sha512-Kwjt+7uNTJK5/MDkGWGVO2KQPnj8yAV75dMpfwyHZrJSXWHrniOB0aUEWlVYf3H1hOqFLIStLdM5QXq6bnKmOQ==", "cpu": [ "arm64" ], @@ -2391,9 +2205,9 @@ } }, "node_modules/@rolldown/binding-win32-arm64-msvc": { - "version": "1.2.14", - "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.14.tgz", - "integrity": "sha512-oA4o5o0S2yB199YyYXDzKUv1Z56Rc+mgOjwm7Z/vJ9Z8igiDPYvoOuDyo6g7AK/ZaF09nPhDKVnGBcYHO11GXA==", + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.16.tgz", + "integrity": "sha512-/LH6WfjDRXXJz/p5xl4TmU+jpcnwcxbKEQBW/GZE0JHfN0lGIyTtsUEGaQ/q/GikkGJ2yLKe6pwm7AnEWO8pdw==", "cpu": [ "arm64" ], @@ -2408,9 +2222,9 @@ } }, "node_modules/@rolldown/binding-win32-x64-msvc": { - "version": "1.2.14", - "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.14.tgz", - "integrity": "sha512-9mE94bf2GZUaR/fUSXCMpBoWkctu421Mi0ORpm4zqfbkjKep7RxzPFa5etcGs5h+2KApoWBOA/hAJa/7saGgEQ==", + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.16.tgz", + "integrity": "sha512-1lv1KvX0Z871zfk7vw+dnXMMnHNyDwMzWG8Kv3HxDXMOhzCX4SHc7HK319fInP0i+0p9D8brkfzL7pJOaGl+tw==", "cpu": [ "x64" ], @@ -2450,49 +2264,49 @@ "license": "0BSD" }, "node_modules/@tailwindcss/node": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/@tailwindcss/node/-/node-4.3.3.tgz", - "integrity": "sha512-/T8IKEsf9VTU6tLjgC7+sv2mOPtQxzE2jMw7u4Tt40Tx+QSZxpzh95/H6cMKoja9XuW7iMdLJYBB0o9G1CaAgg==", + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/@tailwindcss/node/-/node-4.3.5.tgz", + "integrity": "sha512-yT53FzV4ke0cr/BguDxhWMpm5MJu1O2muzk+tKw6lKHjODAsYArBbWwFbJiaksfzFv1tpkO9QHGzmfs1hJT66g==", "dev": true, "license": "MIT", "dependencies": { "@jridgewell/remapping": "^2.3.5", - "enhanced-resolve": "^5.24.1", + "enhanced-resolve": "^5.24.5", "jiti": "^2.7.0", - "lightningcss": "1.32.0", - "magic-string": "^0.30.21", + "lightningcss": "1.33.0", + "magic-string": "^1.1.0", "source-map-js": "^1.2.1", - "tailwindcss": "4.3.3" + "tailwindcss": "4.3.5" } }, "node_modules/@tailwindcss/oxide": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/@tailwindcss/oxide/-/oxide-4.3.3.tgz", - "integrity": "sha512-krXjAikiaFSPaK/FkAQT5UTx3VormQaiZ5hBFlJZ9UFQGB/rwg1MZIhHAG9smMQRTdyJxP6Qt5MwMtdyU5FWrA==", + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide/-/oxide-4.3.5.tgz", + "integrity": "sha512-PynqGLZsZvwM9tqD/CUxkOIfyd6K5elZ2MooauzJryP/UqXYgi3yYbtt3N0Xe+MHV/eFKPFQCEfIKAqlAS1CBg==", "dev": true, "license": "MIT", "engines": { "node": ">= 20" }, "optionalDependencies": { - "@tailwindcss/oxide-android-arm64": "4.3.3", - "@tailwindcss/oxide-darwin-arm64": "4.3.3", - "@tailwindcss/oxide-darwin-x64": "4.3.3", - "@tailwindcss/oxide-freebsd-x64": "4.3.3", - "@tailwindcss/oxide-linux-arm-gnueabihf": "4.3.3", - "@tailwindcss/oxide-linux-arm64-gnu": "4.3.3", - "@tailwindcss/oxide-linux-arm64-musl": "4.3.3", - "@tailwindcss/oxide-linux-x64-gnu": "4.3.3", - "@tailwindcss/oxide-linux-x64-musl": "4.3.3", - "@tailwindcss/oxide-wasm32-wasi": "4.3.3", - "@tailwindcss/oxide-win32-arm64-msvc": "4.3.3", - "@tailwindcss/oxide-win32-x64-msvc": "4.3.3" + "@tailwindcss/oxide-android-arm64": "4.3.5", + "@tailwindcss/oxide-darwin-arm64": "4.3.5", + "@tailwindcss/oxide-darwin-x64": "4.3.5", + "@tailwindcss/oxide-freebsd-x64": "4.3.5", + "@tailwindcss/oxide-linux-arm-gnueabihf": "4.3.5", + "@tailwindcss/oxide-linux-arm64-gnu": "4.3.5", + "@tailwindcss/oxide-linux-arm64-musl": "4.3.5", + "@tailwindcss/oxide-linux-x64-gnu": "4.3.5", + "@tailwindcss/oxide-linux-x64-musl": "4.3.5", + "@tailwindcss/oxide-wasm32-wasi": "4.3.5", + "@tailwindcss/oxide-win32-arm64-msvc": "4.3.5", + "@tailwindcss/oxide-win32-x64-msvc": "4.3.5" } }, "node_modules/@tailwindcss/oxide-android-arm64": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-android-arm64/-/oxide-android-arm64-4.3.3.tgz", - "integrity": "sha512-Y85A2gmPSkl5Ve5qR86GL4HT509cFqQh1aes9p3sSkyTPwt0Pppf3GkwGe4JPACcRYjgJIEhQgM6dBClnr0NYw==", + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-android-arm64/-/oxide-android-arm64-4.3.5.tgz", + "integrity": "sha512-Se0z5xMqcSQanJD1IYmO0cGpK3iv0fp3ZsIT7xRJZ1Da5PghvNoc46zz4jIQn+aan3dV9T8AermFNN9QPmsh0Q==", "cpu": [ "arm64" ], @@ -2507,9 +2321,9 @@ } }, "node_modules/@tailwindcss/oxide-darwin-arm64": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-arm64/-/oxide-darwin-arm64-4.3.3.tgz", - "integrity": "sha512-BiaWatpBcERQFDlOjRDpIVXuFK5PJez5SA4JMg6VYZdBYU+qKfV/vqjcIs+IYmtitf1xYQZTwXvU/8y4lfZUGw==", + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-arm64/-/oxide-darwin-arm64-4.3.5.tgz", + "integrity": "sha512-UPrgTDuUbvmqGMZuCnmI3FKee/tYKzKdp00/kuB4oSGB213VYg8QTdF7lVhnPoBXq/mIfJ+ILoBFqNOboWcMwQ==", "cpu": [ "arm64" ], @@ -2524,9 +2338,9 @@ } }, "node_modules/@tailwindcss/oxide-darwin-x64": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-x64/-/oxide-darwin-x64-4.3.3.tgz", - "integrity": "sha512-fAeUqfV5ndhxRwai8cXGzdLvul9utWOmeTkv69unv4ZXixjn61Z+p9lCWdwOwA3TYboG3BwdVuN/RDjhBRl0mw==", + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-x64/-/oxide-darwin-x64-4.3.5.tgz", + "integrity": "sha512-E+p7HEtjI0b8D7kbbWxH067cGui6d4c79COGko9fAPVE3rwc1E7ld2HFCbaG86AOGWS5VKQYqZOaf38ya4uxTQ==", "cpu": [ "x64" ], @@ -2541,9 +2355,9 @@ } }, "node_modules/@tailwindcss/oxide-freebsd-x64": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-freebsd-x64/-/oxide-freebsd-x64-4.3.3.tgz", - "integrity": "sha512-iyf5bV6+wnAlflVeEy7R25dupxTNECZN5QMI0qNT6eT+EgaGdZcKhGkr5SdoaWiLJ3spLqIY9VCeSGrwmtg4kw==", + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-freebsd-x64/-/oxide-freebsd-x64-4.3.5.tgz", + "integrity": "sha512-yWEWcWyAG7rWOcTpJTjdhQ3pcaFY2h+0bqTRfgU3G2fz87ZU3AKdvdZKhslD+kyHnjBUWKvNdRYwIYC5dI1tIg==", "cpu": [ "x64" ], @@ -2558,9 +2372,9 @@ } }, "node_modules/@tailwindcss/oxide-linux-arm-gnueabihf": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm-gnueabihf/-/oxide-linux-arm-gnueabihf-4.3.3.tgz", - "integrity": "sha512-aAYUprJAJQWWbRrPvtjdroZ56Md+JM8pMiopS6xGEwDfLhqj+2ver2p4nU4Mb3CRqcMmNBjo8KkUgcxhkzVQGQ==", + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm-gnueabihf/-/oxide-linux-arm-gnueabihf-4.3.5.tgz", + "integrity": "sha512-WmeVjtJhZlr+smpqcdR2kQkkn6arHIJnUIBxTO2EJcTLGY1ecVXNo2hbSn8xc0IH2aEtys936iMWKGyj0GaKnA==", "cpu": [ "arm" ], @@ -2575,9 +2389,9 @@ } }, "node_modules/@tailwindcss/oxide-linux-arm64-gnu": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm64-gnu/-/oxide-linux-arm64-gnu-4.3.3.tgz", - "integrity": "sha512-nDxldcEENOxZRzC2uu9jrutZdAAQtb+8WWDCSnWL1zvBk1+FN+x6MtDViPB5AJMfttVCUhehGWus3XBPgatM/w==", + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm64-gnu/-/oxide-linux-arm64-gnu-4.3.5.tgz", + "integrity": "sha512-DTCSyucc6ShMp1QMqV5R94Z7xlgNgUzkGmFF1rL5HH2Qjy4eSmEqy+YLGkqqYvWa4sILtgrBt1JjRKbneQtiFQ==", "cpu": [ "arm64" ], @@ -2595,9 +2409,9 @@ } }, "node_modules/@tailwindcss/oxide-linux-arm64-musl": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm64-musl/-/oxide-linux-arm64-musl-4.3.3.tgz", - "integrity": "sha512-Md44bD6veX/PC5iyF8cDVnw4HBIANZepRZZ7a8DQOvkfo5WUBwcp6iAuCUz23u+4SUkhJlD3eL7hNdW8ezd/kA==", + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm64-musl/-/oxide-linux-arm64-musl-4.3.5.tgz", + "integrity": "sha512-H9lsvO4x9E4nE4Hi8h7NHHw0O/kcVSu+iOyFHNGdYzazGgDjFHZbE6S3hQ8kMcbNXSBlMdNi67LV5EVqtpaJtw==", "cpu": [ "arm64" ], @@ -2615,9 +2429,9 @@ } }, "node_modules/@tailwindcss/oxide-linux-x64-gnu": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-x64-gnu/-/oxide-linux-x64-gnu-4.3.3.tgz", - "integrity": "sha512-tx7us1muwOKAKWao2v/GaafFeQboE6aj88vC6ziN2NCGcRm8gWUhwjzg+YdVB1e4boAtdtma4L43onunI6NS4w==", + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-x64-gnu/-/oxide-linux-x64-gnu-4.3.5.tgz", + "integrity": "sha512-4uxQvtBvPuIdl13WfUBj9xMZHH14PtHZ8OZdtLmdyDtG66sCa1t599NZT+jagkUzRtWhuul1qRZQ1nAJscXN5g==", "cpu": [ "x64" ], @@ -2635,9 +2449,9 @@ } }, "node_modules/@tailwindcss/oxide-linux-x64-musl": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-x64-musl/-/oxide-linux-x64-musl-4.3.3.tgz", - "integrity": "sha512-SJxX60smvHgasZoBy11dX6YRjXJFovwWBoedhbQPOBzgFWBHGB+TVPWB9BxzR7TTxU8FQZAI2AyiNCMzFm8Img==", + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-x64-musl/-/oxide-linux-x64-musl-4.3.5.tgz", + "integrity": "sha512-0JQAzs7jwbA7O6+z/adU+Jk3AXwsu3npAhtr5escXS7TqEqWcaDV7qHuI+0Vy/KQRuVGnLQREcSJWYauyV3oqg==", "cpu": [ "x64" ], @@ -2655,9 +2469,9 @@ } }, "node_modules/@tailwindcss/oxide-wasm32-wasi": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-wasm32-wasi/-/oxide-wasm32-wasi-4.3.3.tgz", - "integrity": "sha512-jx1+rPhY/5Ympkktd656HBWEBLxP7dH06losBLjjf5vgCODXvi9KhtftWcMIwTFIDqBr7cRnQkdLnAG+IOlGvQ==", + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-wasm32-wasi/-/oxide-wasm32-wasi-4.3.5.tgz", + "integrity": "sha512-OJhFmlEfdzMr+avACdi40RPtnkW0B6hXyxL/8r+tnEHBWZji36CYRjEXrrvgBmaYsD3oEOBqwYFRKsYvzFe7Bw==", "bundleDependencies": [ "@napi-rs/wasm-runtime", "@emnapi/core", @@ -2666,37 +2480,34 @@ "@emnapi/wasi-threads", "tslib" ], - "cpu": [ - "wasm32" - ], "dev": true, "license": "MIT", "optional": true, "dependencies": { - "@emnapi/core": "^1.11.1", - "@emnapi/runtime": "^1.11.1", - "@emnapi/wasi-threads": "^1.2.2", - "@napi-rs/wasm-runtime": "^1.1.4", - "@tybys/wasm-util": "^0.10.2", + "@emnapi/core": "^1.11.3", + "@emnapi/runtime": "^1.11.3", + "@emnapi/wasi-threads": "^1.2.3", + "@napi-rs/wasm-runtime": "^1.2.2", + "@tybys/wasm-util": "^0.10.3", "tslib": "^2.8.1" }, "engines": { - "node": ">=14.0.0" + "node": "^20.19.0 || ^22.13.0 || >=23.5.0" } }, "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@emnapi/core": { - "version": "1.11.1", + "version": "1.11.3", "dev": true, "inBundle": true, "license": "MIT", "optional": true, "dependencies": { - "@emnapi/wasi-threads": "1.2.2", + "@emnapi/wasi-threads": "1.2.3", "tslib": "^2.4.0" } }, "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@emnapi/runtime": { - "version": "1.11.1", + "version": "1.11.3", "dev": true, "inBundle": true, "license": "MIT", @@ -2706,7 +2517,7 @@ } }, "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@emnapi/wasi-threads": { - "version": "1.2.2", + "version": "1.2.3", "dev": true, "inBundle": true, "license": "MIT", @@ -2716,25 +2527,28 @@ } }, "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@napi-rs/wasm-runtime": { - "version": "1.1.4", + "version": "1.2.2", "dev": true, "inBundle": true, "license": "MIT", "optional": true, "dependencies": { - "@tybys/wasm-util": "^0.10.1" + "@tybys/wasm-util": "^0.10.3" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=23.5.0" }, "funding": { "type": "github", "url": "https://github.com/sponsors/Brooooooklyn" }, "peerDependencies": { - "@emnapi/core": "^1.7.1", - "@emnapi/runtime": "^1.7.1" + "@emnapi/core": "^1.7.1 || ^2.0.0-alpha.3", + "@emnapi/runtime": "^1.7.1 || ^2.0.0-alpha.3" } }, "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@tybys/wasm-util": { - "version": "0.10.2", + "version": "0.10.3", "dev": true, "inBundle": true, "license": "MIT", @@ -2751,9 +2565,9 @@ "optional": true }, "node_modules/@tailwindcss/oxide-win32-arm64-msvc": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-arm64-msvc/-/oxide-win32-arm64-msvc-4.3.3.tgz", - "integrity": "sha512-3rc292Ca2ceK6Ulcc/bAVnTs/3nDtoPhyEKlgPv+yQJQi/JS/AMJlqzxvlDacL1nekbrcf6bTqp/jV4qgnPxNQ==", + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-arm64-msvc/-/oxide-win32-arm64-msvc-4.3.5.tgz", + "integrity": "sha512-9o8jgthi+QE5eandnboiJT64VQfnIArfZzSTdgbhEK5aafdiu2jTW9Honi/mwYHxBZuH1vAC57IFyrh+0iK5Gg==", "cpu": [ "arm64" ], @@ -2768,9 +2582,9 @@ } }, "node_modules/@tailwindcss/oxide-win32-x64-msvc": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-x64-msvc/-/oxide-win32-x64-msvc-4.3.3.tgz", - "integrity": "sha512-yJ0pwIVc/nYeGoV02WtsN8KYyLQv7kyI2wDnkezyJlGGjkd4QLwDGAwl47YpPJeuI0M0ObaXGSPjvWDPeTPggw==", + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-x64-msvc/-/oxide-win32-x64-msvc-4.3.5.tgz", + "integrity": "sha512-XiKFfIy1RWe7qK4WqByxNW7Oz1/nkOy8o/BWhHminyV1PmpUd8Eedj5v2A8h2kpqeVlz6xRnwk9Fr/ZXNLcZfg==", "cpu": [ "x64" ], @@ -2785,17 +2599,17 @@ } }, "node_modules/@tailwindcss/postcss": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/@tailwindcss/postcss/-/postcss-4.3.3.tgz", - "integrity": "sha512-JTSZZGQi1AyKirbLN3azmjVzef92tcX7h+iSqPdaeStyFpGpDlKvvpxeOE8njhbUanbRwr3z8DyzhICWnMtQeg==", + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/@tailwindcss/postcss/-/postcss-4.3.5.tgz", + "integrity": "sha512-FAV37Tlx9wBiT/hkfgVD0Q6CWsP2oUX3lf28nrfjW8+ksILjnpuFulUqWDfNR4/ZiEHHDRBX8DUTzD1Rys687A==", "dev": true, "license": "MIT", "dependencies": { "@alloc/quick-lru": "^5.2.0", - "@tailwindcss/node": "4.3.3", - "@tailwindcss/oxide": "4.3.3", - "postcss": "^8.5.16", - "tailwindcss": "4.3.3" + "@tailwindcss/node": "4.3.5", + "@tailwindcss/oxide": "4.3.5", + "postcss": "^8.5.25", + "tailwindcss": "4.3.5" } }, "node_modules/@testing-library/dom": { @@ -3688,9 +3502,9 @@ "license": "ISC" }, "node_modules/@vitejs/plugin-react": { - "version": "6.1.2", - "resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-6.1.2.tgz", - "integrity": "sha512-fhJNGUdscQa4HkI0xFxwonWyhnVReCPDbXI7FH7jmzpnVCrFQI7PRrhWecO263610vOrs9tr2Y4xcf8uAdFxbw==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-6.2.1.tgz", + "integrity": "sha512-9KyWCij3r0+qLG3Q62vBmv0VyevmYibAtxaCIVK9o0k6CXgaajZRIe8tpfchQcdZArJ5b/7OrIz4W3b2uxVRDA==", "dev": true, "license": "MIT", "dependencies": { @@ -3700,9 +3514,9 @@ "node": "^20.19.0 || >=22.12.0" }, "peerDependencies": { - "@rolldown/plugin-babel": "^0.1.7 || ^0.2.0", + "@rolldown/plugin-babel": "^0.1.7 || ^0.2.0 || ^0.3.0", "babel-plugin-react-compiler": "^1.0.0", - "oxc-transform-react": "^0.152.0", + "oxc-transform-react": ">=0.152.0 <0.157.0", "vite": "^8.0.0" }, "peerDependenciesMeta": { @@ -3718,15 +3532,15 @@ } }, "node_modules/@vitest/coverage-v8": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-5.0.5.tgz", - "integrity": "sha512-4KpkGdIrSqBihx/JyP/e+S+IKB98etg1XDQiLAxksLfcShnwi1VReGeOT9NI43hLHbknosKp/1CCLn9Zgcs8mg==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-5.1.0.tgz", + "integrity": "sha512-OY9aShBQG5KOIw2zCo9fDoCHI9RHliNHJ//nM7m6jGg41Hyke9JOGWmeMlK74xYErsxMoK8mIB3gAeEyFVA7LA==", "dev": true, "license": "MIT", "dependencies": { "@bcoe/v8-coverage": "^1.0.2", - "@vitest/istanbul-lib-coverage": "^1.0.2", - "@vitest/istanbul-lib-report": "^1.0.2", + "@vitest/istanbul-lib-coverage": "^2.1.0", + "@vitest/istanbul-lib-report": "^2.1.0", "ast-v8-to-istanbul": "^1.0.7", "magicast": "^0.5.5", "obug": "^3.0.0", @@ -3737,8 +3551,8 @@ "url": "https://opencollective.com/vitest" }, "peerDependencies": { - "@vitest/browser": "5.0.5", - "vitest": "5.0.5" + "@vitest/browser": "5.1.0", + "vitest": "5.1.0" }, "peerDependenciesMeta": { "@vitest/browser": { @@ -3747,9 +3561,9 @@ } }, "node_modules/@vitest/istanbul-lib-coverage": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@vitest/istanbul-lib-coverage/-/istanbul-lib-coverage-1.0.2.tgz", - "integrity": "sha512-9J/JMwOf9AoJhAywhrn7ScKTL38hsWQP/qPG60OtaAFcQ5OXPwKsxZFlbnuCKmZ61m8/lGgHYnFpdyQZUvG/iA==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@vitest/istanbul-lib-coverage/-/istanbul-lib-coverage-2.1.0.tgz", + "integrity": "sha512-WOjuS+xcjSIy7ruYBQ+9BUcV7XZQ0FyVcbWbWxW9TRx/kLGx5SQaeFRIFDJxjNplb6YsT7SpKo2zuXXUo91OIQ==", "dev": true, "license": "MIT", "engines": { @@ -3757,27 +3571,27 @@ } }, "node_modules/@vitest/istanbul-lib-report": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@vitest/istanbul-lib-report/-/istanbul-lib-report-1.0.2.tgz", - "integrity": "sha512-gUsfXZJbzPamoIY5TvHFiMMoXESBrUMo+xqaj+rYrWI69+EnvRlYBlP96ZnHPY4vX8kyUpgAnFUCg5wZG/HkDQ==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@vitest/istanbul-lib-report/-/istanbul-lib-report-2.1.0.tgz", + "integrity": "sha512-+ZFta25nWtGCOBG9/IET8w1RO5Oawsd6H8Uf6AJ9EA/StFuKVtKAEJEJ6uRt84OH+T4YkI0ASmIHAhRA+0KVxw==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/istanbul-lib-coverage": "1.0.2" + "@vitest/istanbul-lib-coverage": "2.1.0" }, "engines": { "node": ">=22" } }, "node_modules/@vitest/mocker": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-5.0.5.tgz", - "integrity": "sha512-xLL3lkDegJZw+MGoGaCCsFayDZthGgpAtr3Vziyfc4p7xH89K7KRPcRBBh/kEYm0Aqkt5DtTmkYpBtRV/FrHZg==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-5.1.0.tgz", + "integrity": "sha512-5umB9/jlWcqVS6fsrFmv5Gdnpu6wAUio/lEOwAmvB7v+lFo/IW2B9FhAD0p19GCULTgMzLCdUmuCDCnAzWgppQ==", "dev": true, "license": "MIT", "dependencies": { "@jridgewell/trace-mapping": "0.3.31", - "@vitest/spy": "5.0.5", + "@vitest/spy": "5.1.0", "estree-walker": "^3.0.3", "magic-string": "^1.4.3" }, @@ -3797,20 +3611,10 @@ } } }, - "node_modules/@vitest/mocker/node_modules/magic-string": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-1.4.3.tgz", - "integrity": "sha512-z12OxmaPGE0F4xlpGdjuAUckipLpQlTAuAmyGhNoD7ODpYUzvDfvtxUbjM/jwznyP178oju/KDdyi220wNJ0RQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/sourcemap-codec": "^1.6.0" - } - }, "node_modules/@vitest/spy": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-5.0.5.tgz", - "integrity": "sha512-lwJRExuH417257Q5wv9QYugN9IMJkoxcrKrYxGPQkBzl7wlNpTUxD/5yNX4ESKVUIShKPgkGchYPFMWOOk0wzw==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-5.1.0.tgz", + "integrity": "sha512-2DPO5OMHWKrBngC+fCmTQqemNF0gidRhp3lxbBmRhW+M1XJrfgPpqNqWVevXtn2f2ufD5ZaR1B6B641aAlcX5A==", "dev": true, "license": "MIT", "funding": { @@ -4008,14 +3812,31 @@ "node": ">=6.0.0" } }, - "node_modules/bidi-js": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/bidi-js/-/bidi-js-1.1.0.tgz", - "integrity": "sha512-fX1Onk0tdVPC7obPWB5EbJ1z7NVhLq4m2xZLq2YXBkxzMXIGRpNMU88n0EPgWseKl12J7zXs7qrDxPK4sRs2fg==", + "node_modules/bcp-47": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/bcp-47/-/bcp-47-2.1.2.tgz", + "integrity": "sha512-wsv86UuNFuPnVieKLyECTT+CP1WSAHeoIg5P3xu2kA9Z+7fVPoKt7dxzSeEhtJel0AI+NW3fIW3KtTKQKUCngg==", "dev": true, "license": "MIT", "dependencies": { - "require-from-string": "^2.0.2" + "is-alphabetical": "^2.0.0", + "is-alphanumerical": "^2.0.0", + "is-decimal": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/bcp-47-match": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/bcp-47-match/-/bcp-47-match-2.0.3.tgz", + "integrity": "sha512-JtTezzbAibu8G0R9op9zb3vcWZd9JF6M0xOYGPn0fNCd7wOpRB1mU2mH9T8gaBGbAAyIIVgB2G7xG0GP98zMAQ==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" } }, "node_modules/brace-expansion": { @@ -4253,20 +4074,6 @@ "node": ">= 8" } }, - "node_modules/css-tree": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-3.2.1.tgz", - "integrity": "sha512-X7sjQzceUhu1u7Y/ylrRZFU2FS6LRiFVp6rKLPg23y3x3c3DOKAwuXGDp+PAGjh6CSnCjYeAul8pcT8bAl+lSA==", - "dev": true, - "license": "MIT", - "dependencies": { - "mdn-data": "2.27.1", - "source-map-js": "^1.2.1" - }, - "engines": { - "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0" - } - }, "node_modules/css.escape": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/css.escape/-/css.escape-1.5.1.tgz", @@ -4392,9 +4199,9 @@ "license": "ISC" }, "node_modules/enhanced-resolve": { - "version": "5.26.0", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.26.0.tgz", - "integrity": "sha512-9vhedylFonb2YGogzUKX6+Ja72gOJbN1QHAqdrvqLwhdl/QWbKopzoUC9EbQNVsAns/bx/4uyqalrQAoy1IByw==", + "version": "5.26.1", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.26.1.tgz", + "integrity": "sha512-PPnnSJq3azKOIewXR/uppBV/6h98dprBJ/WaQ9Qgj10xX1lJLNfg+XShpbsrSqcDSy2yYYyhfXM1wWhftqgyzw==", "dev": true, "license": "MIT", "dependencies": { @@ -4406,9 +4213,9 @@ } }, "node_modules/entities": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-8.1.0.tgz", - "integrity": "sha512-kxL7msIffSuh9aaFAMD7rxAIuTRMAHMeBtgHW2yUdWw732ZNh4MehkF2gdjvtdmikkaIP9bFDDJOPlsvm7avrA==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-9.0.0.tgz", + "integrity": "sha512-oJFNDJg3kTPwAD1cNn2+WmUq4wFoo09npc3Ydf1D7ED4smRiWrsKnaLxykrTWgyGEcusc87P5dxlAleol9kpkg==", "dev": true, "license": "BSD-2-Clause", "engines": { @@ -4491,9 +4298,9 @@ } }, "node_modules/eslint": { - "version": "10.13.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-10.13.0.tgz", - "integrity": "sha512-UohDjD4zSzEwhf58M3O7vc/ycc8O1I7dNlhtD0WxE8Px8EHNJKtUwzBqrzeGhisRuv2ag4sAYswszCJRgKXYUg==", + "version": "10.14.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-10.14.0.tgz", + "integrity": "sha512-T0pNsxkb9IKmtQjhpK3d7nWOpFv+YHuMbTJnSVMoQblF0onvXfErrtp4V1jHtsQPan7dKaGVD0q1WCXnzMF31A==", "dev": true, "license": "MIT", "workspaces": [ @@ -4506,7 +4313,7 @@ "@eslint/config-helpers": "^0.7.0", "@eslint/core": "^1.2.1", "@eslint/plugin-kit": "^0.7.3", - "@humanfs/node": "^0.16.6", + "@humanfs/node": "^0.16.8", "@humanwhocodes/module-importer": "^1.0.1", "@humanwhocodes/retry": "^0.4.2", "@types/estree": "^1.0.6", @@ -4527,7 +4334,7 @@ "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", "json-stable-stringify-without-jsonify": "^1.0.1", - "minimatch": "^10.2.5", + "minimatch": "^10.2.6", "natural-compare": "^1.4.0", "optionator": "^0.9.3" }, @@ -4850,9 +4657,9 @@ } }, "node_modules/globals": { - "version": "17.13.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-17.13.0.tgz", - "integrity": "sha512-RwMTC61u7hrG3ZJMkZQOK4JLJrKS8QtoTii63EmWvFXHqycY9FObBJQCbsLxSO8kjKhWE5kV1GC+Vb1g3RI0Zg==", + "version": "17.14.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-17.14.0.tgz", + "integrity": "sha512-UtdkTVyAJePQv0J2M9Xe4L0ruNSDV314XiIJsADI2Zf40bcdAonE/D/OhAU8AT99oij9mhLByb+NvA3QWZYgCg==", "dev": true, "license": "MIT", "engines": { @@ -5181,41 +4988,39 @@ } }, "node_modules/jsdom": { - "version": "30.1.3", - "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-30.1.3.tgz", - "integrity": "sha512-hQMUPvRgN7KxsfIytDQji7bimuJeRQa6Qo5+iuiZQk5CafeRxLIA10/cG5YCBFNpD9RO3oqIiN4CO1Y44kxqXg==", + "version": "31.0.0", + "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-31.0.0.tgz", + "integrity": "sha512-xAkhD9z1eyFC5+QUi9K24CaZJgdCQ2GOGLW1GdVDoQvkp/AxEH9TQ0pAplPOlIiV92hfcgnFOADZypbjgbBT6Q==", "dev": true, "license": "MIT", "dependencies": { - "@asamuzakjp/css-color": "^7.1.3", - "@asamuzakjp/dom-selector": "^10.0.3", - "@bramus/specificity": "^2.4.2", - "@csstools/css-syntax-patches-for-csstree": "^1.1.15", "@exodus/bytes": "^1.16.0", - "css-tree": "^3.2.1", + "bcp-47": "^2.1.2", + "bcp-47-match": "^2.0.3", "data-urls": "^8.0.0", "decimal.js": "^10.6.0", "html-encoding-sniffer": "^7.0.0", "is-potential-custom-element-name": "^1.0.1", "lru-cache": "^11.5.3", - "parse5": "^8.0.1", + "parse5": "^8.1.0", + "parse5-parser-stream": "^8.1.0", "saxes": "^6.0.0", "tough-cookie": "^6.0.2", - "undici": "^8.12.1", + "undici": "^8.12.3", "w3c-xmlserializer": "^6.0.0", "webidl-conversions": "^8.0.1", "whatwg-mimetype": "^5.0.0", - "whatwg-url": "^17.2.0", + "whatwg-url": "^17.3.0", "xml-name-validator": "^5.0.0" }, "engines": { "node": "^22.22.2 || ^24.15.0 || >=26.0.0" }, "peerDependencies": { - "canvas": "^3.2.3" + "@napi-rs/canvas": "^1.0.13" }, "peerDependenciesMeta": { - "canvas": { + "@napi-rs/canvas": { "optional": true } } @@ -5357,9 +5162,9 @@ } }, "node_modules/lightningcss": { - "version": "1.32.0", - "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.32.0.tgz", - "integrity": "sha512-NXYBzinNrblfraPGyrbPoD19C1h9lfI/1mzgWYvXUTe414Gz/X1FD2XBZSZM7rRTrMA8JL3OtAaGifrIKhQ5yQ==", + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.33.0.tgz", + "integrity": "sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==", "dev": true, "license": "MPL-2.0", "dependencies": { @@ -5373,23 +5178,23 @@ "url": "https://opencollective.com/parcel" }, "optionalDependencies": { - "lightningcss-android-arm64": "1.32.0", - "lightningcss-darwin-arm64": "1.32.0", - "lightningcss-darwin-x64": "1.32.0", - "lightningcss-freebsd-x64": "1.32.0", - "lightningcss-linux-arm-gnueabihf": "1.32.0", - "lightningcss-linux-arm64-gnu": "1.32.0", - "lightningcss-linux-arm64-musl": "1.32.0", - "lightningcss-linux-x64-gnu": "1.32.0", - "lightningcss-linux-x64-musl": "1.32.0", - "lightningcss-win32-arm64-msvc": "1.32.0", - "lightningcss-win32-x64-msvc": "1.32.0" + "lightningcss-android-arm64": "1.33.0", + "lightningcss-darwin-arm64": "1.33.0", + "lightningcss-darwin-x64": "1.33.0", + "lightningcss-freebsd-x64": "1.33.0", + "lightningcss-linux-arm-gnueabihf": "1.33.0", + "lightningcss-linux-arm64-gnu": "1.33.0", + "lightningcss-linux-arm64-musl": "1.33.0", + "lightningcss-linux-x64-gnu": "1.33.0", + "lightningcss-linux-x64-musl": "1.33.0", + "lightningcss-win32-arm64-msvc": "1.33.0", + "lightningcss-win32-x64-msvc": "1.33.0" } }, "node_modules/lightningcss-android-arm64": { - "version": "1.32.0", - "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.32.0.tgz", - "integrity": "sha512-YK7/ClTt4kAK0vo6w3X+Pnm0D2cf2vPHbhOXdoNti1Ga0al1P4TBZhwjATvjNwLEBCnKvjJc2jQgHXH0NEwlAg==", + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.33.0.tgz", + "integrity": "sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==", "cpu": [ "arm64" ], @@ -5408,9 +5213,9 @@ } }, "node_modules/lightningcss-darwin-arm64": { - "version": "1.32.0", - "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.32.0.tgz", - "integrity": "sha512-RzeG9Ju5bag2Bv1/lwlVJvBE3q6TtXskdZLLCyfg5pt+HLz9BqlICO7LZM7VHNTTn/5PRhHFBSjk5lc4cmscPQ==", + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.33.0.tgz", + "integrity": "sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==", "cpu": [ "arm64" ], @@ -5429,9 +5234,9 @@ } }, "node_modules/lightningcss-darwin-x64": { - "version": "1.32.0", - "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.32.0.tgz", - "integrity": "sha512-U+QsBp2m/s2wqpUYT/6wnlagdZbtZdndSmut/NJqlCcMLTWp5muCrID+K5UJ6jqD2BFshejCYXniPDbNh73V8w==", + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.33.0.tgz", + "integrity": "sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==", "cpu": [ "x64" ], @@ -5450,9 +5255,9 @@ } }, "node_modules/lightningcss-freebsd-x64": { - "version": "1.32.0", - "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.32.0.tgz", - "integrity": "sha512-JCTigedEksZk3tHTTthnMdVfGf61Fky8Ji2E4YjUTEQX14xiy/lTzXnu1vwiZe3bYe0q+SpsSH/CTeDXK6WHig==", + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.33.0.tgz", + "integrity": "sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==", "cpu": [ "x64" ], @@ -5471,9 +5276,9 @@ } }, "node_modules/lightningcss-linux-arm-gnueabihf": { - "version": "1.32.0", - "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.32.0.tgz", - "integrity": "sha512-x6rnnpRa2GL0zQOkt6rts3YDPzduLpWvwAF6EMhXFVZXD4tPrBkEFqzGowzCsIWsPjqSK+tyNEODUBXeeVHSkw==", + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.33.0.tgz", + "integrity": "sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==", "cpu": [ "arm" ], @@ -5492,9 +5297,9 @@ } }, "node_modules/lightningcss-linux-arm64-gnu": { - "version": "1.32.0", - "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.32.0.tgz", - "integrity": "sha512-0nnMyoyOLRJXfbMOilaSRcLH3Jw5z9HDNGfT/gwCPgaDjnx0i8w7vBzFLFR1f6CMLKF8gVbebmkUN3fa/kQJpQ==", + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.33.0.tgz", + "integrity": "sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==", "cpu": [ "arm64" ], @@ -5516,9 +5321,9 @@ } }, "node_modules/lightningcss-linux-arm64-musl": { - "version": "1.32.0", - "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.32.0.tgz", - "integrity": "sha512-UpQkoenr4UJEzgVIYpI80lDFvRmPVg6oqboNHfoH4CQIfNA+HOrZ7Mo7KZP02dC6LjghPQJeBsvXhJod/wnIBg==", + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.33.0.tgz", + "integrity": "sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==", "cpu": [ "arm64" ], @@ -5540,9 +5345,9 @@ } }, "node_modules/lightningcss-linux-x64-gnu": { - "version": "1.32.0", - "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.32.0.tgz", - "integrity": "sha512-V7Qr52IhZmdKPVr+Vtw8o+WLsQJYCTd8loIfpDaMRWGUZfBOYEJeyJIkqGIDMZPwPx24pUMfwSxxI8phr/MbOA==", + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.33.0.tgz", + "integrity": "sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==", "cpu": [ "x64" ], @@ -5564,9 +5369,9 @@ } }, "node_modules/lightningcss-linux-x64-musl": { - "version": "1.32.0", - "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.32.0.tgz", - "integrity": "sha512-bYcLp+Vb0awsiXg/80uCRezCYHNg1/l3mt0gzHnWV9XP1W5sKa5/TCdGWaR/zBM2PeF/HbsQv/j2URNOiVuxWg==", + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.33.0.tgz", + "integrity": "sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==", "cpu": [ "x64" ], @@ -5588,9 +5393,9 @@ } }, "node_modules/lightningcss-win32-arm64-msvc": { - "version": "1.32.0", - "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.32.0.tgz", - "integrity": "sha512-8SbC8BR40pS6baCM8sbtYDSwEVQd4JlFTOlaD3gWGHfThTcABnNDBda6eTZeqbofalIJhFx0qKzgHJmcPTnGdw==", + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.33.0.tgz", + "integrity": "sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==", "cpu": [ "arm64" ], @@ -5609,9 +5414,9 @@ } }, "node_modules/lightningcss-win32-x64-msvc": { - "version": "1.32.0", - "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.32.0.tgz", - "integrity": "sha512-Amq9B/SoZYdDi1kFrojnoqPLxYhQ4Wo5XiL8EVJrVsB8ARoC1PWW6VGtT0WKCemjy8aC+louJnjS7U18x3b06Q==", + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.33.0.tgz", + "integrity": "sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==", "cpu": [ "x64" ], @@ -5684,13 +5489,13 @@ } }, "node_modules/magic-string": { - "version": "0.30.21", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", - "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==", + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-1.4.5.tgz", + "integrity": "sha512-oLLC2+YvQUfAa+vxoufE/yc1icb87M9iXIRqAoR/2EhE/8cb3SF/+Gi0c2By1B+5Vz2e2vQtUvHiu1+63Znh+w==", "dev": true, "license": "MIT", "dependencies": { - "@jridgewell/sourcemap-codec": "^1.5.5" + "@jridgewell/sourcemap-codec": "^1.6.0" } }, "node_modules/magicast": { @@ -5999,13 +5804,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/mdn-data": { - "version": "2.27.1", - "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.27.1.tgz", - "integrity": "sha512-9Yubnt3e8A0OKwxYSXyhLymGW4sCufcLG6VdiDdUGVkPhpqLxlvP5vl1983gQjJl3tqbrM731mjaZaP68AgosQ==", - "dev": true, - "license": "CC0-1.0" - }, "node_modules/micromark": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/micromark/-/micromark-4.0.3.tgz", @@ -6800,13 +6598,26 @@ "license": "MIT" }, "node_modules/parse5": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-8.0.1.tgz", - "integrity": "sha512-z1e/HMG90obSGeidlli3hj7cbocou0/wa5HacvI3ASx34PecNjNQeaHNo5WIZpWofN9kgkqV1q5YvXe3F0FoPw==", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-8.1.0.tgz", + "integrity": "sha512-sq3qBFpee5jeocbFbO48VHlGr8sT7mbXS0vxlKN6sottBtJzrOG3998sr0llSZcQAGgfpdmEYAIZE0P9z0dE8w==", "dev": true, "license": "MIT", "dependencies": { - "entities": "^8.0.0" + "entities": "^9.0.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, + "node_modules/parse5-parser-stream": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/parse5-parser-stream/-/parse5-parser-stream-8.1.0.tgz", + "integrity": "sha512-58MPfNTA+DsIzro41rU94xghnu/h2N4yEPdPdGPlZVHM/QvA5jlVGYVo7IzlHbFLHYx3cZUnr9s9HBrA0tEYyw==", + "dev": true, + "license": "MIT", + "dependencies": { + "parse5": "^8.0.0" }, "funding": { "url": "https://github.com/inikulin/parse5?sponsor=1" @@ -7238,24 +7049,14 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/require-from-string": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", - "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/rolldown": { - "version": "1.2.14", - "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.14.tgz", - "integrity": "sha512-eTBTTqMR6uHKLgcUqpJP8ntzDI6V4LYA8negAMBEI7gkgVvOdrx6VsvS2Ym+83KhOPdLCHWJu0w7UQFJZhHKNw==", + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.16.tgz", + "integrity": "sha512-bWvlMpFKiTfDKfnK7FC2MPgPeWCf/Kpwsq49ApdW+FQaBZb6O6dZ4MAPbPUjp7hYQrw/RobqCzn64BRrQecGHw==", "dev": true, "license": "MIT", "dependencies": { - "@oxc-project/types": "=0.154.0", + "@oxc-project/types": "=0.156.0", "@rolldown/pluginutils": "^1.0.0" }, "bin": { @@ -7265,21 +7066,21 @@ "node": "^20.19.0 || >=22.12.0" }, "optionalDependencies": { - "@rolldown/binding-android-arm-eabi": "1.2.14", - "@rolldown/binding-android-arm64": "1.2.14", - "@rolldown/binding-darwin-arm64": "1.2.14", - "@rolldown/binding-darwin-x64": "1.2.14", - "@rolldown/binding-freebsd-x64": "1.2.14", - "@rolldown/binding-linux-arm-gnueabihf": "1.2.14", - "@rolldown/binding-linux-arm64-gnu": "1.2.14", - "@rolldown/binding-linux-arm64-musl": "1.2.14", - "@rolldown/binding-linux-ppc64-gnu": "1.2.14", - "@rolldown/binding-linux-s390x-gnu": "1.2.14", - "@rolldown/binding-linux-x64-gnu": "1.2.14", - "@rolldown/binding-linux-x64-musl": "1.2.14", - "@rolldown/binding-openharmony-arm64": "1.2.14", - "@rolldown/binding-win32-arm64-msvc": "1.2.14", - "@rolldown/binding-win32-x64-msvc": "1.2.14" + "@rolldown/binding-android-arm-eabi": "1.2.16", + "@rolldown/binding-android-arm64": "1.2.16", + "@rolldown/binding-darwin-arm64": "1.2.16", + "@rolldown/binding-darwin-x64": "1.2.16", + "@rolldown/binding-freebsd-x64": "1.2.16", + "@rolldown/binding-linux-arm-gnueabihf": "1.2.16", + "@rolldown/binding-linux-arm64-gnu": "1.2.16", + "@rolldown/binding-linux-arm64-musl": "1.2.16", + "@rolldown/binding-linux-ppc64-gnu": "1.2.16", + "@rolldown/binding-linux-s390x-gnu": "1.2.16", + "@rolldown/binding-linux-x64-gnu": "1.2.16", + "@rolldown/binding-linux-x64-musl": "1.2.16", + "@rolldown/binding-openharmony-arm64": "1.2.16", + "@rolldown/binding-win32-arm64-msvc": "1.2.16", + "@rolldown/binding-win32-x64-msvc": "1.2.16" } }, "node_modules/saxes": { @@ -7423,9 +7224,9 @@ } }, "node_modules/tailwindcss": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.3.3.tgz", - "integrity": "sha512-gOhV3P7ufE62QDGg1zVaTgCR+EtPv92k2nIhVcVKcLmxT1sUBsQGhnZj175j+MqRt4zLF7ic+sCYjfhxMxj7YQ==", + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.3.5.tgz", + "integrity": "sha512-FcQk9BuffmEHJP2G0XmB2SplU1aLTI7j07Kunk+U74Ny+XiWOtzXz9aujFZ/avntw1e2cOv/3PkgzflQ7gX2vQ==", "dev": true, "license": "MIT" }, @@ -7871,16 +7672,16 @@ } }, "node_modules/vite": { - "version": "8.3.5", - "resolved": "https://registry.npmjs.org/vite/-/vite-8.3.5.tgz", - "integrity": "sha512-z1YpjieJ9g0ebTmQpLBv/oq9E3F9EIlOe+7LahW8SrE3LTiG3udBRUXQOlYXP9b+IC2q2phHeVxj9xGlw34OEQ==", + "version": "8.3.6", + "resolved": "https://registry.npmjs.org/vite/-/vite-8.3.6.tgz", + "integrity": "sha512-UI7dK29NnS54Fk+mmo7o+jI6U8Fp7hDl+X5Q1k45WH+d4dSlbLVUETGQ+hfkNgvLQGyoElPj837nZyv4MBc0VA==", "dev": true, "license": "MIT", "dependencies": { "lightningcss": "^1.33.0", "picomatch": "^4.0.7", - "postcss": "^8.5.30", - "rolldown": "~1.2.14", + "postcss": "^8.5.32", + "rolldown": "~1.2.16", "tinyglobby": "^0.2.17" }, "bin": { @@ -7948,288 +7749,15 @@ } } }, - "node_modules/vite/node_modules/lightningcss": { - "version": "1.33.0", - "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.33.0.tgz", - "integrity": "sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==", - "dev": true, - "license": "MPL-2.0", - "dependencies": { - "detect-libc": "^2.0.3" - }, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - }, - "optionalDependencies": { - "lightningcss-android-arm64": "1.33.0", - "lightningcss-darwin-arm64": "1.33.0", - "lightningcss-darwin-x64": "1.33.0", - "lightningcss-freebsd-x64": "1.33.0", - "lightningcss-linux-arm-gnueabihf": "1.33.0", - "lightningcss-linux-arm64-gnu": "1.33.0", - "lightningcss-linux-arm64-musl": "1.33.0", - "lightningcss-linux-x64-gnu": "1.33.0", - "lightningcss-linux-x64-musl": "1.33.0", - "lightningcss-win32-arm64-msvc": "1.33.0", - "lightningcss-win32-x64-msvc": "1.33.0" - } - }, - "node_modules/vite/node_modules/lightningcss-android-arm64": { - "version": "1.33.0", - "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.33.0.tgz", - "integrity": "sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MPL-2.0", - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/vite/node_modules/lightningcss-darwin-arm64": { - "version": "1.33.0", - "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.33.0.tgz", - "integrity": "sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MPL-2.0", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/vite/node_modules/lightningcss-darwin-x64": { - "version": "1.33.0", - "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.33.0.tgz", - "integrity": "sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MPL-2.0", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/vite/node_modules/lightningcss-freebsd-x64": { - "version": "1.33.0", - "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.33.0.tgz", - "integrity": "sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MPL-2.0", - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/vite/node_modules/lightningcss-linux-arm-gnueabihf": { - "version": "1.33.0", - "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.33.0.tgz", - "integrity": "sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==", - "cpu": [ - "arm" - ], - "dev": true, - "license": "MPL-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/vite/node_modules/lightningcss-linux-arm64-gnu": { - "version": "1.33.0", - "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.33.0.tgz", - "integrity": "sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==", - "cpu": [ - "arm64" - ], - "dev": true, - "libc": [ - "glibc" - ], - "license": "MPL-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/vite/node_modules/lightningcss-linux-arm64-musl": { - "version": "1.33.0", - "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.33.0.tgz", - "integrity": "sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "libc": [ - "musl" - ], - "license": "MPL-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/vite/node_modules/lightningcss-linux-x64-gnu": { - "version": "1.33.0", - "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.33.0.tgz", - "integrity": "sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==", - "cpu": [ - "x64" - ], - "dev": true, - "libc": [ - "glibc" - ], - "license": "MPL-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/vite/node_modules/lightningcss-linux-x64-musl": { - "version": "1.33.0", - "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.33.0.tgz", - "integrity": "sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==", - "cpu": [ - "x64" - ], - "dev": true, - "libc": [ - "musl" - ], - "license": "MPL-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/vite/node_modules/lightningcss-win32-arm64-msvc": { - "version": "1.33.0", - "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.33.0.tgz", - "integrity": "sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MPL-2.0", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/vite/node_modules/lightningcss-win32-x64-msvc": { - "version": "1.33.0", - "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.33.0.tgz", - "integrity": "sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MPL-2.0", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, "node_modules/vitest": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/vitest/-/vitest-5.0.5.tgz", - "integrity": "sha512-cPODOMF8YnkiiYtDdHo6n4wWmBrOBBbOIYH2d33M4l3CdNn72h+qMmO6uXffUN6A5AZFXNND/d+krS9mgkXRfg==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-5.1.0.tgz", + "integrity": "sha512-MzmNFnrwa8v8lF1bLxw3UJ4EREwVOVb75VqJZmUDRjJ6EluK/x9th7qTbaeDk41WxE1GxWqmTXcdsfobfH5sOA==", "dev": true, "license": "MIT", "dependencies": { "@types/chai": "^5.2.2", - "@vitest/mocker": "5.0.5", + "@vitest/mocker": "5.1.0", "chai": "^6.3.0", "es-module-lexer": "^2.3.2", "expect-type": "^1.4.0", @@ -8255,12 +7783,12 @@ "@edge-runtime/vm": "*", "@opentelemetry/api": "^1.9.0", "@types/node": "^22.0.0 || >=24.0.0", - "@vitest/browser-playwright": "5.0.5", - "@vitest/browser-preview": "5.0.5", + "@vitest/browser-playwright": "5.1.0", + "@vitest/browser-preview": "5.1.0", "@vitest/browser-webdriverio": "^5.0.0-beta.5 || >=5.0.0", - "@vitest/coverage-istanbul": "5.0.5", - "@vitest/coverage-v8": "5.0.5", - "@vitest/ui": "5.0.5", + "@vitest/coverage-istanbul": "5.1.0", + "@vitest/coverage-v8": "5.1.0", + "@vitest/ui": "5.1.0", "happy-dom": "*", "jsdom": "*", "vite": "^6.4.0 || ^7.0.0 || ^8.0.0" @@ -8304,16 +7832,6 @@ } } }, - "node_modules/vitest/node_modules/magic-string": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-1.4.3.tgz", - "integrity": "sha512-z12OxmaPGE0F4xlpGdjuAUckipLpQlTAuAmyGhNoD7ODpYUzvDfvtxUbjM/jwznyP178oju/KDdyi220wNJ0RQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/sourcemap-codec": "^1.6.0" - } - }, "node_modules/w3c-xmlserializer": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-6.0.0.tgz", diff --git a/frontend/package.json b/frontend/package.json index 0d00a8d..630e5da 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -41,7 +41,7 @@ }, "devDependencies": { "@eslint/js": "10.0.1", - "@tailwindcss/postcss": "4.3.3", + "@tailwindcss/postcss": "4.3.5", "@testing-library/jest-dom": "7.0.1", "@testing-library/react": "16.3.3", "@testing-library/user-event": "14.6.8", @@ -50,22 +50,22 @@ "@types/react": "19.3.0", "@types/react-dom": "19.3.0", "@typescript/native": "npm:typescript@7.0.2", - "@vitejs/plugin-react": "6.1.2", - "@vitest/coverage-v8": "5.0.5", + "@vitejs/plugin-react": "6.2.1", + "@vitest/coverage-v8": "5.1.0", "axe-core": "4.14.0", "esbuild": "0.28.2", - "eslint": "10.13.0", + "eslint": "10.14.0", "eslint-plugin-react-hooks": "7.1.1", "eslint-plugin-react-refresh": "0.5.7", - "globals": "17.13.0", - "jsdom": "30.1.3", + "globals": "17.14.0", + "jsdom": "31.0.0", "json-schema-to-typescript": "16.0.0", "postcss": "8.5.32", - "tailwindcss": "4.3.3", + "tailwindcss": "4.3.5", "tailwindcss-animate": "1.0.7", "typescript": "npm:@typescript/typescript6@6.0.2", "typescript-eslint": "8.72.1", - "vite": "8.3.5", - "vitest": "5.0.5" + "vite": "8.3.6", + "vitest": "5.1.0" } } diff --git a/frontend/src/auth/AuthProvider.test.tsx b/frontend/src/auth/AuthProvider.test.tsx new file mode 100644 index 0000000..14940df --- /dev/null +++ b/frontend/src/auth/AuthProvider.test.tsx @@ -0,0 +1,248 @@ +// SPDX-License-Identifier: MIT +/** + * Tests for the auth context's sign-out: it clears the saved-settings store, so the next user to + * sign in on the same page load fetches their own settings and never sees the previous user's. + */ +import { act, renderHook } from "@testing-library/react"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; + +import type { UserSettingsView } from "../api/CrmApiClient"; +import { + EMPTY_TIER_SELECTION, + __resetSessionTuningForTests, + getSessionTuning, + loadUserSettings, + resetUserSettings, + resetUserSettingsState, + saveUserSettings, + useSettingsStatus, + type SettingsClient, +} from "../components/tuning/sessionTuning"; +import { AuthProvider, useAuth, type AuthContextValue } from "./AuthProvider"; +import type { AuthSession } from "./CognitoAuthSession"; +import type { Identity } from "./identity"; + +const { signInMock, restoreMock } = vi.hoisted(() => ({ + signInMock: vi.fn(), + restoreMock: vi.fn(), +})); + +vi.mock("../config/runtimeConfig", () => ({ + loadRuntimeConfig: vi.fn().mockResolvedValue({}), +})); + +vi.mock("./CognitoAuthSession", () => ({ + CognitoAuthSession: { signIn: signInMock, restore: restoreMock }, +})); + +function fakeSession(userId: string): AuthSession { + const identity: Identity = { + userId, + repId: `rep-${userId}`, + book: [], + fullVisibility: false, + expiresAt: Number.MAX_SAFE_INTEGER, + }; + return { + getIdentity: () => identity, + getAccessToken: () => Promise.resolve(`token-${userId}`), + signOut: vi.fn(), + }; +} + +function viewFor(model: string): UserSettingsView { + return { + tuning: { + schema: 3, + source: "settings.tuning", + tiers: { supervisor: { family: "anthropic", model, effort: "low" } }, + }, + is_default: false, + notice: null, + updated_at: "2026-10-08T00:00:00Z", + }; +} + +function settingsClient( + getUserSettings: () => Promise, +): SettingsClient & { getUserSettings: ReturnType } { + return { + getUserSettings: vi.fn(getUserSettings), + saveUserSettings: vi.fn(), + resetUserSettings: vi.fn(), + } as never; +} + +async function renderAuth(): Promise<{ current: () => AuthContextValue }> { + const { result } = renderHook(() => useAuth(), { wrapper: AuthProvider }); + await act(async () => {}); + return { current: () => result.current }; +} + +async function signInAs(auth: { current: () => AuthContextValue }, userId: string): Promise { + signInMock.mockResolvedValueOnce(fakeSession(userId)); + await act(async () => { + await auth.current().signIn(userId, "pw"); + }); +} + +beforeEach(() => { + __resetSessionTuningForTests(); + signInMock.mockReset(); + restoreMock.mockReset().mockResolvedValue(undefined); +}); + +afterEach(() => { + __resetSessionTuningForTests(); +}); + +describe("AuthProvider sign-out", () => { + it("makes the next user's settings load fetch afresh instead of reusing the previous user's", async () => { + const auth = await renderAuth(); + const clientA = settingsClient(() => Promise.resolve(viewFor("model-of-a"))); + const clientB = settingsClient(() => Promise.resolve(viewFor("model-of-b"))); + + await signInAs(auth, "user-a"); + await act(async () => { + await loadUserSettings(clientA); + }); + expect(getSessionTuning().tiers.supervisor.model).toBe("model-of-a"); + + act(() => auth.current().signOut()); + expect(auth.current().status).toBe("signed-out"); + expect(getSessionTuning().tiers.supervisor).toEqual(EMPTY_TIER_SELECTION); + + await signInAs(auth, "user-b"); + await act(async () => { + await loadUserSettings(clientB); + }); + + expect(clientB.getUserSettings).toHaveBeenCalledTimes(1); + expect(getSessionTuning().tiers.supervisor.model).toBe("model-of-b"); + }); + + it("calls the session's own sign-out", async () => { + const auth = await renderAuth(); + const session = fakeSession("user-a"); + signInMock.mockResolvedValueOnce(session); + await act(async () => { + await auth.current().signIn("user-a", "pw"); + }); + + act(() => auth.current().signOut()); + + expect(session.signOut).toHaveBeenCalledTimes(1); + }); +}); + +describe("resetUserSettingsState", () => { + it("returns a loaded store to idle and notifies subscribers", async () => { + const { result } = renderHook(() => useSettingsStatus()); + await act(async () => { + await loadUserSettings(settingsClient(() => Promise.resolve(viewFor("model-of-a")))); + }); + expect(result.current.status).toBe("ready"); + + act(() => resetUserSettingsState()); + + expect(result.current).toEqual({ status: "idle" }); + }); + + it("discards a load that was in flight when the store was reset", async () => { + let resolveA: (view: UserSettingsView) => void = () => {}; + const clientA = settingsClient( + () => + new Promise((resolve) => { + resolveA = resolve; + }), + ); + const pendingA = loadUserSettings(clientA); + + resetUserSettingsState(); + const clientB = settingsClient(() => Promise.resolve(viewFor("model-of-b"))); + await loadUserSettings(clientB); + resolveA(viewFor("model-of-a")); + await pendingA; + + expect(clientB.getUserSettings).toHaveBeenCalledTimes(1); + expect(getSessionTuning().tiers.supervisor.model).toBe("model-of-b"); + }); + + it("discards the failure of a load that was in flight when the store was reset", async () => { + let rejectA: (err: Error) => void = () => {}; + const pendingA = loadUserSettings( + settingsClient( + () => + new Promise((_resolve, reject) => { + rejectA = reject; + }), + ), + ); + + resetUserSettingsState(); + rejectA(new Error("previous user's load failed")); + await pendingA; + + const { result } = renderHook(() => useSettingsStatus()); + expect(result.current).toEqual({ status: "idle" }); + }); +}); + +function deferred(): { promise: Promise; resolve: (value: T) => void } { + let resolve: (value: T) => void = () => {}; + const promise = new Promise((done) => { + resolve = done; + }); + return { promise, resolve }; +} + +describe("a save or reset in flight at sign-out", () => { + it.each([ + ["save", (client: SettingsClient) => saveUserSettings(client, getSessionTuning())], + ["reset", (client: SettingsClient) => resetUserSettings(client)], + ] as const)( + "discards user A's %s result, so user B's sign-in fetches B's settings", + async (_label, write) => { + const auth = await renderAuth(); + const pendingA = deferred(); + const clientA = { + ...settingsClient(() => Promise.resolve(viewFor("model-of-a"))), + saveUserSettings: vi.fn(() => pendingA.promise), + resetUserSettings: vi.fn(() => pendingA.promise), + }; + const clientB = settingsClient(() => Promise.resolve(viewFor("model-of-b"))); + + await signInAs(auth, "user-a"); + await act(async () => { + await loadUserSettings(clientA); + }); + const writeA = write(clientA); + + act(() => auth.current().signOut()); + await act(async () => { + pendingA.resolve(viewFor("model-of-a-written")); + await writeA; + }); + expect(getSessionTuning().tiers.supervisor).toEqual(EMPTY_TIER_SELECTION); + + await signInAs(auth, "user-b"); + await act(async () => { + await loadUserSettings(clientB); + }); + + expect(clientB.getUserSettings).toHaveBeenCalledTimes(1); + expect(getSessionTuning().tiers.supervisor.model).toBe("model-of-b"); + }, + ); + + it("still adopts a save that completes before sign-out (control)", async () => { + const client = { + ...settingsClient(() => Promise.resolve(viewFor("model-of-a"))), + saveUserSettings: vi.fn(() => Promise.resolve(viewFor("model-of-a-written"))), + }; + + await saveUserSettings(client, getSessionTuning()); + + expect(getSessionTuning().tiers.supervisor.model).toBe("model-of-a-written"); + }); +}); diff --git a/frontend/src/auth/AuthProvider.tsx b/frontend/src/auth/AuthProvider.tsx index 17b9b4e..1e8fb47 100644 --- a/frontend/src/auth/AuthProvider.tsx +++ b/frontend/src/auth/AuthProvider.tsx @@ -6,6 +6,7 @@ import { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react"; import type { JSX, ReactNode } from "react"; +import { resetUserSettingsState } from "../components/tuning/sessionTuning"; import { loadRuntimeConfig } from "../config/runtimeConfig"; import { CognitoAuthSession, type AuthSession } from "./CognitoAuthSession"; import type { Identity } from "./identity"; @@ -58,6 +59,7 @@ export function AuthProvider({ children }: { children: ReactNode }): JSX.Element const signOut = useCallback(() => { session?.signOut(); + resetUserSettingsState(); setSession(undefined); setIdentity(undefined); setStatus("signed-out"); diff --git a/frontend/src/auth/CognitoAuthSession.test.ts b/frontend/src/auth/CognitoAuthSession.test.ts new file mode 100644 index 0000000..4e24baa --- /dev/null +++ b/frontend/src/auth/CognitoAuthSession.test.ts @@ -0,0 +1,150 @@ +// SPDX-License-Identifier: MIT +/** + * Tests for sign-out against the real `amazon-cognito-identity-js`: a session restored from seeded + * browser storage, with `fetch` stubbed so the only observable network effect is a `RevokeToken` + * request. Asserts the refresh token is revoked when revocable, that cached tokens are gone before + * `signOut` returns, and that a non-revocable token makes no request at all. + */ +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; + +import type { RuntimeConfig } from "../config/runtimeConfig"; +import { CognitoAuthSession } from "./CognitoAuthSession"; + +const CLIENT_ID = "testclient123"; +const USERNAME = "rep-042"; +const KEY_PREFIX = `CognitoIdentityServiceProvider.${CLIENT_ID}`; +const REFRESH_TOKEN = "opaque-refresh-token-value"; // gitleaks:allow + +const CONFIG = { + cognitoUserPoolId: "us-east-1_TestPool1", + cognitoClientId: CLIENT_ID, + cognitoRegion: "us-east-1", + cognitoHostedUiDomain: "", +} as RuntimeConfig; + +function base64Url(value: object): string { + return btoa(JSON.stringify(value)).replace(/=+$/, "").replace(/\+/g, "-").replace(/\//g, "_"); +} + +function jwt(claims: Record): string { + const now = Math.floor(Date.now() / 1000); + return `${base64Url({ alg: "none" })}.${base64Url({ iat: now, exp: now + 3600, ...claims })}.sig`; +} + +function seedCachedSession({ revocable }: { revocable: boolean }): void { + const userPrefix = `${KEY_PREFIX}.${USERNAME}`; + localStorage.setItem(`${KEY_PREFIX}.LastAuthUser`, USERNAME); + localStorage.setItem(`${userPrefix}.idToken`, jwt({ token_use: "id", sub: "abc" })); + localStorage.setItem( + `${userPrefix}.accessToken`, + jwt({ token_use: "access", ...(revocable ? { origin_jti: "origin-jti-1" } : {}) }), + ); + localStorage.setItem(`${userPrefix}.refreshToken`, REFRESH_TOKEN); + localStorage.setItem(`${userPrefix}.clockDrift`, "0"); +} + +function cognitoKeys(): string[] { + return Object.keys(localStorage).filter((key) => key.startsWith("CognitoIdentityServiceProvider.")); +} + +async function restoredSession(): Promise>>> { + const session = await CognitoAuthSession.restore(CONFIG); + if (session === undefined) throw new Error("the seeded session did not restore"); + return session; +} + +function revokeRequests(fetchMock: ReturnType): RequestInit[] { + return fetchMock.mock.calls + .map((call) => call[1] as RequestInit) + .filter((init) => { + const headers = init.headers as Record; + return headers["X-Amz-Target"] === "AWSCognitoIdentityProviderService.RevokeToken"; + }); +} + +let fetchMock: ReturnType; + +beforeEach(() => { + localStorage.clear(); + fetchMock = vi.fn(() => new Promise(() => {})); + vi.stubGlobal("fetch", fetchMock); +}); + +afterEach(() => { + vi.unstubAllGlobals(); + vi.restoreAllMocks(); + localStorage.clear(); +}); + +describe("CognitoAuthSession.signOut", () => { + it("restores from the seeded cache without a network call (fixture control)", async () => { + seedCachedSession({ revocable: true }); + await restoredSession(); + expect(fetchMock).not.toHaveBeenCalled(); + expect(cognitoKeys().length).toBeGreaterThan(0); + }); + + it("sends one RevokeToken request carrying the refresh token", async () => { + seedCachedSession({ revocable: true }); + const session = await restoredSession(); + + session.signOut(); + + const requests = revokeRequests(fetchMock); + expect(requests).toHaveLength(1); + expect(JSON.parse(requests[0]?.body as string)).toEqual({ + Token: REFRESH_TOKEN, + ClientId: CLIENT_ID, + }); + }); + + it("clears every cached Cognito key before it returns, with the revocation still pending", async () => { + seedCachedSession({ revocable: true }); + const session = await restoredSession(); + + session.signOut(); + + expect(cognitoKeys()).toEqual([]); + expect(revokeRequests(fetchMock)).toHaveLength(1); + }); + + it("makes no network call for a token without origin_jti, and still clears the cache", async () => { + seedCachedSession({ revocable: false }); + const session = await restoredSession(); + + session.signOut(); + + expect(fetchMock).not.toHaveBeenCalled(); + expect(cognitoKeys()).toEqual([]); + }); + + it("reports a failed revocation without the token and keeps the cache cleared", async () => { + fetchMock.mockImplementation(() => Promise.reject(new TypeError("network down"))); + const warn = vi.spyOn(console, "warn").mockImplementation(() => {}); + seedCachedSession({ revocable: true }); + const session = await restoredSession(); + + vi.useFakeTimers({ toFake: ["setTimeout"] }); + try { + session.signOut(); + await vi.advanceTimersByTimeAsync(120_000); + } finally { + vi.useRealTimers(); + } + + expect(warn).toHaveBeenCalledTimes(1); + + expect(JSON.stringify(warn.mock.calls)).not.toContain(REFRESH_TOKEN); + expect(cognitoKeys()).toEqual([]); + }); + + it("does not navigate away from the page", async () => { + seedCachedSession({ revocable: true }); + const session = await restoredSession(); + const before = window.location.href; + + session.signOut(); + + expect(window.location.href).toBe(before); + }); +}); diff --git a/frontend/src/auth/CognitoAuthSession.ts b/frontend/src/auth/CognitoAuthSession.ts index f912db6..43bf283 100644 --- a/frontend/src/auth/CognitoAuthSession.ts +++ b/frontend/src/auth/CognitoAuthSession.ts @@ -37,10 +37,18 @@ export interface AuthSession { getIdentity(): Identity; /** Returns a valid, non-expired Cognito ID token, refreshing first if necessary. */ getAccessToken(): Promise; - /** Signs the user out and clears all cached Cognito state for this pool. */ + /** + * Signs the user out: starts revoking the refresh token, and clears all cached Cognito state for + * this pool before returning. + */ signOut(): void; } +/** `CognitoUser.revokeTokens`, present at runtime but missing from the library's type declarations. */ +interface RevocableUser { + revokeTokens(callback: (err?: Error) => void): void; +} + export class CognitoAuthSession implements AuthSession { private user: CognitoUser; private session: CognitoUserSession; @@ -125,7 +133,15 @@ export class CognitoAuthSession implements AuthSession { return this.session.getIdToken().getJwtToken(); } + /** + * Start revoking the refresh token, then clear every cached Cognito token synchronously. The + * revocation runs in the background; a token without `origin_jti` is not revocable and makes no + * network call, and a failed revocation is reported to the console only. + */ signOut(): void { + (this.user as unknown as RevocableUser).revokeTokens((err?: Error) => { + if (err) console.warn("Could not revoke the refresh token at sign-out", err.name); + }); this.user.signOut(); } } diff --git a/frontend/src/components/tuning/sessionTuning.ts b/frontend/src/components/tuning/sessionTuning.ts index 0943a0b..ed61bb8 100644 --- a/frontend/src/components/tuning/sessionTuning.ts +++ b/frontend/src/components/tuning/sessionTuning.ts @@ -3,11 +3,11 @@ * The signed-in user's per-tier tuning: one `{family, model, effort}` selection per tier, persisted * server-side through `POST /api/user_settings` and mirrored in memory here. * - * {@link loadUserSettings} fetches the saved settings once per page load, {@link saveUserSettings} - * and {@link resetUserSettings} write them, and the store adopts the server's view only after the - * server accepts it. The chat surface reads `getSessionTuning()` once per new turn, so a change - * applies to the next turn and never to one already streaming. Nothing here touches browser - * storage. + * {@link loadUserSettings} fetches the saved settings once per sign-in, {@link saveUserSettings} + * and {@link resetUserSettings} write them, {@link resetUserSettingsState} forgets them at + * sign-out, and the store adopts the server's view only after the server accepts it. The chat + * surface reads `getSessionTuning()` once per new turn, so a change applies to the next turn and + * never to one already streaming. Nothing here touches browser storage. * * {@link useTuningEditor} is the editing state shared by the settings page and the assistant * panel: a pending copy, client-side validation, and server rejections mapped onto the offending @@ -97,6 +97,7 @@ const INITIAL_STATE: StoreState = { tuning: EMPTY_TUNING, settings: { status: "i let state: StoreState = INITIAL_STATE; let inFlightLoad: Promise | null = null; +let loadGeneration = 0; const listeners = new Set<() => void>(); function update(next: Partial): void { @@ -171,17 +172,22 @@ export function resetSessionTuning(): void { } /** - * Fetch the saved settings once per page load. Later calls resolve with the first call's result; + * Fetch the saved settings once per sign-in. Later calls resolve with the first call's result; * a failed load may be retried. */ export function loadUserSettings(client: SettingsClient): Promise { if (state.settings.status === "ready") return Promise.resolve(); if (inFlightLoad !== null) return inFlightLoad; update({ settings: { status: "loading" } }); - inFlightLoad = client + const generation = loadGeneration; + const isCurrent = (): boolean => generation === loadGeneration; + const load = client .getUserSettings() - .then(adoptView) + .then((view) => { + if (isCurrent()) adoptView(view); + }) .catch((err: unknown) => { + if (!isCurrent()) return; update({ settings: { status: "error", @@ -190,19 +196,44 @@ export function loadUserSettings(client: SettingsClient): Promise { }); }) .finally(() => { - inFlightLoad = null; + if (isCurrent()) inFlightLoad = null; }); - return inFlightLoad; + inFlightLoad = load; + return load; +} + +/** + * Return the store to its never-loaded state and notify subscribers, so the next + * {@link loadUserSettings} fetches afresh. A load, save or reset still in flight is abandoned: its + * result is discarded when it settles. + */ +export function resetUserSettingsState(): void { + loadGeneration += 1; + inFlightLoad = null; + update(INITIAL_STATE); } -/** Save `tuning` to the server and adopt the server's view. Rejects with the server's error. */ +/** Adopt `view` only if {@link resetUserSettingsState} has not run since `generation` was read. */ +function adoptViewIfCurrent(generation: number, view: UserSettingsView): void { + if (generation === loadGeneration) adoptView(view); +} + +/** + * Save `tuning` to the server and adopt the server's view. Rejects with the server's error. A + * response arriving after {@link resetUserSettingsState} is discarded. + */ export async function saveUserSettings(client: SettingsClient, tuning: SessionTuning): Promise { - adoptView(await client.saveUserSettings({ tuning: wireTuningBlock(tuning) })); + const generation = loadGeneration; + adoptViewIfCurrent(generation, await client.saveUserSettings({ tuning: wireTuningBlock(tuning) })); } -/** Delete the saved settings and adopt the server's defaults. Rejects with the server's error. */ +/** + * Delete the saved settings and adopt the server's defaults. Rejects with the server's error. A + * response arriving after {@link resetUserSettingsState} is discarded. + */ export async function resetUserSettings(client: SettingsClient): Promise { - adoptView(await client.resetUserSettings()); + const generation = loadGeneration; + adoptViewIfCurrent(generation, await client.resetUserSettings()); } /** React hook binding a component to the current tuning, re-rendering on change. */ @@ -341,5 +372,6 @@ export function useTuningEditor(matrix: CapabilityMatrix, client: SettingsClient export function __resetSessionTuningForTests(): void { state = INITIAL_STATE; inFlightLoad = null; + loadGeneration += 1; listeners.clear(); } diff --git a/frontend/src/hooks/usePageContext.ts b/frontend/src/hooks/usePageContext.ts index ef57241..37bb282 100644 --- a/frontend/src/hooks/usePageContext.ts +++ b/frontend/src/hooks/usePageContext.ts @@ -164,7 +164,7 @@ function hasForbiddenCharacter(value: string): boolean { } /** The longest pagination cursor (`CURSOR_MAX_LENGTH` server-side). */ -export const CURSOR_MAX_LENGTH = 2048; +export const CURSOR_MAX_LENGTH = 4000; /** A pagination cursor: URL-safe base64. */ export const CURSOR_PATTERN = /^[A-Za-z0-9_-]*=*$/; diff --git a/frontend/src/pages/evals/EvalArtifactList.tsx b/frontend/src/pages/evals/EvalArtifactList.tsx index 5511ba6..0a4e553 100644 --- a/frontend/src/pages/evals/EvalArtifactList.tsx +++ b/frontend/src/pages/evals/EvalArtifactList.tsx @@ -7,7 +7,8 @@ * The artefacts bucket is private, so each control asks the run API for a short-lived presigned * URL (`EvalRunClient.getArtefactUrl`) when clicked and opens it in a new tab. A refused or failed * request is shown as an alert naming the artifact. An unavailable artifact keeps its row and is - * labelled unavailable. + * labelled unavailable. "Download matrix.md" asks for the same file as an attachment and navigates to + * that URL, which saves it rather than leaving the page. */ import { useState } from "react"; import type { JSX } from "react"; @@ -33,6 +34,7 @@ export function EvalArtifactList({ artifacts, runId, client }: EvalArtifactListP const rawCount = raw.length; const [opening, setOpening] = useState(undefined); const [failure, setFailure] = useState(undefined); + const matrixMd = artifacts.matrixMd; async function open(key: string): Promise { // Opened before the request so the browser treats the new tab as the click's own. @@ -56,6 +58,20 @@ export function EvalArtifactList({ artifacts, runId, client }: EvalArtifactListP } } + async function download(key: string): Promise { + setOpening(`download:${key}`); + setFailure(undefined); + try { + const { url } = await client.getArtefactUrl(runId, key, { download: true }); + window.location.assign(url); + } catch (err) { + const reason = err instanceof Error && err.message ? err.message : "the request failed"; + setFailure(`Could not download ${key}: ${reason}`); + } finally { + setOpening(undefined); + } + } + function control(key: string, label: string): JSX.Element { return ( + ) : ( matrix.md — not available )} diff --git a/frontend/src/pages/evals/EvalDashboardPage.tsx b/frontend/src/pages/evals/EvalDashboardPage.tsx index f1e45e4..19d2dc3 100644 --- a/frontend/src/pages/evals/EvalDashboardPage.tsx +++ b/frontend/src/pages/evals/EvalDashboardPage.tsx @@ -28,6 +28,7 @@ import { EvalArmResults } from "./EvalArmResults"; import { EvalArtifactList } from "./EvalArtifactList"; import { LiveSweepDialog, RepeatsSelect } from "./LiveSweepDialog"; import { RunHistory } from "./RunHistory"; +import { TierComparisonSummary } from "./TierComparisonSummary"; import { classifyRunMode } from "./runMode"; import { erroredItemsCostNote } from "./types"; import { toArtifactLinks, useEvalRun } from "./useEvalRun"; @@ -383,6 +384,7 @@ function EvalDashboardPageBody({ ? " This run was cancelled, so the figures cover only the tasks that finished." : ""}

+ {/* Keyed on model and effort: `model_id` alone is not unique across the matrix. */} {matrix.arms.map((arm) => ( ; /** Requests a cooperative cancel. Admin only; the server enforces it. */ cancelRun(runId: string): Promise; - /** A presigned GET for one artefact of `runId`; the server checks the caller and the key. */ - getArtefactUrl(runId: string, key: string): Promise; + /** + * A presigned GET for one artefact of `runId`; the server checks the caller and the key. With + * `download`, the URL serves the object as an attachment. + */ + getArtefactUrl( + runId: string, + key: string, + options?: ArtefactUrlOptions, + ): Promise; } function unreadable(path: string): CrmApiError { @@ -231,10 +249,39 @@ function isRenderableMatrix(raw: unknown): boolean { }); } +/** Whether `raw` is a tier comparison table: string headers, one section per tier in order, each + * row a list of strings as long as `headers`, and string notes. */ +function isTierComparisonTable(raw: unknown): raw is EvalTierComparisonTable { + const table = asRecord(raw); + const headers = table.headers; + const sections = table.sections; + const notes = table.notes; + if (!Array.isArray(headers) || headers.length < 2 || !headers.every((h) => typeof h === "string")) { + return false; + } + if (!Array.isArray(notes) || !notes.every((note) => typeof note === "string")) return false; + if (!Array.isArray(sections) || sections.length !== TIER_COMPARISON_TIERS.length) return false; + return sections.every((candidate: unknown, index) => { + const section = asRecord(candidate); + return ( + section.tier === TIER_COMPARISON_TIERS[index] && + typeof section.heading === "string" && + Array.isArray(section.rows) && + section.rows.every( + (row: unknown) => + Array.isArray(row) && + row.length === headers.length && + row.every((cell: unknown) => typeof cell === "string"), + ) + ); + }); +} + /** * Parse one run, checking the fields the page branches on (`run_id`, `status`, `is_terminal`, * `cancel_requested`), the figures it renders (`tasks_*`, `cost_spent_usd`) and, when present, - * `repeats` and the matrix structure; other display fields are not validated here. + * `repeats` and the matrix structure; other display fields are not validated here. An unreadable + * `tier_comparison_table` is dropped rather than refusing the run. * * @throws CrmApiError when one of those fields is invalid. */ @@ -260,6 +307,11 @@ function parseRun(raw: unknown, path: st ) { throw unreadable(path); } + if (run.tier_comparison_table !== undefined && !isTierComparisonTable(run.tier_comparison_table)) { + const { tier_comparison_table: _unreadableTable, ...rest } = run; + void _unreadableTable; + return rest as unknown as TResponse; + } return run as unknown as TResponse; } @@ -395,8 +447,13 @@ export class HttpEvalRunClient implements EvalRunClient { }); } - getArtefactUrl(runId: string, key: string): Promise { - return this.action({ action: "artefact_url", run_id: runId, key }).then((raw) => { + getArtefactUrl( + runId: string, + key: string, + options: ArtefactUrlOptions = {}, + ): Promise { + const download = options.download === true ? { download: true } : {}; + return this.action({ action: "artefact_url", run_id: runId, key, ...download }).then((raw) => { const response = asRecord(raw); if ( typeof response.url !== "string" || diff --git a/frontend/src/pages/evals/README.md b/frontend/src/pages/evals/README.md index 6effe43..3bb45ae 100644 --- a/frontend/src/pages/evals/README.md +++ b/frontend/src/pages/evals/README.md @@ -16,6 +16,8 @@ each property below is enforced by a test. | **Repeats.** | A "Repeats" select (1 to `MAX_SWEEP_REPEATS`, mirroring `eval.runs.MAX_SWEEP_REPEATS`; default 1) sits above the stub button, and another inside `LiveSweepDialog`. Both submits, and the dialog's `estimate`, add `repeats` only when it is not 1. The dialog re-fetches the estimate for each selection and keeps "Start live sweep" disabled until that selection's estimate has loaded; the sweep size it shows multiplies tasks × arms × the estimate's `repeats`. A run payload without `repeats` reads as 1 (`types.ts` `runRepeats`). | `evals.test.tsx` ("Repeats") | | **Live sweep, admins only.** | "Run live sweep…" opens `LiveSweepDialog`, which fetches `estimate` first. "Start live sweep" stays disabled until an estimate has loaded, then sends `{action: "submit", mode: "live", confirmed: true}`. The sweep size is derived from the estimate. When the estimate's figures were measured at a supervisor effort other than the current default (`eval.sweep_units.DEFAULT_ARM_EFFORT`), the payload carries `effort_caveat` (`eval.runs.ESTIMATE_EFFORT_CAVEAT`), and the dialog shows it under the basis line; with no caveat, nothing is shown. A failed start keeps the dialog open with the reason. | `evals.test.tsx` ("live sweep, admins only", the effort-caveat cells), `src/auth/adminGroup.test.ts`, `tests/unit/test_runs_estimate_effort_caveat.py` | | **Cancel, admins only.** | "Cancel sweep" appears on a `queued` or `running` live run with no cancel requested yet. It is cooperative: the task in flight finishes, and the rest are skipped. | `evals.test.tsx` ("cancel") | +| **Tier comparison summary.** | Above the per-arm results, three tables (Supervisor, Subagent, ToolCall) headed `Metric` plus one column per arm in run order, then the notes that define each row. Every header, cell and note is the run payload's `tier_comparison_table` string (`eval.matrix.tier_comparison_table`, the same function that writes `matrix.md`'s `## Tier comparison summary`), rendered verbatim. A run without the table, or with one `EvalRunClient` cannot read, shows "Tier comparison summary is not available for this run." Cancelled runs with partial results show it as well. | `TierComparisonSummary.test.tsx`, `tests/integration/test_tier_comparison_ui_contract.py` (writes `__fixtures__/tierComparison.json`) | +| **Download matrix.md.** | "Download matrix.md" beside the matrix.md control asks `artefact_url` with `download: true`, which signs the URL with an attachment disposition (`matrix-.md`), and navigates to it, so the browser saves the file and the page stays. A refusal is shown in the artifact list's alert. | `evals.artefacts.test.tsx` | | **Cancelled and failed runs.** | A cancelled run reads `Cancelled after N/total tasks` with its spend, plus partial results when any task finished. A failed run shows the backend's failure summary. | `evals.test.tsx` | Admin status comes from the ID token's `cognito:groups` (`src/auth/adminGroup.ts`) and is @@ -30,7 +32,7 @@ Admin status comes from the ID token's `cognito:groups` (`src/auth/adminGroup.ts | **Prompt-cache minimums are per model**, and cache-attributable cost is reported apart from cost excluding cache. | The arm's `cache_min_checkpoint_tokens`, the cache read/write token counts, and two separate cost fields — never one summed figure. | `evals.annotations.test.tsx` | | **Cost is shown only when the backend marks it publishable.** | Keyed on each record's `cost_withheld_provisional` flag: `true` renders a withheld disclosure, `false` renders the backend-emitted cost fields, absent renders "not displayed". This covers the per-tier summary's `cost_total`. The page computes no cost figure from token counts. | `evals.integrity.test.tsx` (adversarial payloads), `scripts/check_cost_withheld.sh --frontend-dir` (active while `config/pricing.yaml` is `provisional: true`) | | **Run spend is metered spend, live runs only.** | A live run's `cost_spent_usd` is shown as the backend sent it, except a live run with no measured item (`tasks_done` 0, `tasks_failed` above 0), which reads "not measured" rather than a zero figure, beside the errored-items note. A stub run reads "no inference cost (stub)" rather than a zero figure. An unrecognised mode shows no figure. | `evals.test.tsx`, `evals.allFailed.test.tsx` | -| **No verdict, winner, or ranking.** | Arms render in backend order with identical styling and no sort affordance; nothing labels a model. The history table has no sort affordance either. | `evals.test.tsx` (including a source scan) + `evals.integrity.test.tsx` | +| **No verdict, winner, or ranking.** | Arms render in backend order with identical styling and no sort affordance; nothing labels a model. The tier comparison columns share one style and have no sort control. The history table has no sort affordance either. | `evals.test.tsx` (including a source scan) + `evals.integrity.test.tsx` | Absent values are named rather than blanked or zeroed: an unscored outcome renders `unscored`, an absent token count renders `not reported`, a model with no documented cache threshold renders @@ -48,7 +50,9 @@ reads `not applicable` for its success rate. | `RunHistory.tsx` | The history table. | | `LiveSweepDialog.tsx` | The Repeats select (`RepeatsSelect`, also used for the stub sweep), the estimate for the selected repeats with its effort caveat when the payload carries one, then the confirmed live submit. | | `EvalArmResults.tsx` | One arm: the mode-provenance disclosure, the annotated measurement list, the per-tier summary (`tier_summary`), the per-tier/per-tool blocks, and the per-task table. | -| `EvalArtifactList.tsx` | Opens `matrix.json`, `matrix.md`, `matrix.csv` and the raw per-run JSON. The bucket is private: a click asks `artefact_url` for a presigned GET (valid 300 s, admin or full visibility, only for a key the run recorded) and opens it in a new tab; a refusal is shown as an alert naming the artifact. An unavailable artifact keeps its row and says so. | +| `TierComparisonSummary.tsx` | The tier comparison summary tables and notes, or the unavailable state. | +| `__fixtures__/tierComparison.json` | Generated by `tests/integration/test_tier_comparison_ui_contract.py`; never hand-edited. | +| `EvalArtifactList.tsx` | Opens `matrix.json`, `matrix.md`, `matrix.csv` and the raw per-run JSON, and downloads `matrix.md`. The bucket is private: a click asks `artefact_url` for a presigned GET (valid 300 s, admin or full visibility, only for a key the run recorded) and opens it in a new tab; a refusal is shown as an alert naming the artifact. An unavailable artifact keeps its row and says so. | | `runMode.ts` | The single classifier for a run's reported `mode`: `stub`, `live`, or `unrecognised`. | | `types.ts` | Hand-written mirror of the harness's wire shapes. | | `testFixtures.ts` | `jobPayload()` and `BaseFakeEvalRunClient`, a compliant backend for the tests. | diff --git a/frontend/src/pages/evals/TierComparisonSummary.test.tsx b/frontend/src/pages/evals/TierComparisonSummary.test.tsx new file mode 100644 index 0000000..905b554 --- /dev/null +++ b/frontend/src/pages/evals/TierComparisonSummary.test.tsx @@ -0,0 +1,273 @@ +// SPDX-License-Identifier: MIT +/** + * The tier comparison summary renders the backend's `tier_comparison_table` cell for cell. The + * fixture is written by `tests/integration/test_tier_comparison_ui_contract.py` from the same + * function that renders `matrix.md`, so a reformatted cell here diverges from the file. + */ +import { readFileSync } from "node:fs"; +import { join } from "node:path"; + +import { cleanup, render, screen, waitFor, within } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; +import { afterEach, describe, expect, it, vi } from "vitest"; + +import type { AuthContextValue } from "../../auth/AuthProvider"; +import { EvalDashboardPage } from "./EvalDashboardPage"; +import { HttpEvalRunClient } from "./EvalRunClient"; +import { BaseFakeEvalRunClient, jobPayload } from "./testFixtures"; +import { TIER_COMPARISON_UNAVAILABLE, TierComparisonSummary } from "./TierComparisonSummary"; +import type { EvalArm, EvalTierComparisonTable } from "./types"; + +type FixtureCase = "multi_arm" | "single_arm"; + +const FIXTURE = JSON.parse( + readFileSync(join(__dirname, "__fixtures__", "tierComparison.json"), "utf-8"), +) as Record; + +function fixtureTable(name: FixtureCase): EvalTierComparisonTable { + return FIXTURE[name].tier_comparison_table; +} + +const POLL_MS = 5; + +const fakeAuth: AuthContextValue = { + status: "signed-in", + identity: { + userId: "user-1", + repId: "rep-1", + book: [], + fullVisibility: true, + expiresAt: 9_999_999_999, + }, + signIn: vi.fn(), + signOut: vi.fn(), + getAccessToken: vi.fn().mockResolvedValue("tok-123"), +}; + +function arm(modelId: string): EvalArm { + return { + provenance: { + mode: "stub", + timestamp: "2026-11-06T00:00:00Z", + model_id: modelId, + effort: "medium", + dataset_seed: 20261106, + git_revision: "not-a-commit", + runtime_identifier: "local-stub", + price_table_version: "v1", + }, + model_metrics: { model_id: modelId, included_invocation_count: 2, cost_withheld_provisional: true }, + aggregate_score: { mean_correctness: 0.5, scored_task_count: 2, unscored_task_count: 0, bad_write_rate: 0 }, + task_scores: [{ task_id: "gt-01", correctness: 1.0, bad_write: false }], + }; +} + +/** Header cells, then every body row's cells, as the DOM renders them. */ +function renderedTable(table: HTMLElement): { headers: string[]; rows: string[][] } { + const headers = within(table) + .getAllByRole("columnheader") + .map((cell) => cell.textContent ?? ""); + const bodyRows = within(table).getAllByRole("row").slice(1); + const rows = bodyRows.map((row) => + Array.from(row.querySelectorAll("th, td")).map((cell) => cell.textContent ?? ""), + ); + return { headers, rows }; +} + +afterEach(() => { + cleanup(); + vi.unstubAllGlobals(); +}); + +/** A note's text as rendered: the markdown code-span markers of a balanced note removed. */ +function withoutCodeSpanMarkers(note: string): string { + return note.split("`").length % 2 === 1 ? note.split("`").join("") : note; +} + +describe("TierComparisonSummary — verbatim cells", () => { + it.each(["multi_arm", "single_arm"])( + "renders every header, cell and note of the %s fixture exactly as sent", + (name) => { + const table = fixtureTable(name); + render(); + + const summary = screen.getByTestId("tier-comparison-summary"); + for (const section of table.sections) { + const element = within(summary).getByTestId(`tier-comparison-table-${section.tier}`); + expect(within(element).getByText(section.heading, { selector: "caption" })).toBeInTheDocument(); + expect(renderedTable(element)).toEqual({ + headers: [...table.headers], + rows: section.rows.map((row) => [...row]), + }); + } + const notes = within(summary).getByRole("list", { name: /notes on the tier comparison/i }); + expect(within(notes).getAllByRole("listitem").map((item) => item.textContent)).toEqual( + table.notes.map(withoutCodeSpanMarkers), + ); + }, + ); + + it("renders the three tiers in the backend's order under their own headings", () => { + render(); + const tables = screen.getAllByRole("table"); + expect(tables.map((t) => t.getAttribute("data-testid"))).toEqual([ + "tier-comparison-table-supervisor", + "tier-comparison-table-subagent", + "tier-comparison-table-tool", + ]); + expect(tables.map((t) => t.querySelector("caption")?.textContent)).toEqual([ + "Supervisor", + "Subagent", + "ToolCall", + ]); + }); + + it("carries the fixture's em dash, withheld, not measured and not applicable cells unchanged", () => { + render(); + const cells = screen.getAllByRole("cell").map((cell) => cell.textContent); + for (const literal of ["—", "withheld", "not measured", "not applicable", "n/a"]) { + expect(cells, literal).toContain(literal); + } + }); + + it("gives one column per arm and the label column, for one arm as for two", () => { + for (const name of ["multi_arm", "single_arm"] as const) { + const table = fixtureTable(name); + const { unmount } = render(); + for (const element of screen.getAllByRole("table")) { + expect(within(element).getAllByRole("columnheader")).toHaveLength(table.headers.length); + } + unmount(); + } + }); + + it("offers no sort control and styles every arm column identically", () => { + render(); + const summary = screen.getByTestId("tier-comparison-summary"); + expect(within(summary).queryAllByRole("button")).toEqual([]); + expect(summary.querySelectorAll("[aria-sort]")).toHaveLength(0); + const cellClasses = new Set(within(summary).getAllByRole("cell").map((cell) => cell.className)); + expect(cellClasses.size).toBe(1); + const headerClasses = new Set( + within(summary) + .getAllByRole("columnheader") + .map((cell) => cell.className), + ); + expect(headerClasses.size).toBe(1); + }); + + it("states that the summary is not available when the run carries no table", () => { + render(); + expect(screen.getByTestId("tier-comparison-unavailable")).toHaveTextContent( + TIER_COMPARISON_UNAVAILABLE, + ); + expect(screen.queryAllByRole("table")).toEqual([]); + }); +}); + +describe("TierComparisonSummary — markdown code spans in notes", () => { + const CODE_NOTE = + 'Effort labels are not equivalent across families; see `effort` under "Reading these figures".'; + + it("renders a note's inline code span as , with no backtick left in the text", () => { + const table = { ...fixtureTable("multi_arm"), notes: [CODE_NOTE] }; + render(); + + const notes = screen.getByRole("list", { name: /notes on the tier comparison/i }); + const [item] = within(notes).getAllByRole("listitem"); + expect(item.textContent).toBe( + 'Effort labels are not equivalent across families; see effort under "Reading these figures".', + ); + expect([...item.querySelectorAll("code")].map((code) => code.textContent)).toEqual(["effort"]); + }); + + it("renders every code span of a note, and keeps a note with an unpaired backtick verbatim", () => { + const table = { + ...fixtureTable("multi_arm"), + notes: ["a `b` c `d`", "no spans", "one ` stray"], + }; + render(); + + const notes = screen.getByRole("list", { name: /notes on the tier comparison/i }); + const items = within(notes).getAllByRole("listitem"); + expect(items.map((item) => item.textContent)).toEqual(["a b c d", "no spans", "one ` stray"]); + expect(items.map((item) => [...item.querySelectorAll("code")].map((c) => c.textContent))).toEqual( + [["b", "d"], [], []], + ); + }); +}); + +describe("EvalDashboardPage — tier comparison summary placement", () => { + function runWith(status: "completed" | "cancelled", table?: EvalTierComparisonTable) { + return { + ...jobPayload({ status }), + matrix: { arms: [arm("anthropic.claude-sonnet-5-5"), arm("openai.gpt-6-1-sol")] }, + ...(table === undefined ? {} : { tier_comparison_table: table }), + }; + } + + async function renderFocused(run: ReturnType): Promise { + const client = new BaseFakeEvalRunClient([run]); + render( + , + ); + await userEvent.click(screen.getByRole("button", { name: /run stub sweep/i })); + await waitFor(() => expect(screen.getByTestId("tier-comparison-summary")).toBeInTheDocument(), { + timeout: 4000, + }); + } + + it("renders the summary above the per-arm results of a completed run", async () => { + await renderFocused(runWith("completed", fixtureTable("multi_arm"))); + const summary = screen.getByTestId("tier-comparison-summary"); + const firstArm = screen.getByRole("region", { name: /anthropic\.claude-sonnet-5-5/ }); + expect(summary.compareDocumentPosition(firstArm) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy(); + expect(screen.getAllByTestId(/^tier-comparison-table-/)).toHaveLength(3); + }); + + it("renders the summary of a cancelled run's partial results", async () => { + await renderFocused(runWith("cancelled", fixtureTable("single_arm"))); + expect(screen.getAllByTestId(/^tier-comparison-table-/)).toHaveLength(3); + expect(screen.queryByTestId("tier-comparison-unavailable")).not.toBeInTheDocument(); + }); + + it("states the summary is unavailable for a run recorded without one", async () => { + await renderFocused(runWith("completed")); + expect(screen.getByTestId("tier-comparison-unavailable")).toHaveTextContent( + TIER_COMPARISON_UNAVAILABLE, + ); + }); +}); + +describe("HttpEvalRunClient — tier_comparison_table parsing", () => { + function clientReturning(body: unknown): HttpEvalRunClient { + vi.stubGlobal( + "fetch", + vi.fn().mockResolvedValue({ ok: true, json: () => Promise.resolve(body) }), + ); + return new HttpEvalRunClient("/api", { getAccessToken: () => Promise.resolve("tok") }); + } + + it("keeps a well-formed table exactly as sent", async () => { + const table = fixtureTable("multi_arm"); + const run = await clientReturning({ ...jobPayload({ status: "completed" }), tier_comparison_table: table }) + .getRunStatus("run-1"); + expect(run.tier_comparison_table).toEqual(table); + }); + + it.each<[string, (table: EvalTierComparisonTable) => unknown]>([ + ["a missing tier", (t) => ({ ...t, sections: t.sections.slice(0, 2) })], + ["tiers out of order", (t) => ({ ...t, sections: [...t.sections].reverse() })], + ["a numeric cell", (t) => ({ ...t, sections: t.sections.map((s) => ({ ...s, rows: s.rows.map((r) => [r[0], 1, ...r.slice(2)]) })) })], + ["a short row", (t) => ({ ...t, sections: t.sections.map((s) => ({ ...s, rows: s.rows.map((r) => r.slice(1)) })) })], + ["a non-string note", (t) => ({ ...t, notes: [7] })], + ["no headers", (t) => ({ ...t, headers: undefined })], + ])("drops a table with %s and still returns the run", async (_label, corrupt) => { + const run = await clientReturning({ + ...jobPayload({ status: "completed" }), + tier_comparison_table: corrupt(fixtureTable("multi_arm")), + }).getRunStatus("run-1"); + expect(run.run_id).toBe(jobPayload().run_id); + expect(run).not.toHaveProperty("tier_comparison_table"); + }); +}); diff --git a/frontend/src/pages/evals/TierComparisonSummary.tsx b/frontend/src/pages/evals/TierComparisonSummary.tsx new file mode 100644 index 0000000..4ac1452 --- /dev/null +++ b/frontend/src/pages/evals/TierComparisonSummary.tsx @@ -0,0 +1,132 @@ +// SPDX-License-Identifier: MIT +/** + * The run's tier comparison summary: one table per tier (Supervisor, Subagent, ToolCall) with a + * `Metric` column and one column per arm in run order, then the notes that define each row. + * + * Every header, cell and note is the backend's string (`tier_comparison_table`), rendered verbatim, + * so the page shows exactly the section `matrix.md` carries. Notes are markdown there; their inline + * code spans (`` `x` ``) render as ``, and nothing else in a note is interpreted. Columns share + * one style and offer no sort control. Without a table the section says the summary is not available. + */ +import type { JSX } from "react"; + +import type { EvalTierComparisonTable } from "./types"; + +export const TIER_COMPARISON_UNAVAILABLE = "Tier comparison summary is not available for this run."; + +const INTRO = + "Per-tier figures for each arm, one column per arm in run order; the notes below the tables " + + "define each row."; + +const SECTION = "rounded-surface border border-hairline border-border-subtle bg-surface-raised"; +const HEADING = + "border-b-hairline border-border-subtle px-6 py-5 font-sans text-lg font-semibold leading-snug text-text-primary"; +const PROSE = "max-w-prose px-6 pt-5 font-sans text-sm leading-relaxed text-text-secondary"; +const TABLE_WRAP = "w-full overflow-x-auto"; +const TABLE = "w-full min-w-max border-collapse font-sans text-sm text-text-primary"; +const CAPTION = + "px-6 pb-2 pt-6 text-left font-sans text-sm font-semibold leading-snug text-text-primary"; +const COLUMN_HEADER = + "h-row-dense px-cell-x text-left align-middle font-sans text-2xs font-semibold text-text-secondary"; +const ROW_HEADER = + "px-cell-x py-cell-y text-left align-middle font-sans text-xs font-medium text-text-primary"; +const CELL = "px-cell-x py-cell-y align-middle font-numeric text-xs tabular-nums text-text-primary"; +const NOTES = "flex max-w-prose list-disc flex-col gap-2 px-6 pb-6 pl-10 pt-5"; +const NOTE = "font-sans text-2xs leading-normal text-text-muted"; +const NOTE_CODE = "font-numeric text-2xs text-text-primary"; +const UNAVAILABLE = + "m-6 rounded-control border border-hairline border-dashed border-empty-border bg-empty-surface px-5 py-4 font-sans text-sm leading-snug text-empty-text"; + +/** One run of a note's text: inside an inline code span or not. */ +interface NotePart { + readonly code: boolean; + readonly text: string; +} + +/** + * Split a markdown note into its inline code spans and the text around them. A note with an unpaired + * backtick is returned whole, as plain text. + */ +function noteParts(note: string): readonly NotePart[] { + const pieces = note.split("`"); + if (pieces.length % 2 === 0) return [{ code: false, text: note }]; + return pieces + .map((text, index) => ({ code: index % 2 === 1, text })) + .filter((part) => part.code || part.text !== ""); +} + +export interface TierComparisonSummaryProps { + /** The run payload's `tier_comparison_table`; `undefined` renders the unavailable state. */ + readonly table?: EvalTierComparisonTable; +} + +export function TierComparisonSummary({ table }: TierComparisonSummaryProps): JSX.Element { + return ( +
+

+ Tier comparison summary +

+ {table === undefined ? ( +

+ {TIER_COMPARISON_UNAVAILABLE} +

+ ) : ( + <> +

{INTRO}

+ {table.sections.map((section) => ( +
+
+ + + + {table.headers.map((header, index) => ( + + ))} + + + + {section.rows.map(([label, ...cells], rowIndex) => ( + + + {cells.map((cell, cellIndex) => ( + + ))} + + ))} + +
{section.heading}
+ {header} +
+ {label} + + {cell} +
+ + ))} +

    + {table.notes.map((note, index) => ( +
  • + {noteParts(note).map((part, partIndex) => + part.code ? ( + + {part.text} + + ) : ( + part.text + ), + )} +
  • + ))} +
+ + )} + + ); +} diff --git a/frontend/src/pages/evals/__fixtures__/tierComparison.json b/frontend/src/pages/evals/__fixtures__/tierComparison.json new file mode 100644 index 0000000..dab09dd --- /dev/null +++ b/frontend/src/pages/evals/__fixtures__/tierComparison.json @@ -0,0 +1,489 @@ +{ + "multi_arm": { + "tier_comparison_table": { + "headers": [ + "Metric", + "anthropic", + "openai" + ], + "sections": [ + { + "tier": "supervisor", + "heading": "Supervisor", + "rows": [ + [ + "Model", + "anthropic.claude-sonnet-5-5", + "openai.gpt-6-1-sol" + ], + [ + "Effort", + "medium", + "medium" + ], + [ + "Task completion rate", + "0.750000 (3/4)", + "0.500000 (2/4)" + ], + [ + "Task completion over repeats", + "n/a", + "n/a" + ], + [ + "Task accuracy", + "0.750000", + "0.500000" + ], + [ + "Cost per completed task", + "withheld", + "withheld" + ], + [ + "P95 latency per completed task (ms)", + "not measured", + "not measured" + ], + [ + "P50 latency per completed task (ms)", + "not measured", + "not measured" + ], + [ + "Model invocations", + "2", + "2" + ], + [ + "Input tokens", + "100", + "100" + ], + [ + "Output tokens", + "10", + "10" + ], + [ + "Cost per task, all tasks", + "withheld", + "withheld" + ], + [ + "Self-corrected retries", + "0", + "—" + ], + [ + "Budget-exhausted tasks", + "0", + "0" + ] + ] + }, + { + "tier": "subagent", + "heading": "Subagent", + "rows": [ + [ + "Model", + "anthropic.claude-haiku-5-5", + "openai.gpt-6-1-luna" + ], + [ + "Effort", + "low", + "low" + ], + [ + "Task completion rate", + "0.666667 (2/3)", + "not applicable" + ], + [ + "Task completion over repeats", + "n/a", + "n/a" + ], + [ + "Task accuracy", + "0.666667", + "not applicable" + ], + [ + "Cost per completed task", + "withheld", + "withheld" + ], + [ + "P95 latency per completed task (ms)", + "not measured", + "not measured" + ], + [ + "P50 latency per completed task (ms)", + "not measured", + "not measured" + ], + [ + "Model invocations", + "2", + "2" + ], + [ + "Input tokens", + "200", + "200" + ], + [ + "Output tokens", + "20", + "20" + ], + [ + "Cost per task, all tasks", + "withheld", + "withheld" + ], + [ + "Self-corrected retries", + "0", + "—" + ], + [ + "Delegation outcome: data", + "2", + "0" + ], + [ + "Delegation outcome: no_match", + "0", + "0" + ], + [ + "Delegation outcome: denied", + "1", + "0" + ], + [ + "Delegation outcome: tool_failure", + "0", + "0" + ], + [ + "Delegation outcome: none", + "1", + "4" + ] + ] + }, + { + "tier": "tool", + "heading": "ToolCall", + "rows": [ + [ + "Model", + "anthropic.claude-haiku-5-5", + "openai.gpt-6-1-luna" + ], + [ + "Effort", + "low", + "low" + ], + [ + "Task completion rate", + "0.500000 (1/2)", + "1.000000 (2/2)" + ], + [ + "Task completion over repeats", + "n/a", + "n/a" + ], + [ + "Task accuracy", + "0.500000", + "1.000000" + ], + [ + "Cost per completed task", + "withheld", + "withheld" + ], + [ + "P95 latency per completed task (ms)", + "not measured", + "not measured" + ], + [ + "P50 latency per completed task (ms)", + "not measured", + "not measured" + ], + [ + "Model invocations", + "2", + "2" + ], + [ + "Input tokens", + "300", + "300" + ], + [ + "Output tokens", + "30", + "30" + ], + [ + "Cost per task, all tasks", + "withheld", + "withheld" + ], + [ + "Self-corrected retries", + "not applicable", + "not applicable" + ], + [ + "Truncated tasks", + "0", + "0" + ] + ] + } + ], + "notes": [ + "Model lists the tier's configured model and every model that spent tokens at the tier; Effort lists the efforts the tier's turns ran at, with unsupported for a model that takes no effort setting. Task completion rate is rate (met/applicable) over the arm's tasks applicable at the tier, where n is the applicable task count: at Supervisor a task's correctness is 1.0, at Subagent the observed delegation outcome equals the expected one, and at ToolCall an expected tool was called with schema-valid arguments. Task accuracy is the arm's mean_correctness at Supervisor and the completion rate at Subagent and ToolCall. Task completion over repeats is rate (completed/applicable) over the arm's tasks applicable at the tier in any repeat, where a task counts when its tier expectation was met in a strict majority of its applicable repeats, and N is the per-task repeat count. Cost per completed task divides the tier's total cost by its completed task count, so spend on tasks that did not complete is included; Cost per task, all tasks divides the same total by every task the arm ran. Latency per completed task sums the tier's measured call latencies within each completed task and takes the nearest-rank percentile over those tasks; a completed task with no measured call at the tier contributes no sample, and n counts the contributing tasks. Model invocations sums the tier's included invocations. Self-corrected retries counts the tier's tool calls whose tool_failure result was followed, later in the same task, by a call to the same tool from the same role that returned data or no_match; such a call does not set the task's delegation outcome. ToolCall makes one call per invocation, so that row is not applicable there.", + "Columns are the sweep's arms in run order, not sorted by any result, and no difference or ratio between columns is computed.", + "Effort labels are not equivalent across families: each family declares its own effort scale (config/model_capabilities.yaml, effort_scale_comparability); see `effort` under \"Reading these figures\".", + "Input tokens are each family's own reported count and are not like-for-like across families (token_accounting_disclosure, src/eval/matrix.py); see `input_tokens` comparability under \"Reading these figures\".", + "Stub-mode columns ran the deterministic stub provider: no live model was invoked, so latency is not measured there.", + "Cost cells read withheld where the price table is marked provisional." + ] + } + }, + "single_arm": { + "tier_comparison_table": { + "headers": [ + "Metric", + "anthropic" + ], + "sections": [ + { + "tier": "supervisor", + "heading": "Supervisor", + "rows": [ + [ + "Model", + "anthropic.claude-opus-5-5" + ], + [ + "Effort", + "medium" + ], + [ + "Task completion rate", + "1.000000 (1/1)" + ], + [ + "Task completion over repeats", + "n/a" + ], + [ + "Task accuracy", + "1.000000" + ], + [ + "Cost per completed task", + "withheld" + ], + [ + "P95 latency per completed task (ms)", + "not measured" + ], + [ + "P50 latency per completed task (ms)", + "not measured" + ], + [ + "Model invocations", + "2" + ], + [ + "Input tokens", + "100" + ], + [ + "Output tokens", + "10" + ], + [ + "Cost per task, all tasks", + "withheld" + ], + [ + "Self-corrected retries", + "0" + ], + [ + "Budget-exhausted tasks", + "0" + ] + ] + }, + { + "tier": "subagent", + "heading": "Subagent", + "rows": [ + [ + "Model", + "anthropic.claude-sonnet-5-5" + ], + [ + "Effort", + "low" + ], + [ + "Task completion rate", + "1.000000 (1/1)" + ], + [ + "Task completion over repeats", + "n/a" + ], + [ + "Task accuracy", + "1.000000" + ], + [ + "Cost per completed task", + "withheld" + ], + [ + "P95 latency per completed task (ms)", + "not measured" + ], + [ + "P50 latency per completed task (ms)", + "not measured" + ], + [ + "Model invocations", + "2" + ], + [ + "Input tokens", + "200" + ], + [ + "Output tokens", + "20" + ], + [ + "Cost per task, all tasks", + "withheld" + ], + [ + "Self-corrected retries", + "0" + ], + [ + "Delegation outcome: data", + "1" + ], + [ + "Delegation outcome: no_match", + "0" + ], + [ + "Delegation outcome: denied", + "0" + ], + [ + "Delegation outcome: tool_failure", + "0" + ], + [ + "Delegation outcome: none", + "0" + ] + ] + }, + { + "tier": "tool", + "heading": "ToolCall", + "rows": [ + [ + "Model", + "anthropic.claude-haiku-5-5" + ], + [ + "Effort", + "low" + ], + [ + "Task completion rate", + "0.000000 (0/1)" + ], + [ + "Task completion over repeats", + "n/a" + ], + [ + "Task accuracy", + "0.000000" + ], + [ + "Cost per completed task", + "withheld" + ], + [ + "P95 latency per completed task (ms)", + "not measured" + ], + [ + "P50 latency per completed task (ms)", + "not measured" + ], + [ + "Model invocations", + "2" + ], + [ + "Input tokens", + "300" + ], + [ + "Output tokens", + "30" + ], + [ + "Cost per task, all tasks", + "withheld" + ], + [ + "Self-corrected retries", + "not applicable" + ], + [ + "Truncated tasks", + "0" + ] + ] + } + ], + "notes": [ + "Model lists the tier's configured model and every model that spent tokens at the tier; Effort lists the efforts the tier's turns ran at, with unsupported for a model that takes no effort setting. Task completion rate is rate (met/applicable) over the arm's tasks applicable at the tier, where n is the applicable task count: at Supervisor a task's correctness is 1.0, at Subagent the observed delegation outcome equals the expected one, and at ToolCall an expected tool was called with schema-valid arguments. Task accuracy is the arm's mean_correctness at Supervisor and the completion rate at Subagent and ToolCall. Task completion over repeats is rate (completed/applicable) over the arm's tasks applicable at the tier in any repeat, where a task counts when its tier expectation was met in a strict majority of its applicable repeats, and N is the per-task repeat count. Cost per completed task divides the tier's total cost by its completed task count, so spend on tasks that did not complete is included; Cost per task, all tasks divides the same total by every task the arm ran. Latency per completed task sums the tier's measured call latencies within each completed task and takes the nearest-rank percentile over those tasks; a completed task with no measured call at the tier contributes no sample, and n counts the contributing tasks. Model invocations sums the tier's included invocations. Self-corrected retries counts the tier's tool calls whose tool_failure result was followed, later in the same task, by a call to the same tool from the same role that returned data or no_match; such a call does not set the task's delegation outcome. ToolCall makes one call per invocation, so that row is not applicable there.", + "Columns are the sweep's arms in run order, not sorted by any result, and no difference or ratio between columns is computed.", + "Effort labels are not equivalent across families: each family declares its own effort scale (config/model_capabilities.yaml, effort_scale_comparability); see `effort` under \"Reading these figures\".", + "Input tokens are each family's own reported count and are not like-for-like across families (token_accounting_disclosure, src/eval/matrix.py); see `input_tokens` comparability under \"Reading these figures\".", + "Stub-mode columns ran the deterministic stub provider: no live model was invoked, so latency is not measured there.", + "Cost cells read withheld where the price table is marked provisional." + ] + } + } +} diff --git a/frontend/src/pages/evals/evals.artefacts.test.tsx b/frontend/src/pages/evals/evals.artefacts.test.tsx index 38196f3..8bf8d31 100644 --- a/frontend/src/pages/evals/evals.artefacts.test.tsx +++ b/frontend/src/pages/evals/evals.artefacts.test.tsx @@ -12,6 +12,7 @@ import { afterEach, describe, expect, it, vi } from "vitest"; import { CrmApiError } from "../../api/CrmApiClient"; import { EvalArtifactList } from "./EvalArtifactList"; import { HttpEvalRunClient } from "./EvalRunClient"; +import type { ArtefactUrlOptions, EvalArtefactUrlResponse } from "./EvalRunClient"; import { BaseFakeEvalRunClient } from "./testFixtures"; import type { EvalArtifactLinks } from "./types"; @@ -44,7 +45,7 @@ afterEach(() => { describe("EvalArtifactList — presigned artefact URLs", () => { it.each<[string, RegExp | string, string]>([ ["matrix.json", /matrix\.json/i, "matrix.json"], - ["matrix.md", /matrix\.md/i, "matrix.md"], + ["matrix.md", /^matrix\.md/i, "matrix.md"], ["matrix.csv", /matrix\.csv/i, "matrix.csv"], ["a raw archive", RAW_KEY, RAW_KEY], ])("clicking %s requests that one key and opens the presigned URL in a new tab", async (_l, name, key) => { @@ -101,6 +102,86 @@ describe("EvalArtifactList — presigned artefact URLs", () => { }); }); +/** Records each request's `download` option beside the base fake's key log. */ +class DownloadRecordingClient extends BaseFakeEvalRunClient { + public readonly downloadOptions: (ArtefactUrlOptions | undefined)[] = []; + + override getArtefactUrl( + runId: string, + key: string, + options?: ArtefactUrlOptions, + ): Promise { + this.downloadOptions.push(options); + return super.getArtefactUrl(runId, key); + } +} + +describe("EvalArtifactList — Download matrix.md", () => { + it("asks for matrix.md as an attachment and navigates to the returned URL", async () => { + const open = vi.fn(); + vi.stubGlobal("open", open); + const assign = vi.fn(); + vi.stubGlobal("location", { ...window.location, assign }); + const client = new DownloadRecordingClient(); + render(); + + await userEvent.click(screen.getByTestId("download-matrix-md")); + + await waitFor(() => + expect(assign).toHaveBeenCalledWith("https://artefacts.example.test/run-9/matrix.md?X-Amz-Expires=300"), + ); + expect(client.artefactRequests).toEqual([{ runId: "run-9", key: "matrix.md" }]); + expect(client.downloadOptions).toEqual([{ download: true }]); + expect(open).not.toHaveBeenCalled(); + expect(screen.queryByRole("alert")).not.toBeInTheDocument(); + }); + + it("is named for what it does and sits beside the open control", () => { + render(); + const button = screen.getByTestId("download-matrix-md"); + expect(button).toHaveAccessibleName("Download matrix.md"); + expect(button.closest("li")).toBe(screen.getByRole("button", { name: /^matrix\.md/i }).closest("li")); + }); + + it("opening matrix.md still asks for no attachment", async () => { + stubWindowOpen(); + const client = new DownloadRecordingClient(); + render(); + await userEvent.click(screen.getByRole("button", { name: /^matrix\.md/i })); + await waitFor(() => expect(client.downloadOptions).toEqual([undefined])); + }); + + it("states a refusal in the existing alert", async () => { + const assign = vi.fn(); + vi.stubGlobal("location", { ...window.location, assign }); + const client = new BaseFakeEvalRunClient([], { + artefactError: new CrmApiError("scope_denied", 403, { + message: "Reading evaluation artefacts requires full tenant visibility.", + }), + }); + render(); + + await userEvent.click(screen.getByTestId("download-matrix-md")); + + const alert = await screen.findByRole("alert"); + expect(alert).toHaveTextContent(/could not download matrix\.md/i); + expect(alert).toHaveTextContent(/full tenant visibility/i); + expect(assign).not.toHaveBeenCalled(); + }); + + it("is absent when the run recorded no matrix.md", () => { + render( + , + ); + expect(screen.queryByTestId("download-matrix-md")).not.toBeInTheDocument(); + expect(screen.getByText(/matrix\.md — not available/)).toBeInTheDocument(); + }); +}); + describe("HttpEvalRunClient.getArtefactUrl", () => { function clientWith(response: unknown): { client: HttpEvalRunClient; fetchMock: ReturnType } { const fetchMock = vi.fn().mockResolvedValue({ ok: true, json: () => Promise.resolve(response) }); @@ -131,6 +212,17 @@ describe("HttpEvalRunClient.getArtefactUrl", () => { }); }); + it("adds download: true only when asked", async () => { + const { client, fetchMock } = clientWith(reply); + await client.getArtefactUrl("run-7", "matrix.json", { download: true }); + await client.getArtefactUrl("run-7", "matrix.json", { download: false }); + const bodies = fetchMock.mock.calls.map(([, init]) => JSON.parse((init as RequestInit).body as string)); + expect(bodies).toEqual([ + { action: "artefact_url", run_id: "run-7", key: "matrix.json", download: true }, + { action: "artefact_url", run_id: "run-7", key: "matrix.json" }, + ]); + }); + it.each<[string, unknown]>([ ["a plain-http URL", { ...reply, url: "http://bucket.s3.amazonaws.com/x" }], ["no URL", { ...reply, url: undefined }], diff --git a/frontend/src/pages/evals/evals.test.tsx b/frontend/src/pages/evals/evals.test.tsx index 45df515..7e680f3 100644 --- a/frontend/src/pages/evals/evals.test.tsx +++ b/frontend/src/pages/evals/evals.test.tsx @@ -187,7 +187,7 @@ describe("EvalDashboardPage — progress and results rendering", () => { // All four artifact kinds present, each opened through a presigned URL rather than a raw path // (`evals.artefacts.test.tsx`). - for (const name of [/matrix\.json/i, /matrix\.md/i, /matrix\.csv/i, "/results/raw/run-1-anthropic.json"]) { + for (const name of [/matrix\.json/i, /^matrix\.md/i, /matrix\.csv/i, "/results/raw/run-1-anthropic.json"]) { expect(screen.getByRole("button", { name })).toBeEnabled(); } expect(screen.queryByRole("link", { name: /matrix\.json/i })).not.toBeInTheDocument(); diff --git a/frontend/src/pages/evals/types.ts b/frontend/src/pages/evals/types.ts index 04296e7..44f8cd2 100644 --- a/frontend/src/pages/evals/types.ts +++ b/frontend/src/pages/evals/types.ts @@ -255,3 +255,26 @@ export interface EvalArtifactLinks { export function runRepeats(run: { readonly repeats?: number }): number { return run.repeats ?? 1; } + +/** The tier sections of {@link EvalTierComparisonTable}, in the order the backend renders them. */ +export const TIER_COMPARISON_TIERS = ["supervisor", "subagent", "tool"] as const; + +export type EvalComparisonTier = (typeof TIER_COMPARISON_TIERS)[number]; + +/** One tier's table: `rows` are `[label, ...one cell per arm]`, every cell a display string. */ +export interface EvalTierComparisonSection { + readonly tier: EvalComparisonTier; + readonly heading: string; + readonly rows: readonly (readonly string[])[]; +} + +/** + * The run payload's `tier_comparison_table` (`eval.matrix.tier_comparison_table`): the + * `## Tier comparison summary` section of `matrix.md` as cell strings. `headers` is `Metric` then one + * label per arm in run order. Rendered verbatim; the page formats none of it. + */ +export interface EvalTierComparisonTable { + readonly headers: readonly string[]; + readonly sections: readonly EvalTierComparisonSection[]; + readonly notes: readonly string[]; +} diff --git a/frontend/src/test/responseShapes.test.ts b/frontend/src/test/responseShapes.test.ts index a442672..e104d46 100644 --- a/frontend/src/test/responseShapes.test.ts +++ b/frontend/src/test/responseShapes.test.ts @@ -52,7 +52,7 @@ const EXPECTED_ENVELOPES: Readonly> = { list_audit_records: ["audit_records", "next_cursor"], list_proposals: ["next_cursor", "proposals"], log_activity: ["activity", "opportunity"], - pipeline_aggregate: ["forecast_by_close_date", "stage_funnel", "value_rollup"], + pipeline_aggregate: ["forecast_by_close_date", "stage_funnel", "truncated", "value_rollup"], rebase_proposal: ["proposal"], reject_proposal: ["proposal"], revert_audit_record: ["audit_record"], @@ -138,10 +138,11 @@ describe("wire response shapes (derived from crm.handlers, not restated)", () => expect(shapes.get_contact).toEqual(["contact"]); }); - it("pipeline_aggregate: the rollups are the three keys the handler returns", () => { + it("pipeline_aggregate: the three rollups plus the truncation flag the handler returns", () => { expect(shapes.pipeline_aggregate).toEqual([ "forecast_by_close_date", "stage_funnel", + "truncated", "value_rollup", ]); }); diff --git a/infra/main.tf b/infra/main.tf index b0f1c8e..19e5ce9 100644 --- a/infra/main.tf +++ b/infra/main.tf @@ -145,7 +145,7 @@ locals { { table = "activities", actions = ["dynamodb:Query"] }, ] pipeline_aggregate = [ - { table = "opportunities", actions = ["dynamodb:Query", "dynamodb:GetItem"] }, + { table = "opportunities", actions = ["dynamodb:Query", "dynamodb:BatchGetItem"] }, ] # BatchGetItem re-reads the base items, because `gsi_status`/`gsi_tenant` do not project # `before_snapshot`, which the scope check reads. @@ -222,6 +222,9 @@ locals { { table = "opportunities", actions = ["dynamodb:GetItem", "dynamodb:UpdateItem", "dynamodb:DeleteItem"] }, { table = "activities", actions = ["dynamodb:GetItem", "dynamodb:UpdateItem", "dynamodb:DeleteItem"] }, { table = "audit_records", actions = ["dynamodb:PutItem"] }, + # The cascade re-check before approving an account delete; scoped to the indexes in + # `local.tool_query_indexes`, never the base table. + { table = "opportunities", actions = ["dynamodb:Query"] }, ] reject_proposal = [ { table = "proposals", actions = ["dynamodb:GetItem", "dynamodb:UpdateItem"] }, @@ -269,6 +272,9 @@ locals { # A Query-only grant listed here names exactly these GSIs and omits the table ARN; any other Query # grant covers all of its table's GSIs. Mirrors `crm.audit._CHILD_INDEXES`. tool_query_indexes = { + approve_proposal = { + opportunities = ["gsi_account"] + } revert_audit_record = { contacts = ["gsi_account"] opportunities = ["gsi_account"] @@ -644,11 +650,18 @@ module "lambda_action" { timeout_seconds = 30 memory_size_mb = 256 - environment_variables = { - CRM_TABLE_PREFIX = local.name_prefix - } + environment_variables = merge( + { CRM_TABLE_PREFIX = local.name_prefix }, + contains(local.routed_tool_names, each.key) ? { CRM_API_ALLOWED_CLIENT_IDS_PARAMETER = local.api_allowed_client_ids_parameter_name } : {}, + contains(local.cursor_tools, each.key) ? { CRM_CURSOR_KMS_KEY_ARN = aws_kms_key.cursor.arn } : {}, + ) environment_kms_key_arn = module.observability.cloudwatch_logs_kms_key_arn + config_parameter_arns = contains(local.routed_tool_names, each.key) ? [local.api_allowed_client_ids_parameter_arn] : [] + + cursor_kms_key_arn = contains(local.cursor_tools, each.key) ? aws_kms_key.cursor.arn : null + cursor_kms_grant_enabled = contains(local.cursor_tools, each.key) + reserved_concurrent_executions = local.reserved_concurrency[each.key] dynamodb_grants = [ @@ -862,7 +875,8 @@ module "lambda_action_eval_trigger" { memory_size_mb = 512 environment_variables = { - CRM_TABLE_PREFIX = local.name_prefix + CRM_TABLE_PREFIX = local.name_prefix + CRM_API_ALLOWED_CLIENT_IDS_PARAMETER = local.api_allowed_client_ids_parameter_name # Required for this zip's layout: the first-party packages live under `src/`. PYTHONPATH = "/var/task/src" # The state machine `submit_sweep` starts. Constructed: the resource reference is an @@ -873,6 +887,7 @@ module "lambda_action_eval_trigger" { EVAL_ARTIFACTS_PREFIX = module.eval_artifacts.artifact_prefix } environment_kms_key_arn = module.observability.cloudwatch_logs_kms_key_arn + config_parameter_arns = [local.api_allowed_client_ids_parameter_arn] reserved_concurrent_executions = local.reserved_concurrency["eval_trigger"] @@ -922,10 +937,12 @@ module "lambda_action_capabilities" { memory_size_mb = 256 environment_variables = { + CRM_API_ALLOWED_CLIENT_IDS_PARAMETER = local.api_allowed_client_ids_parameter_name # Required for this zip's layout: the first-party packages live under `src/`. PYTHONPATH = "/var/task/src" } environment_kms_key_arn = module.observability.cloudwatch_logs_kms_key_arn + config_parameter_arns = [local.api_allowed_client_ids_parameter_arn] reserved_concurrent_executions = local.reserved_concurrency["capabilities"] @@ -1278,6 +1295,22 @@ module "frontend_cdn" { caller_principal_arn = data.aws_iam_session_context.current.issuer_arn operator_principal_arns = var.crm_operator_principal_arns administrator_principal_arns = concat(var.crm_operator_principal_arns, ["arn:aws:iam::${data.aws_caller_identity.current.account_id}:root"]) + + csp_script_hashes = local.spa_inline_script_hashes + csp_connect_src_extra = local.spa_connect_src_extra +} + +# The SPA's Content-Security-Policy sources: the hash of each attribute-less inline `", file("${path.module}/../frontend/index.html")) : + "sha256-${base64sha256(script[0])}" + ] + spa_connect_src_extra = [ + "https://cognito-idp.${var.aws_region}.amazonaws.com", + "https://${module.cognito.domain}.auth.${var.aws_region}.amazoncognito.com", + ] } # --------------------------------------------------------------------------- @@ -1400,6 +1433,133 @@ module "eval_artifacts" { administrator_principal_arns = concat(var.crm_operator_principal_arns, ["arn:aws:iam::${data.aws_caller_identity.current.account_id}:root"]) } +# --------------------------------------------------------------------------- +# cursor — the CMK sealing pagination cursors (KMS Encrypt/Decrypt under the +# `purpose = crm-cursor` encryption context), used by the five paginating tools. +# --------------------------------------------------------------------------- + +locals { + cursor_tools = ["search_opportunities", "search_accounts", "list_activities", "list_audit_records", "list_proposals"] + + # Listed by static index, so the key policy does not wait on every `module.lambda_action` instance. + cursor_key_principal_arns = [ + module.lambda_action["search_opportunities"].role_arn, + module.lambda_action["search_accounts"].role_arn, + module.lambda_action["list_activities"].role_arn, + module.lambda_action["list_audit_records"].role_arn, + module.lambda_action["list_proposals"].role_arn, + ] +} + +resource "aws_kms_key" "cursor" { + # checkov:skip=CKV2_AWS_64: policy managed by aws_kms_key_policy.cursor + description = "${local.name_prefix} pagination cursor sealing" + enable_key_rotation = true + deletion_window_in_days = 7 + + tags = { + "data-classification" = "internal" + } +} + +resource "aws_kms_alias" "cursor" { + name = "alias/${local.name_prefix}-cursor" + target_key_id = aws_kms_key.cursor.key_id +} + +# Keeps the account-root statement, refuses any use outside the `crm-cursor` context and every +# operation the cursor codec does not call, and denies key use and key administration outside the +# lists. +resource "aws_kms_key_policy" "cursor" { + key_id = aws_kms_key.cursor.id + bypass_policy_lockout_safety_check = false + + lifecycle { + precondition { + condition = contains(concat(var.crm_operator_principal_arns, ["arn:aws:iam::${data.aws_caller_identity.current.account_id}:root"]), data.aws_iam_session_context.current.issuer_arn) && data.aws_iam_session_context.current.issuer_arn != "arn:aws:iam::${data.aws_caller_identity.current.account_id}:root" + error_message = "The caller running this plan is not an operator. Add its role or user ARN to crm_operator_principal_arns in terraform.tfvars, or run as a listed operator; nothing was applied." + } + } + + policy = jsonencode({ + Version = "2012-10-17" + Statement = [ + { + Sid = "EnableIAMUserPermissions" + Effect = "Allow" + Principal = { AWS = "arn:aws:iam::${data.aws_caller_identity.current.account_id}:root" } + Action = "kms:*" + Resource = "*" + }, + { + Sid = "DenyCursorKeyUseOutsidePurpose" + Effect = "Deny" + Principal = "*" + Action = [ + "kms:Decrypt", + "kms:Encrypt", + "kms:GenerateDataKey*", + "kms:ReEncrypt*", + ] + Resource = "*" + Condition = { + StringNotEquals = { "kms:EncryptionContext:purpose" = "crm-cursor" } + } + }, + { + Sid = "DenyCursorKeyUnusedOperations" + Effect = "Deny" + Principal = "*" + Action = [ + "kms:GenerateDataKey*", + "kms:ReEncrypt*", + "kms:CreateGrant", + ] + Resource = "*" + }, + { + Sid = "DenyKeyUseToNonProjectPrincipals" + Effect = "Deny" + Principal = "*" + Action = [ + "kms:Decrypt", + "kms:Encrypt", + "kms:GenerateDataKey*", + "kms:ReEncrypt*", + "kms:CreateGrant", + ] + Resource = "*" + Condition = { + ArnNotEquals = { "aws:PrincipalArn" = concat(local.cursor_key_principal_arns, var.crm_operator_principal_arns) } + Bool = { "aws:PrincipalIsAWSService" = "false" } + } + }, + { + Sid = "DenyKeyAdministrationToNonOperators" + Effect = "Deny" + Principal = "*" + Action = [ + "kms:PutKeyPolicy", + "kms:ScheduleKeyDeletion", + "kms:DisableKey", + "kms:RevokeGrant", + "kms:DisableKeyRotation", + "kms:CreateAlias", + "kms:UpdateAlias", + "kms:DeleteAlias", + "kms:TagResource", + "kms:UntagResource", + "kms:UpdateKeyDescription", + ] + Resource = "*" + Condition = { + ArnNotEquals = { "aws:PrincipalArn" = concat(var.crm_operator_principal_arns, ["arn:aws:iam::${data.aws_caller_identity.current.account_id}:root"]) } + } + }, + ] + }) +} + # --------------------------------------------------------------------------- # agent_relay — the browser's only agent endpoint: a Node.js Lambda with a # RESPONSE_STREAM Function URL, built by `scripts/package_relay.sh`. @@ -1416,6 +1576,25 @@ locals { relay_cognito_audience_parameter_name = "/${local.name_prefix}/relay/cognito-audience" } +# The app client ids `crm.envelope` admits on the API Gateway channel. Delivered through SSM, by a +# constructed name and ARN, because a function attribute referencing the SPA client would cycle +# through the distribution. +locals { + api_allowed_client_ids_parameter_name = "/${local.name_prefix}/api/allowed-client-ids" + api_allowed_client_ids_parameter_arn = "arn:aws:ssm:${var.aws_region}:${data.aws_caller_identity.current.account_id}:parameter${local.api_allowed_client_ids_parameter_name}" +} + +resource "aws_ssm_parameter" "api_allowed_client_ids" { + # checkov:skip=CKV2_AWS_34: holds the SPA client id, a public value, not a secret + name = local.api_allowed_client_ids_parameter_name + type = "String" + value = module.cognito.spa_client_id + + tags = { + "data-classification" = "internal" + } +} + resource "aws_ssm_parameter" "relay_cognito_audience" { # checkov:skip=CKV2_AWS_34: holds the SPA client id, a public value, not a secret name = local.relay_cognito_audience_parameter_name diff --git a/infra/modules/frontend_cdn/README.md b/infra/modules/frontend_cdn/README.md index ede056e..1efa33f 100644 --- a/infra/modules/frontend_cdn/README.md +++ b/infra/modules/frontend_cdn/README.md @@ -15,7 +15,7 @@ baseline](../../../docs/security-baseline.md#h-5). Modules named here: |---|---| | `kms.tf` | customer-managed KMS key (CMK) and alias encrypting the origin bucket | | `s3.tf` | the origin bucket (private, versioned, SSE-KMS, TLS-deny + OAC-only policy, S3 access logging) and a dedicated access-log bucket receiving S3, CloudFront and ALB access logs | -| `cloudfront.tf` | two OACs (S3 and `lambda`-type for the relay), the two distribution-scoped Lambda permissions for the relay, the managed cache/origin-request policies read by data source, `/agent/*`'s own origin-request policy, two viewer-request functions, and the distribution | +| `cloudfront.tf` | two OACs (S3 and `lambda`-type for the relay), the two distribution-scoped Lambda permissions for the relay, the managed cache/origin-request policies read by data source, `/agent/*`'s own origin-request policy, the security-headers response-headers policy (with the CSP), two viewer-request functions, and the distribution | | `functions/api_path_rewrite.js` | `/api/*` viewer-request function, rendered with the stage name by `templatefile` | | `functions/spa_history_fallback.js` | default-behaviour viewer-request function rewriting extensionless paths to the SPA entry point | @@ -36,6 +36,8 @@ baseline](../../../docs/security-baseline.md#h-5). Modules named here: | `operator_principal_arns` | required | IAM role or user ARNs: the only non-service principals allowed frontend-key use and writes into the origin bucket. Non-empty; no `*`, `?` or account root | | `administrator_principal_arns` | required | IAM role or user ARNs, or the account root, allowed to administer the frontend key and the origin bucket. Non-empty; no `*` or `?` | | `caller_principal_arn` | required | role or user ARN of the principal running the plan; the key and origin policies refuse to plan unless it is a listed administrator other than the root | +| `csp_script_hashes` | required | CSP hashes (`sha256-`, unquoted) of the SPA's inline scripts, added to `script-src`. The root derives them at plan time from the attribute-less `", re.DOTALL) + +#: An unauthenticated `/agent/*` probe. The relay refuses it before routing, so any path works. +_UNAUTHENTICATED_AGENT_PATH = "/agent/csp-probe" + +#: `(resource, path, method, unauthenticated)` for each served-header probe. +_CSP_PROBES: tuple[tuple[str, str, str, bool], ...] = ( + ("behavior:/*", "/", "GET", False), + ("behavior:/api/*", _UNAUTHENTICATED_API_PATH, _UNAUTHENTICATED_API_METHOD, True), + ("behavior:/agent/*", _UNAUTHENTICATED_AGENT_PATH, "GET", True), +) + +_CSP_HEADER = "content-security-policy" +_CSP_REPORT_ONLY_HEADER = "content-security-policy-report-only" + + +def _parse_csp(policy: str) -> tuple[dict[str, list[str]], list[str]]: + """Return `{directive: [sources]}` for `policy` and the directives it repeats. + + A repeated directive keeps its first occurrence, as browsers do. + """ + parsed: dict[str, list[str]] = {} + repeated: list[str] = [] + for part in policy.split(";"): + tokens = part.split() + if not tokens: + continue + name = tokens[0].lower() + if name in parsed: + repeated.append(name) + continue + parsed[name] = tokens[1:] + return parsed, repeated + + +def _csp_hash(script_body: str) -> str: + digest = hashlib.sha256(script_body.encode("utf-8")).digest() + return "'sha256-" + base64.b64encode(digest).decode("ascii") + "'" + + +def _csp_design_problems(policy: str) -> list[str]: + """Every way `policy` departs from the designed directive set; empty when it matches.""" + parsed, repeated = _parse_csp(policy) + problems: list[str] = [f"directive {name!r} appears more than once" for name in repeated] + missing = sorted(_CSP_DIRECTIVES - parsed.keys()) + extra = sorted(parsed.keys() - _CSP_DIRECTIVES) + if missing: + problems.append(f"missing directives {missing}") + if extra: + problems.append(f"unexpected directives {extra}") + for name, expected in _CSP_FIXED_DIRECTIVES.items(): + if name in parsed and tuple(parsed[name]) != expected: + problems.append(f"{name} is {parsed[name]}, expected {list(expected)}") + script_src = parsed.get("script-src", []) + if script_src[:1] != ["'self'"] or not all( + _SCRIPT_HASH_SOURCE.match(source) for source in script_src[1:] + ): + problems.append(f"script-src must be 'self' then sha256 hash sources only: {script_src}") + connect_src = parsed.get("connect-src", []) + if connect_src[:1] != ["'self'"] or not all( + source.startswith("https://") and "*" not in source for source in connect_src[1:] + ): + problems.append(f"connect-src must be 'self' then https origins only: {connect_src}") + for name, sources in parsed.items(): + if "'unsafe-eval'" in sources: + problems.append(f"{name} allows 'unsafe-eval'") + if "'unsafe-inline'" in sources and name != "style-src": + problems.append(f"{name} allows 'unsafe-inline'") + return problems + + +def _check_response_headers_policy( + distribution_config: dict[str, Any], cloudfront: Any +) -> tuple[list[CheckResult], str | None]: + """Assert one custom response-headers policy on every behaviour, enforcing the CSP. + + Returns the results and the policy's CSP value, or `None` when it could not be read. + """ + resource = "distribution" + behaviours = [("default", distribution_config.get("DefaultCacheBehavior", {}))] + for behaviour in distribution_config.get("CacheBehaviors", {}).get("Items", []) or []: + behaviours.append((str(behaviour.get("PathPattern")), behaviour)) + ids = {label: behaviour.get("ResponseHeadersPolicyId") for label, behaviour in behaviours} + distinct = set(ids.values()) + results: list[CheckResult] = [] + if None in distinct or "" in distinct or len(distinct) != 1: + results.append( + CheckResult( + resource=resource, + check="one_response_headers_policy_on_every_behaviour", + status="fail", + detail=f"behaviours do not share one ResponseHeadersPolicyId: {ids}", + ) + ) + results.append( + CheckResult( + resource=resource, + check="response_headers_policy_enforces_csp", + status="fail", + detail="no single policy to inspect; see one_response_headers_policy_on_every_behaviour", + ) + ) + return results, None + (policy_id,) = distinct + results.append( + CheckResult( + resource=resource, + check="one_response_headers_policy_on_every_behaviour", + status="pass", + detail=f"every behaviour ({', '.join(ids)}) attaches ResponseHeadersPolicyId {policy_id}", + ) + ) + + custom_ids = { + str(item.get("ResponseHeadersPolicy", {}).get("Id")) + for item in cloudfront.list_response_headers_policies(Type="custom") + .get("ResponseHeadersPolicyList", {}) + .get("Items", []) + or [] + } + config = ( + cloudfront.get_response_headers_policy(Id=policy_id) + .get("ResponseHeadersPolicy", {}) + .get("ResponseHeadersPolicyConfig", {}) + ) + security = config.get("SecurityHeadersConfig", {}) or {} + csp_block = security.get("ContentSecurityPolicy", {}) or {} + csp_value = csp_block.get("ContentSecurityPolicy") + frame = (security.get("FrameOptions", {}) or {}).get("FrameOption") + problems = [] + if policy_id not in custom_ids: + problems.append( + f"policy {policy_id} is not a custom policy (an AWS-managed one has no CSP)" + ) + if not isinstance(csp_value, str) or not csp_value.strip(): + problems.append("the policy carries no Content-Security-Policy") + if csp_block.get("Override") is not True: + problems.append( + f"ContentSecurityPolicy.Override is {csp_block.get('Override')!r}, not True" + ) + if frame != "DENY": + problems.append(f"FrameOptions.FrameOption is {frame!r}, not 'DENY'") + results.append( + CheckResult( + resource=resource, + check="response_headers_policy_enforces_csp", + status="fail" if problems else "pass", + detail="; ".join(problems) + if problems + else f"custom policy {policy_id}: CSP with Override true, X-Frame-Options DENY", + ) + ) + return results, csp_value if isinstance(csp_value, str) and csp_value.strip() else None + + +def _check_served_csp( + domain_name: str, + *, + region: str, + cognito_domain: str, + policy_csp: str | None, + header_caller: HeaderCaller, +) -> Iterable[CheckResult]: + """Assert the served CSP on `/`, an unauthenticated `/api/*` and an unauthenticated `/agent/*`. + + One `csp_header_enforced` row per behaviour, then rows over the `/` response's header: equal on + every behaviour and to the policy, the designed directive set, Cognito in `connect-src`, and a + hash source for every inline script in the served document. + """ + served: dict[str, str] = {} + root_body: str | None = None + for resource, path, method, unauthenticated in _CSP_PROBES: + check = "csp_header_enforced" + result = header_caller(f"https://{domain_name}{path}", method) + if isinstance(result, str): + yield CheckResult(resource=resource, check=check, status="fail", detail=result) + continue + status_code, headers, body = result + policy = headers.get(_CSP_HEADER) + if unauthenticated and status_code < 400: + yield CheckResult( + resource=resource, + check=check, + status="fail", + detail=( + f"unauthenticated {method} {path} returned {status_code}; the probe must read " + "the header from a refusal" + ), + ) + elif not policy: + report_only = ( + " (only Content-Security-Policy-Report-Only)" + if headers.get(_CSP_REPORT_ONLY_HEADER) + else "" + ) + yield CheckResult( + resource=resource, + check=check, + status="fail", + detail=f"{method} {path} returned {status_code} with no enforced CSP{report_only}", + ) + else: + served[resource] = policy + if path == "/": + root_body = body + yield CheckResult( + resource=resource, + check=check, + status="pass", + detail=f"{method} {path} returned {status_code} carrying Content-Security-Policy", + ) + + resource = "distribution" + root_policy = served.get("behavior:/*") + if root_policy is None: + for check in ( + "served_csp_identical_and_equal_to_policy", + "served_csp_matches_design", + "served_csp_connect_src_allows_cognito", + "served_csp_allows_every_inline_script", + ): + yield CheckResult( + resource=resource, + check=check, + status="fail", + detail="no CSP was served on / to inspect; see behavior:/* csp_header_enforced", + ) + return + + differing = sorted(name for name, value in served.items() if value != root_policy) + mismatch = [] + if differing: + mismatch.append(f"behaviours serving a different CSP from /: {differing}") + if policy_csp is not None and root_policy != policy_csp: + mismatch.append("the served CSP differs from the response-headers policy's value") + compared = ( + "and to the policy's value" + if policy_csp is not None + else ("(the policy's value was unreadable, so it was not compared)") + ) + yield CheckResult( + resource=resource, + check="served_csp_identical_and_equal_to_policy", + status="fail" if mismatch else "pass", + detail="; ".join(mismatch) + if mismatch + else f"every behaviour that served a CSP serves the same one, equal to / {compared}", + ) + + problems = _csp_design_problems(root_policy) + yield CheckResult( + resource=resource, + check="served_csp_matches_design", + status="fail" if problems else "pass", + detail="; ".join(problems) if problems else f"served CSP matches the design: {root_policy}", + ) + + parsed, _ = _parse_csp(root_policy) + connect_src = parsed.get("connect-src", []) + wanted = [ + f"https://cognito-idp.{region}.amazonaws.com", + f"https://{cognito_domain}.auth.{region}.amazoncognito.com", + ] + absent = [origin for origin in wanted if origin not in connect_src] + yield CheckResult( + resource=resource, + check="served_csp_connect_src_allows_cognito", + status="fail" if absent else "pass", + detail=f"connect-src lacks {absent}: {connect_src}" + if absent + else f"connect-src carries {wanted}", + ) + + script_src = parsed.get("script-src", []) + scripts = _INLINE_SCRIPT.findall(root_body or "") + hashes = [_csp_hash(body) for body in scripts] + not_allowed = [h for h in hashes if h not in script_src] + status: Status + if not scripts: + status, detail = ( + "fail", + "the served document carries no inline "; +const COMPLIANT_PAGE = "compliant

no script, no subresource

"; + +test.describe("the shared CSP violation trap", () => { + test("records a planted inline-script violation, naming the directive", async ({ browser }) => { + const page = await browser.newPage(); + try { + await installCspViolationTrap(page); + await servePlantedPage(page, VIOLATING_PAGE); + await expect.poll(() => cspViolationsOf(page).length).toBeGreaterThan(0); + expect(cspViolationsOf(page)[0]).toMatch(/^enforce script-src(-elem)? blocked inline on /); + } finally { + await page.close(); + } + }); + + test("fails the test a violation occurs in, even when the body itself passes", async ({ page }) => { + test.fail(true, "the fixture's teardown must fail this test: its page records a violation"); + await servePlantedPage(page, VIOLATING_PAGE); + await expect.poll(() => cspViolationsOf(page).length).toBeGreaterThan(0); + }); + + test("records nothing for a page that keeps to its policy", async ({ page }) => { + await servePlantedPage(page, COMPLIANT_PAGE); + await expect(page).toHaveTitle("compliant"); + expect(cspViolationsOf(page)).toEqual([]); + }); + + test("hands a journey a copy, so a journey cannot clear the record", async ({ browser }) => { + const page = await browser.newPage(); + try { + await installCspViolationTrap(page); + await servePlantedPage(page, VIOLATING_PAGE); + await expect.poll(() => cspViolationsOf(page).length).toBeGreaterThan(0); + const copy = cspViolationsOf(page) as string[]; + copy.length = 0; + expect(cspViolationsOf(page).length).toBeGreaterThan(0); + } finally { + await page.close(); + } + }); +}); diff --git a/tests/e2e/browser/journeys/README.md b/tests/e2e/browser/journeys/README.md index bed41c3..5df94b9 100644 --- a/tests/e2e/browser/journeys/README.md +++ b/tests/e2e/browser/journeys/README.md @@ -25,6 +25,7 @@ describes what it asserts and its declared limits. | `18-approval-rebase` | An unrelated `log_activity` write does not block approval; a write to a touched field shows the three-way conflict view, and "Refresh and review current state" rebases it so approval succeeds | | `19-account-opportunities` | An account's detail page lists its opportunities in the shared table; an account with none shows "No opportunities yet." and no table | | `20-chat-cost` | Each reply shows its cost with a per-tier breakdown and the header totals the conversation; the withheld text appears only when `config/pricing.yaml` is `provisional: true` | +| `21-tier-comparison` | A stub sweep's tier comparison summary renders three tables (Supervisor, Subagent, ToolCall), each headed `Metric` plus one column per arm with fixed row labels and the notes beneath; every cell equals the run status's `tier_comparison_table`, and the downloaded `matrix.md`'s tier section carries the same cells and notes. No verdict or winner term appears in either | Journeys 14–20 sit in one directory each. diff --git a/tests/e2e/browser/package-lock.json b/tests/e2e/browser/package-lock.json index 45eb276..c417777 100644 --- a/tests/e2e/browser/package-lock.json +++ b/tests/e2e/browser/package-lock.json @@ -6,19 +6,19 @@ "": { "name": "crm-eval-v2-browser-journeys", "devDependencies": { - "@playwright/test": "1.64.1", + "@playwright/test": "1.65.0", "@types/node": "26.6.6", "typescript": "7.0.2" } }, "node_modules/@playwright/test": { - "version": "1.64.1", - "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.64.1.tgz", - "integrity": "sha512-IaYGml/nSOiZWROfPtuIL7neuu9qDOZ3TNvNljUIrhDMxiGTgPjzj/g9p9RxpS2tSepPDRY+UwAaEeiKtUvIAg==", + "version": "1.65.0", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.65.0.tgz", + "integrity": "sha512-iGURLGuKDLakSEl7Pgfv8h7f+XLT+V861Wfhz0zlEl5nyFuKUopdkFBPKqTllTUp06aOwPuH8iuUEb3yp3MpbQ==", "dev": true, "license": "Apache-2.0", "dependencies": { - "playwright": "1.64.1" + "playwright": "1.65.0" }, "bin": { "playwright": "cli.js" @@ -378,13 +378,13 @@ } }, "node_modules/playwright": { - "version": "1.64.1", - "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.64.1.tgz", - "integrity": "sha512-HCrVhHr5QQuwYoswEUGTb7gGp522yflbv/ST8nF4sFWGuLjQCt17Q/EubpGGSNKYn1tsTCPZxqHhHCfVURu7UA==", + "version": "1.65.0", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.65.0.tgz", + "integrity": "sha512-F3AMWcR44qMBt4kq+6Kb6mX7bjGXshktKFOPULd7reED6ZJWevjbNRqysP7q+AATE9kdPEZBibex1BYsvpVoeA==", "dev": true, "license": "Apache-2.0", "dependencies": { - "playwright-core": "1.64.1" + "playwright-core": "1.65.0" }, "bin": { "playwright": "cli.js" @@ -394,9 +394,9 @@ } }, "node_modules/playwright-core": { - "version": "1.64.1", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.64.1.tgz", - "integrity": "sha512-BC4s8y6SEVA6Q1rSxZTto8hI1KUI3xXlHGZgvGqP4IqPdI/a6FX9H29IDNz7vKo9l21b6LfYosScPL6M3xxyDQ==", + "version": "1.65.0", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.65.0.tgz", + "integrity": "sha512-vNSKgH6YqtN7cdT/L334zo0a+YwkrpicyrHJlWWPIm/Q+Nn2SWInil01oT0mbu96U4GgoRtCYQD9CzJQgju+lA==", "dev": true, "license": "Apache-2.0", "bin": { diff --git a/tests/e2e/browser/package.json b/tests/e2e/browser/package.json index 07279da..422497e 100644 --- a/tests/e2e/browser/package.json +++ b/tests/e2e/browser/package.json @@ -4,7 +4,7 @@ "type": "module", "description": "T4 browser journeys against a deployed stack. Isolated from frontend/ and src/relay/: installs only Playwright and the TypeScript compiler, so a journey cannot import application code.", "devDependencies": { - "@playwright/test": "1.64.1", + "@playwright/test": "1.65.0", "@types/node": "26.6.6", "typescript": "7.0.2" }, diff --git a/tests/fixtures/plans/compliant.base.ndjson b/tests/fixtures/plans/compliant.base.ndjson index cd27296..0e69efa 100644 --- a/tests/fixtures/plans/compliant.base.ndjson +++ b/tests/fixtures/plans/compliant.base.ndjson @@ -1,4 +1,4 @@ -{"_fixture_provenance": {"captured_at": "2026-10-29", "captured_infra_digest": "e5d475c2e575fc275ebde370298cd761868181dcec2826152d505a6591489d48", "currency": "Captured from a tree whose tracked infra/**/*.tf digest is captured_infra_digest. plan_freshness passes while plan_fixtures.infra_digest of the working tree equals it. The adopted network (VPC, subnets, route tables, the CloudFront VPC-origin security group) is created outside Terraform and adopted by the gitignored tfvars, so its ids are scrubbed to placeholders.", "derived_from": "native capture; no earlier fixture content", "how": "terraform show -json of a create-everything plan captured against EMPTY LOCAL STATE in a scratch copy of infra/ (providers and build/ symlinked, backend block removed so state is local), no deploy. Plan: 644 to add, 0 to change, 0 to destroy; 131 data reads. Scrubbed by scripts/scrub_plan_capture.py: account id -> 123456789012, IAM unique ids -> AIDA-example-caller-user-id, caller role and session -> example-deployer/example-session, operator principals -> example-operator-, aws_profile -> example-deployer, adopted-network ids -> non-hex placeholder tokens.", "variables_at_capture": "runtime_source_vpce_deny_enabled = false; runtime_source_vpce_report_only_enabled = true; vpc_flow_log_enabled = true; vpc_nat_gateway_enabled = true; adopted-network variables and crm_operator_principal_arns from the gitignored infra/terraform.tfvars. NONE has a tracked default that supplies a real id."}, "configuration": {"provider_config": {"aws": {"expressions": {"default_tags": [{"tags": {"references": ["var.service", "var.environment", "var.owner", "var.cost_center", "var.data_classification"]}}], "profile": {"references": ["var.aws_profile"]}, "region": {"references": ["var.aws_region"]}}, "full_name": "registry.terraform.io/hashicorp/aws", "name": "aws", "version_constraint": "6.71.0"}, "module.agentcore:null": {"full_name": "registry.terraform.io/hashicorp/null", "module_address": "module.agentcore", "name": "null"}, "terraform": {"full_name": "terraform.io/builtin/terraform", "name": "terraform"}}, "root_module": {"module_calls": {"agent_relay": {"expressions": {"agent_runtime_arn": {"references": ["module.agentcore.agent_runtime_arn", "module.agentcore"]}, "agent_runtime_qualifier": {"references": ["local.relay_runtime_qualifier"]}, "cognito_audience_parameter_arn": {"references": ["var.aws_region", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current", "local.relay_cognito_audience_parameter_name"]}, "cognito_audience_parameter_name": {"references": ["local.relay_cognito_audience_parameter_name"]}, "cognito_issuer": {"references": ["var.aws_region", "module.cognito.user_pool_id", "module.cognito"]}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "filename": {"references": ["var.lambda_build_dir"]}, "function_name": {"references": ["local.name_prefix"]}, "log_retention_days": {"constant_value": 365}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"agent_relay\"]", "local.reserved_concurrency"]}, "source_code_hash": {"references": ["var.lambda_build_dir"]}, "tags": {"references": ["var.data_classification"]}, "timeout_seconds": {"constant_value": 660}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"environment_variable_names": {"description": "Names of every environment variable this module sets on the relay. Lets a contract test assert the config surface in both directions \u2014 nothing the relay reads is unset, nothing set is unread.", "expression": {"references": ["local.environment_variables"]}}, "function_arn": {"description": "The relay function's ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The relay function's name. Consumed by `modules/frontend_cdn` to attach the CloudFront-scoped `lambda:InvokeFunctionUrl` permission.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "function_url": {"description": "The Function URL, scheme and trailing slash included, as Lambda returns it.", "expression": {"references": ["aws_lambda_function_url.this.function_url", "aws_lambda_function_url.this"]}}, "function_url_domain": {"description": "Host portion of the Function URL, for use as a CloudFront custom-origin `domain_name` (which rejects a scheme or a path).", "expression": {"references": ["aws_lambda_function_url.this.function_url", "aws_lambda_function_url.this"]}}, "log_group_name": {"description": "The relay's CloudWatch log group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "The relay execution role's ARN. Consumed by the Layer 4 `simulate-principal-policy` check.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "The relay execution role's name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"references": ["var.log_retention_days"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.invoke_runtime", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.invoke_runtime.json", "data.aws_iam_policy_document.invoke_runtime"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "invoke_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.read_audience_parameter", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.read_audience_parameter.json", "data.aws_iam_policy_document.read_audience_parameter"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "read_audience_parameter", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"environment": [{"variables": {"references": ["local.environment_variables"]}}], "filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_function_url.this", "expressions": {"authorization_type": {"constant_value": "AWS_IAM"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "invoke_mode": {"constant_value": "RESPONSE_STREAM"}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function_url"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.invoke_runtime", "expressions": {"statement": [{"actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.agent_runtime_arn", "local.agent_runtime_endpoints_arn"]}, "sid": {"constant_value": "InvokeOneRuntimeAndItsEndpoints"}}, {"effect": {"constant_value": "Deny"}, "not_actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime"]}, "resources": {"references": ["var.agent_runtime_arn", "local.agent_runtime_endpoints_arn"]}, "sid": {"constant_value": "DenyEverythingButTheOnePermittedInvokeOnThisRuntime"}}, {"actions": {"constant_value": ["bedrock-agentcore:*"]}, "effect": {"constant_value": "Deny"}, "resources": {"references": ["local.agentcore_harness_arn"]}, "sid": {"constant_value": "DenyEveryHarness"}}]}, "mode": "data", "name": "invoke_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.read_audience_parameter", "expressions": {"statement": [{"actions": {"constant_value": ["ssm:GetParameter"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.cognito_audience_parameter_arn"]}, "sid": {"constant_value": "ReadRelayParameters"}}]}, "mode": "data", "name": "read_audience_parameter", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"agent_runtime_arn": {"description": "ARN of the one AgentCore Runtime this relay may invoke\n(`module.agentcore.agent_runtime_arn`). The execution role is granted\n`bedrock-agentcore:InvokeAgentRuntime` on this ARN and its endpoint sub-resources and on nothing\nelse \u2014 no wildcard, no second runtime.\n"}, "agent_runtime_qualifier": {"default": "DEFAULT", "description": "Runtime endpoint qualifier the relay invokes, passed to the relay as `AGENT_RUNTIME_QUALIFIER`\n(`src/relay/src/runtime.ts`). The execution role's `InvokeAgentRuntime` grant covers the endpoint\nthis value names.\n"}, "cognito_audience_parameter_arn": {"description": "ARN of that same parameter, for the execution role's `ssm:GetParameter` grant. The caller constructs\nit from region, account and name, not from `aws_ssm_parameter.\u2026arn`, to avoid a module cycle.\n"}, "cognito_audience_parameter_name": {"description": "Name of the SSM parameter holding the SPA app-client id the relay requires. The relay reads it at\ncold start and rejects any token issued to a different client.\n"}, "cognito_issuer": {"description": "Cognito user-pool issuer URL (`https://cognito-idp..amazonaws.com/`). The relay derives its JWKS URL from this and rejects any token whose `iss` differs."}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables and its log group."}, "filename": {"description": "Path to the relay deployment package built by `scripts/package_relay.sh`."}, "function_name": {"description": "Unique Lambda function name. Also names this module's IAM role and log group."}, "handler": {"default": "index.handler", "description": "Lambda handler entry point inside the relay zip."}, "log_retention_days": {"default": 365, "description": "Explicit CloudWatch Logs retention for the relay's log group."}, "memory_size_mb": {"default": 512, "description": "Lambda memory allocation in MB, sizing the Node runtime and the JWKS cache."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for the relay. Must be greater than zero; 0 makes the function permanently\nuninvokable.\n\nOne chat turn holds one invocation for up to `timeout_seconds`. The caller keeps the sum of every\nreserved concurrency in the deployment below the account pool minus unreserved headroom.\n\nNo default; the caller states a value.\n"}, "runtime": {"default": "nodejs24.x", "description": "Lambda runtime identifier. Must be a Node.js runtime, which supports response streaming."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the relay package, forcing redeploy on code change."}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already carries the mandatory tags; this adds or overrides per-resource."}, "timeout_seconds": {"default": 660, "description": "Lambda invocation timeout in seconds. Must exceed the 600s chat turn wall clock."}, "vpc_security_group_ids": {"description": "Security groups for the relay's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress; the relay is invoked through the Lambda control plane (a signed Function URL invoke).\n"}, "vpc_subnet_ids": {"description": "Private subnet ids the relay's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default; at least two subnets.\n\nThe relay's outbound calls (`bedrock-agentcore:InvokeAgentRuntime`, `ssm:GetParameter` and the\nCognito JWKS fetch) leave through these subnets, via the VPC endpoints and the NAT gateway. A missing\npath presents as a hung turn, not as an authorization error.\n"}}}, "source": "./modules/agent_relay"}, "agentcore": {"depends_on": ["aws_s3_object.agent_source", "aws_iam_role_policy.agentcore_runtime"], "expressions": {"agent_runtime_environment_variables": {"references": ["module.cognito.user_pool_id", "module.cognito", "module.api.stage_invoke_url", "module.api", "local.name_prefix", "local.name_prefix"]}, "agent_runtime_name": {"constant_value": "crm_agent_eval_runtime"}, "agent_runtime_role_arn": {"references": ["aws_iam_role.agentcore_runtime.arn", "aws_iam_role.agentcore_runtime"]}, "aws_profile": {"references": ["var.aws_profile"]}, "aws_region": {"references": ["var.aws_region"]}, "buildspec": {"references": ["local.agent_buildspec"]}, "cognito_allowed_audiences": {"references": ["module.cognito.allowed_client_ids", "module.cognito"]}, "cognito_allowed_client_ids": {"references": ["module.cognito.allowed_client_ids", "module.cognito"]}, "cognito_allowed_scopes": {"references": ["module.cognito.gateway_scope_identifier", "module.cognito"]}, "cognito_discovery_url": {"references": ["var.aws_region", "module.cognito.user_pool_id", "module.cognito"]}, "cognito_required_custom_claims": {"constant_value": []}, "data_classification": {"references": ["var.data_classification"]}, "ecr_repository_name": {"references": ["local.agent_ecr_repository_name"]}, "gateway_name": {"constant_value": "crm-agent-eval-gateway"}, "gateway_role_arn": {"references": ["aws_iam_role.agentcore_gateway.arn", "aws_iam_role.agentcore_gateway"]}, "identity_interceptor_lambda_arn": {"references": ["module.lambda_action_interceptor.function_arn", "module.lambda_action_interceptor"]}, "identity_interceptor_lambda_function_name": {"references": ["module.lambda_action_interceptor.function_name", "module.lambda_action_interceptor"]}, "image_retention_count": {"constant_value": 10}, "image_tag": {"references": ["local.agent_image_tag"]}, "kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "log_retention_days": {"constant_value": 365}, "name_prefix": {"references": ["local.name_prefix"]}, "runtime_network_mode": {"constant_value": "VPC"}, "runtime_security_group_ids": {"references": ["module.vpc.runtime_security_group_id", "module.vpc"]}, "runtime_subnet_ids": {"references": ["module.vpc.runtime_subnet_ids", "module.vpc"]}, "source_bucket_arn": {"references": ["module.eval_artifacts.bucket_arn", "module.eval_artifacts"]}, "source_content_hash": {"references": ["var.lambda_build_dir"]}, "source_key": {"references": ["aws_s3_object.agent_source.key", "aws_s3_object.agent_source"]}, "source_kms_key_arn": {"references": ["aws_kms_key.eval_artifacts.arn", "aws_kms_key.eval_artifacts"]}, "tool_lambda_arns": {"references": ["module.lambda_action"]}, "tool_schemas": {"references": ["local.tool_names", "local.tools", "local.tool_schema_properties"]}}, "module": {"outputs": {"agent_runtime_arn": {"description": "The deployed AgentCore Runtime ARN.", "expression": {"references": ["aws_bedrockagentcore_agent_runtime.this.agent_runtime_arn", "aws_bedrockagentcore_agent_runtime.this"]}}, "agent_runtime_id": {"description": "The deployed AgentCore Runtime id.", "expression": {"references": ["aws_bedrockagentcore_agent_runtime.this.agent_runtime_id", "aws_bedrockagentcore_agent_runtime.this"]}}, "agent_runtime_log_group_arn": {"description": "CloudWatch Logs group ARN for the AgentCore Runtime's default endpoint stdout, for scoping the execution role's logs:* grant.", "expression": {"references": ["aws_cloudwatch_log_group.runtime.arn", "aws_cloudwatch_log_group.runtime"]}}, "agent_runtime_log_group_name": {"description": "CloudWatch Logs group name for the AgentCore Runtime's default endpoint stdout.", "expression": {"references": ["aws_cloudwatch_log_group.runtime.name", "aws_cloudwatch_log_group.runtime"]}}, "codebuild_role_arn": {"description": "ARN of the CodeBuild image-build project's service role, which reads the agent-source object and uses its CMK. The root admits it to the eval-artefacts bucket and key policies.", "expression": {"references": ["aws_iam_role.codebuild.arn", "aws_iam_role.codebuild"]}}, "ecr_repository_arn": {"description": "ARN of the ECR repository the agent container image is pushed to. The root composition scopes the\nAgentCore Runtime execution role's `ecr:BatchGetImage`/`ecr:GetDownloadUrlForLayer` grant to this\nARN.\n", "expression": {"references": ["aws_ecr_repository.agent.arn", "aws_ecr_repository.agent"]}}, "ecr_repository_url": {"description": "The ECR repository URL the agent container image is pushed to.", "expression": {"references": ["aws_ecr_repository.agent.repository_url", "aws_ecr_repository.agent"]}}, "gateway_arn": {"description": "The deployed Gateway ARN.", "expression": {"references": ["aws_bedrockagentcore_gateway.this.gateway_arn", "aws_bedrockagentcore_gateway.this"]}}, "gateway_id": {"description": "The deployed Gateway id.", "expression": {"references": ["aws_bedrockagentcore_gateway.this.gateway_id", "aws_bedrockagentcore_gateway.this"]}}, "gateway_target_ids": {"description": "Map of tool_name -> that tool's gateway target id, one entry per entry in var.tool_lambda_arns.", "expression": {"references": ["aws_bedrockagentcore_gateway_target.tool"]}}, "gateway_url": {"description": "The deployed Gateway's invocation URL.", "expression": {"references": ["aws_bedrockagentcore_gateway.this.gateway_url", "aws_bedrockagentcore_gateway.this"]}}}, "resources": [{"address": "aws_bedrockagentcore_agent_runtime.this", "depends_on": ["null_resource.image_build"], "expressions": {"agent_runtime_artifact": [{"container_configuration": [{"container_uri": {"references": ["aws_ecr_repository.agent.repository_url", "aws_ecr_repository.agent", "var.image_tag"]}}]}], "agent_runtime_name": {"references": ["var.agent_runtime_name"]}, "environment_variables": {"references": ["var.agent_runtime_environment_variables"]}, "network_configuration": [{"network_mode": {"references": ["var.runtime_network_mode"]}}], "platform_version": {"references": ["var.platform_version"]}, "region": {"references": ["var.aws_region"]}, "role_arn": {"references": ["var.agent_runtime_role_arn"]}, "tags": {"references": ["var.tags"]}, "timeouts": {"create": {"constant_value": "30m"}, "update": {"constant_value": "30m"}}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_bedrockagentcore_agent_runtime"}, {"address": "aws_bedrockagentcore_gateway.this", "expressions": {"authorizer_configuration": [{"custom_jwt_authorizer": [{"allowed_audience": {"constant_value": null}, "allowed_clients": {"references": ["var.cognito_allowed_client_ids"]}, "allowed_scopes": {"references": ["var.cognito_allowed_scopes"]}, "discovery_url": {"references": ["var.cognito_discovery_url"]}}]}], "authorizer_type": {"constant_value": "CUSTOM_JWT"}, "interceptor_configuration": [{"input_configuration": [{"pass_request_headers": {"constant_value": true}}], "interception_points": {"constant_value": ["REQUEST"]}, "interceptor": [{"lambda": [{"arn": {"references": ["var.identity_interceptor_lambda_arn"]}}]}]}], "name": {"references": ["var.gateway_name"]}, "region": {"references": ["var.aws_region"]}, "role_arn": {"references": ["var.gateway_role_arn"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_bedrockagentcore_gateway"}, {"address": "aws_bedrockagentcore_gateway_target.tool", "expressions": {"credential_provider_configuration": [{"gateway_iam_role": [{}]}], "description": {"references": ["each.key"]}, "gateway_identifier": {"references": ["aws_bedrockagentcore_gateway.this.gateway_id", "aws_bedrockagentcore_gateway.this"]}, "name": {"references": ["each.key"]}, "target_configuration": [{"mcp": [{"lambda": [{"lambda_arn": {"references": ["each.value"]}, "tool_schema": [{"inline_payload": [{"description": {"references": ["var.tool_schemas", "each.key"]}, "input_schema": [{"type": {"constant_value": "object"}}], "name": {"references": ["each.key"]}}]}]}]}]}]}, "for_each_expression": {"references": ["var.tool_lambda_arns"]}, "mode": "managed", "name": "tool", "provider_config_key": "aws", "schema_version": 0, "type": "aws_bedrockagentcore_gateway_target"}, {"address": "aws_cloudwatch_log_group.codebuild", "expressions": {"kms_key_id": {"references": ["var.kms_key_arn"]}, "name": {"references": ["var.name_prefix"]}, "retention_in_days": {"references": ["var.log_retention_days"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "codebuild", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_cloudwatch_log_group.runtime", "expressions": {"kms_key_id": {"references": ["var.kms_key_arn"]}, "name": {"references": ["aws_bedrockagentcore_agent_runtime.this.agent_runtime_id", "aws_bedrockagentcore_agent_runtime.this"]}, "retention_in_days": {"references": ["var.log_retention_days"]}, "tags": {"references": ["var.tags", "var.data_classification"]}}, "mode": "managed", "name": "runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_codebuild_project.agent_image", "expressions": {"artifacts": [{"type": {"constant_value": "NO_ARTIFACTS"}}], "build_timeout": {"constant_value": 30}, "description": {"constant_value": "Builds and pushes the AgentCore Runtime container image."}, "encryption_key": {"references": ["var.source_kms_key_arn"]}, "environment": [{"compute_type": {"constant_value": "BUILD_GENERAL1_SMALL"}, "environment_variable": [{"name": {"constant_value": "ECR_REPOSITORY_URI"}, "value": {"references": ["aws_ecr_repository.agent.repository_url", "aws_ecr_repository.agent"]}}, {"name": {"constant_value": "AWS_DEFAULT_REGION"}, "value": {"references": ["var.aws_region"]}}], "image": {"constant_value": "aws/codebuild/amazonlinux2-aarch64-standard:3.0"}, "image_pull_credentials_type": {"constant_value": "CODEBUILD"}, "privileged_mode": {"constant_value": true}, "type": {"constant_value": "ARM_CONTAINER"}}], "logs_config": [{"cloudwatch_logs": [{"group_name": {"references": ["aws_cloudwatch_log_group.codebuild.name", "aws_cloudwatch_log_group.codebuild"]}}]}], "name": {"references": ["var.name_prefix"]}, "service_role": {"references": ["aws_iam_role.codebuild.arn", "aws_iam_role.codebuild"]}, "source": [{"buildspec": {"references": ["var.buildspec"]}, "location": {"references": ["var.source_bucket_arn", "var.source_bucket_arn", "var.source_key"]}, "type": {"constant_value": "S3"}}], "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "agent_image", "provider_config_key": "aws", "schema_version": 0, "type": "aws_codebuild_project"}, {"address": "aws_ecr_lifecycle_policy.agent", "expressions": {"policy": {"references": ["var.image_retention_count", "var.image_retention_count"]}, "repository": {"references": ["aws_ecr_repository.agent.name", "aws_ecr_repository.agent"]}}, "mode": "managed", "name": "agent", "provider_config_key": "aws", "schema_version": 0, "type": "aws_ecr_lifecycle_policy"}, {"address": "aws_ecr_repository.agent", "expressions": {"encryption_configuration": [{"encryption_type": {"constant_value": "KMS"}, "kms_key": {"references": ["var.kms_key_arn"]}}], "force_delete": {"constant_value": true}, "image_scanning_configuration": [{"scan_on_push": {"constant_value": true}}], "image_tag_mutability": {"constant_value": "IMMUTABLE"}, "name": {"references": ["var.ecr_repository_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "agent", "provider_config_key": "aws", "schema_version": 0, "type": "aws_ecr_repository"}, {"address": "aws_iam_role.codebuild", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.codebuild_assume_role.json", "data.aws_iam_policy_document.codebuild_assume_role"]}, "name": {"references": ["var.name_prefix"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "codebuild", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.codebuild", "expressions": {"name": {"references": ["var.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.codebuild_permissions.json", "data.aws_iam_policy_document.codebuild_permissions"]}, "role": {"references": ["aws_iam_role.codebuild.id", "aws_iam_role.codebuild"]}}, "mode": "managed", "name": "codebuild", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_lambda_permission.gateway_invoke_interceptor", "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["var.identity_interceptor_lambda_function_name"]}, "principal": {"constant_value": "bedrock-agentcore.amazonaws.com"}, "source_arn": {"references": ["aws_bedrockagentcore_gateway.this.gateway_arn", "aws_bedrockagentcore_gateway.this"]}, "statement_id": {"constant_value": "AllowGatewayInvokeIdentityInterceptor"}}, "mode": "managed", "name": "gateway_invoke_interceptor", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "null_resource.image_build", "depends_on": ["aws_codebuild_project.agent_image"], "expressions": {"triggers": {"references": ["var.source_content_hash", "aws_codebuild_project.agent_image.name", "aws_codebuild_project.agent_image"]}}, "mode": "managed", "name": "image_build", "provider_config_key": "module.agentcore:null", "provisioners": [{"expressions": {"command": {"references": ["var.image_tag", "aws_ecr_repository.agent.name", "aws_ecr_repository.agent", "var.aws_profile", "var.aws_region", "aws_ecr_repository.agent.name", "aws_ecr_repository.agent", "aws_codebuild_project.agent_image.name", "aws_codebuild_project.agent_image", "var.aws_profile", "var.aws_region", "var.aws_profile", "var.aws_region", "aws_codebuild_project.agent_image.name", "aws_codebuild_project.agent_image", "var.aws_profile", "var.aws_region"]}}, "type": "local-exec"}], "schema_version": 0, "type": "null_resource"}, {"address": "data.aws_iam_policy_document.codebuild_assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["codebuild.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "codebuild_assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.codebuild_permissions", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.codebuild.arn", "aws_cloudwatch_log_group.codebuild"]}, "sid": {"constant_value": "Logs"}}, {"actions": {"constant_value": ["ecr:GetAuthorizationToken"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "EcrAuth"}}, {"actions": {"constant_value": ["ecr:BatchCheckLayerAvailability", "ecr:GetDownloadUrlForLayer", "ecr:BatchGetImage", "ecr:PutImage", "ecr:InitiateLayerUpload", "ecr:UploadLayerPart", "ecr:CompleteLayerUpload"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_ecr_repository.agent.arn", "aws_ecr_repository.agent"]}, "sid": {"constant_value": "EcrPush"}}, {"actions": {"constant_value": ["s3:GetObject", "s3:GetObjectVersion"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.source_bucket_arn", "var.source_key"]}, "sid": {"constant_value": "SourceObject"}}, {"actions": {"constant_value": ["kms:Decrypt", "kms:Encrypt", "kms:GenerateDataKey*", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.source_kms_key_arn"]}, "sid": {"constant_value": "ProjectKms"}}]}, "mode": "data", "name": "codebuild_permissions", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"agent_runtime_environment_variables": {"default": {}, "description": "Plaintext environment variables for the runtime. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "agent_runtime_name": {"default": "crm_agent_eval_runtime", "description": "Name for the AgentCore Runtime resource. Must satisfy the CreateAgentRuntime pattern [a-zA-Z][a-zA-Z0-9_]{0,47} -- no hyphens."}, "agent_runtime_role_arn": {"description": "Execution role ARN the AgentCore Runtime assumes to run the agent container."}, "aws_profile": {"default": "default", "description": "Named AWS CLI profile used by the in-apply CodeBuild trigger's `local-exec` provisioner."}, "aws_region": {"default": "us-east-1", "description": "AWS region for the AgentCore resources and the in-apply build trigger."}, "buildspec": {"description": "Inline buildspec for the CodeBuild project (Docker build + ECR push steps)."}, "cognito_allowed_audiences": {"description": "Accepted `aud` claim values for the CUSTOM_JWT authorizer."}, "cognito_allowed_client_ids": {"description": "App client ids accepted as valid callers by the CUSTOM_JWT authorizer."}, "cognito_allowed_scopes": {"default": [], "description": "Scopes required to be present on an inbound access token, enforced by the Gateway CUSTOM_JWT authorizer."}, "cognito_discovery_url": {"description": "Cognito user pool OIDC discovery URL, ending in /.well-known/openid-configuration."}, "cognito_required_custom_claims": {"default": [], "description": "Custom claims the Gateway CUSTOM_JWT authorizer requires on an inbound token, each matched by\nequality against one fixed `required_value` (for example a fixed `token_use` claim). Presence-only\nchecks are not expressible here; the interceptor's `decode_identity` rejects a token without the\nidentity claims. Defaults to empty.\n"}, "data_classification": {"description": "Value for the mandatory `data-classification` tag, applied per-resource (mirrors every sibling module's convention)."}, "ecr_repository_name": {"default": "crm-agent-eval-agent", "description": "Name of the ECR repository holding the agent container image."}, "gateway_name": {"default": "crm-agent-eval-gateway", "description": "Name for the AgentCore Gateway resource."}, "gateway_role_arn": {"description": "Execution role ARN the Gateway assumes, including to invoke each target Lambda via credential_provider_configuration.gateway_iam_role."}, "identity_interceptor_lambda_arn": {"description": "Invoke ARN of the identity_interceptor Lambda (src/gateway/identity_interceptor.py), attached as the Gateway's REQUEST interceptor."}, "identity_interceptor_lambda_function_name": {"description": "Function name of the identity_interceptor Lambda, used to grant this Gateway invoke permission in the function resource policy."}, "image_retention_count": {"default": 10, "description": "Number of most-recent tagged images retained by the ECR lifecycle policy."}, "image_tag": {"default": "latest", "description": "Tag applied to the image the agent_runtime resource consumes (e.g. a short content-hash-derived tag the caller mints alongside source_content_hash)."}, "kms_key_arn": {"description": "KMS customer-managed key ARN encrypting the ECR repository and the module's CloudWatch Logs log groups (runtime and CodeBuild) at rest."}, "log_retention_days": {"default": 365, "description": "Explicit CloudWatch Logs retention for the CodeBuild project's log group."}, "name_prefix": {"default": "crm-agent-eval", "description": "Prefix applied to the CodeBuild project, its IAM role, and its log group names."}, "platform_version": {"default": "V2", "description": "AgentCore Runtime `platformVersion`: \"V1\" or \"V2\". V2 restores each instance from a\nprepared snapshot; creates and updates take minutes. Switching either way is an in-place update.\nRollback: set \"V1\" and apply (docs/runbook.md).\n"}, "runtime_network_mode": {"default": "PUBLIC", "description": "AgentCore Runtime `networkMode`: \"PUBLIC\" or \"VPC\". VPC mode places the microVM's ENIs in the\nadopted VPC's Runtime subnets on a dedicated no-ingress security group; it governs egress only.\nDefaults to \"PUBLIC\"; the root composition sets \"VPC\" and wires the subnet and security-group\nvariables.\n"}, "runtime_security_group_ids": {"default": [], "description": "Security group ids for the Runtime's VPC-mode ENIs. Required (at least one) when\nruntime_network_mode is \"VPC\"; ignored under \"PUBLIC\". Must be the dedicated Runtime security group\n(no ingress, egress only to the endpoint security group and the gateway prefix lists), not the\nLambda security group.\n"}, "runtime_subnet_ids": {"default": [], "description": "Subnet ids for the Runtime's VPC-mode ENIs. Required (at least one) when runtime_network_mode is\n\"VPC\"; ignored under \"PUBLIC\". Set through the gitignored tfvars.\n\nEvery subnet must be in an AgentCore-supported AZ for the region (`infra/regions.json`);\n`scripts/preflight_adopted_vpc.sh` asserts that at deploy time.\n"}, "source_bucket_arn": {"description": "S3 bucket ARN holding the zipped agent source CodeBuild reads from as its `source`."}, "source_content_hash": {"description": "Content hash of the agent source tree, used as this module's `null_resource.image_build` trigger\nvalue. The image build re-runs when this value changes between applies.\n"}, "source_key": {"description": "S3 object key, within source_bucket_arn, of the zipped agent source archive."}, "source_kms_key_arn": {"description": "ARN of the customer-managed KMS key encrypting `source_bucket_arn`'s objects at rest, also used as\nthe CodeBuild project's `encryption_key`. The CodeBuild role is granted `kms:Decrypt`,\n`kms:Encrypt`, `kms:GenerateDataKey*` and `kms:DescribeKey` on exactly this key. The key's own\npolicy must also admit `aws_iam_role.codebuild` (or a broader principal it belongs to).\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-resource override or addition."}, "tool_lambda_arns": {"description": "Map of tool_name -> that tool's action Lambda ARN (`module.lambda_action[tool_name].function_arn`),\none entry per tool in `crm.toolspec.definitions.ALL_TOOLS`. Each entry produces exactly one gateway\ntarget. Its keys are a superset of the `api` module's tool routes: `get_page_context` is reachable\nby the agents and the Gateway but has no HTTP route (`local.agent_only_tools` in `infra/main.tf`).\nThat the key set equals `ALL_TOOLS` is `scripts/check_toolspec_parity.py`'s check on\n`local.tools`, which this map is built from.\n"}, "tool_schemas": {"description": "Map of tool_name -> that tool's flattened MCP tool schema, for the required\n`target_configuration.mcp.lambda.tool_schema` block of each `aws_bedrockagentcore_gateway_target`.\nCarries exactly the keys of `tool_lambda_arns`; the gateway target resource's precondition fails\nthe plan otherwise.\n\nThe root composition derives each entry's `description` and `properties` from\n`crm.toolspec.definitions.ALL_TOOLS[tool_name]` (`.description` and the top-level keys of\n`.input_schema[\"properties\"]`).\n\nOnly top-level scalar properties, and arrays of scalars, are expressible; a property whose type is\n`object`, or an array of objects, needs this variable's shape extended.\n"}}}, "source": "./modules/agentcore"}, "api": {"expressions": {"access_log_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "api_name": {"constant_value": "crm-agent-eval-api"}, "cognito_user_pool_arn": {"references": ["module.cognito.user_pool_arn", "module.cognito"]}, "extra_routes": {"references": ["module.lambda_action_eval_trigger.invoke_arn", "module.lambda_action_eval_trigger", "module.lambda_action_eval_trigger.function_name", "module.lambda_action_eval_trigger", "module.lambda_action_capabilities.invoke_arn", "module.lambda_action_capabilities", "module.lambda_action_capabilities.function_name", "module.lambda_action_capabilities", "module.lambda_action_user_settings.invoke_arn", "module.lambda_action_user_settings", "module.lambda_action_user_settings.function_name", "module.lambda_action_user_settings"]}, "log_retention_days": {"constant_value": 365}, "stage_name": {"constant_value": "prod"}, "tool_lambda_function_names": {"references": ["local.routed_tool_names", "module.lambda_action"]}, "tool_lambda_invoke_arns": {"references": ["local.routed_tool_names", "module.lambda_action"]}, "vpc_endpoint_ids": {"references": ["module.vpc.execute_api_vpc_endpoint_id", "module.vpc"]}}, "module": {"outputs": {"access_log_group_name": {"description": "CloudWatch Logs group name receiving API Gateway access logs.", "expression": {"references": ["aws_cloudwatch_log_group.access_logs.name", "aws_cloudwatch_log_group.access_logs"]}}, "api_id": {"description": "Private REST API id.", "expression": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}}, "authorizer_id": {"description": "Cognito authorizer id \u2014 every method in this module references this one authorizer; exposed for the Layer 3 gate's authorizer-coverage assertion.", "expression": {"references": ["aws_api_gateway_authorizer.cognito.id", "aws_api_gateway_authorizer.cognito"]}}, "execution_arn": {"description": "API execution ARN, for Lambda resource-policy `source_arn` patterns outside this module if needed.", "expression": {"references": ["aws_api_gateway_rest_api.this.execution_arn", "aws_api_gateway_rest_api.this"]}}, "private_origin_domain_name": {"description": "Hostname for the CloudFront `/api/*` origin's `domain_name` (`-.execute-api..amazonaws.com`). Sent as the Host header to the private API; requires no custom domain and no `x-apigw-api-id`. Uses the first entry of `vpc_endpoint_ids`.", "expression": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this", "var.vpc_endpoint_ids[0]", "var.vpc_endpoint_ids", "data.aws_region.current.region", "data.aws_region.current"]}}, "route_tool_names": {"description": "Sorted list of the tool names this module generated routes for, derived from `var.tool_lambda_invoke_arns`'s keys \u2014 for the Layer 3 gate to diff against `crm.toolspec.definitions.ALL_TOOLS`.", "expression": {"references": ["local.tool_names"]}}, "stage_invoke_url": {"description": "Full invoke URL for the deployed stage. For this private API it is reachable only from inside the VPC through a named interface endpoint; it is not a publicly callable URL.", "expression": {"references": ["aws_api_gateway_stage.this.invoke_url", "aws_api_gateway_stage.this"]}}, "stage_name": {"description": "Deployed stage name. Every route is served beneath it (`//`), so a path-prefixed CloudFront behaviour in front of this API rewrites onto the stage path.", "expression": {"references": ["aws_api_gateway_stage.this.stage_name", "aws_api_gateway_stage.this"]}}, "vpc_endpoint_ids": {"description": "The `execute-api` interface endpoint ids this API is associated with and whose `aws:sourceVpce` its resource policy allows.", "expression": {"references": ["var.vpc_endpoint_ids"]}}}, "resources": [{"address": "aws_api_gateway_authorizer.cognito", "expressions": {"identity_source": {"constant_value": "method.request.header.Authorization"}, "name": {"constant_value": "cognito-user-pools"}, "provider_arns": {"references": ["var.cognito_user_pool_arn"]}, "rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}, "type": {"constant_value": "COGNITO_USER_POOLS"}}, "mode": "managed", "name": "cognito", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_authorizer"}, {"address": "aws_api_gateway_deployment.this", "depends_on": ["aws_api_gateway_method.tool", "aws_api_gateway_integration.tool", "aws_api_gateway_request_validator.body_and_params", "aws_api_gateway_model.json_object"], "expressions": {"rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}, "triggers": {"references": ["local.deployment_trigger"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_deployment"}, {"address": "aws_api_gateway_integration.tool", "expressions": {"http_method": {"references": ["aws_api_gateway_method.tool", "each.key"]}, "integration_http_method": {"constant_value": "POST"}, "resource_id": {"references": ["aws_api_gateway_resource.tool", "each.key"]}, "rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}, "type": {"constant_value": "AWS_PROXY"}, "uri": {"references": ["each.value"]}}, "for_each_expression": {"references": ["local.route_invoke_arns"]}, "mode": "managed", "name": "tool", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_integration"}, {"address": "aws_api_gateway_method.tool", "expressions": {"authorization": {"constant_value": "COGNITO_USER_POOLS"}, "authorizer_id": {"references": ["aws_api_gateway_authorizer.cognito.id", "aws_api_gateway_authorizer.cognito"]}, "http_method": {"references": ["local.route_methods", "each.key"]}, "request_models": {"references": ["local.route_methods", "each.key", "aws_api_gateway_model.json_object.name", "aws_api_gateway_model.json_object"]}, "request_validator_id": {"references": ["aws_api_gateway_request_validator.body_and_params.id", "aws_api_gateway_request_validator.body_and_params"]}, "resource_id": {"references": ["aws_api_gateway_resource.tool", "each.key"]}, "rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}}, "for_each_expression": {"references": ["local.route_invoke_arns"]}, "mode": "managed", "name": "tool", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_method"}, {"address": "aws_api_gateway_method_settings.this", "expressions": {"method_path": {"constant_value": "*/*"}, "rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}, "settings": [{"throttling_burst_limit": {"references": ["var.throttle_burst_limit"]}, "throttling_rate_limit": {"references": ["var.throttle_rate_limit"]}}], "stage_name": {"references": ["aws_api_gateway_stage.this.stage_name", "aws_api_gateway_stage.this"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_method_settings"}, {"address": "aws_api_gateway_model.json_object", "expressions": {"content_type": {"constant_value": "application/json"}, "name": {"constant_value": "JsonObject"}, "rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}, "schema": {}}, "mode": "managed", "name": "json_object", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_model"}, {"address": "aws_api_gateway_request_validator.body_and_params", "expressions": {"name": {"constant_value": "body-and-params"}, "rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}, "validate_request_body": {"constant_value": true}, "validate_request_parameters": {"constant_value": true}}, "mode": "managed", "name": "body_and_params", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_request_validator"}, {"address": "aws_api_gateway_resource.tool", "expressions": {"parent_id": {"references": ["aws_api_gateway_rest_api.this.root_resource_id", "aws_api_gateway_rest_api.this"]}, "path_part": {"references": ["each.key"]}, "rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}}, "for_each_expression": {"references": ["local.route_invoke_arns"]}, "mode": "managed", "name": "tool", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_resource"}, {"address": "aws_api_gateway_rest_api.this", "expressions": {"endpoint_configuration": [{"types": {"constant_value": ["PRIVATE"]}, "vpc_endpoint_ids": {"references": ["var.vpc_endpoint_ids"]}}], "name": {"references": ["var.api_name"]}, "policy": {"references": ["data.aws_iam_policy_document.resource_policy.json", "data.aws_iam_policy_document.resource_policy"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_rest_api"}, {"address": "aws_api_gateway_stage.this", "expressions": {"access_log_settings": [{"destination_arn": {"references": ["aws_cloudwatch_log_group.access_logs.arn", "aws_cloudwatch_log_group.access_logs"]}, "format": {}}], "deployment_id": {"references": ["aws_api_gateway_deployment.this.id", "aws_api_gateway_deployment.this"]}, "rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}, "stage_name": {"references": ["var.stage_name"]}, "tags": {"references": ["var.tags"]}, "xray_tracing_enabled": {"constant_value": true}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_stage"}, {"address": "aws_cloudwatch_log_group.access_logs", "expressions": {"kms_key_id": {"references": ["var.access_log_kms_key_arn"]}, "name": {"references": ["var.api_name"]}, "retention_in_days": {"references": ["var.log_retention_days"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "access_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_lambda_permission.apigw_invoke", "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["each.value"]}, "principal": {"constant_value": "apigateway.amazonaws.com"}, "source_arn": {"references": ["aws_api_gateway_rest_api.this.execution_arn", "aws_api_gateway_rest_api.this", "local.route_methods", "each.key", "each.key"]}, "statement_id": {"references": ["each.key"]}}, "for_each_expression": {"references": ["local.route_function_names"]}, "mode": "managed", "name": "apigw_invoke", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.resource_policy", "expressions": {"statement": [{"actions": {"constant_value": ["execute-api:Invoke"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"constant_value": ["execute-api:/*"]}, "sid": {"constant_value": "AllowInvokeFromNamedVpcEndpointsOnly"}}, {"actions": {"constant_value": ["execute-api:Invoke"]}, "condition": [{"test": {"constant_value": "StringNotEquals"}, "values": {"references": ["var.vpc_endpoint_ids"]}, "variable": {"constant_value": "aws:sourceVpce"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"constant_value": ["execute-api:/*"]}, "sid": {"constant_value": "DenyInvokeFromAnyOtherVpcEndpoint"}}]}, "mode": "data", "name": "resource_policy", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_region.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_region"}], "variables": {"access_log_kms_key_arn": {"description": "KMS customer-managed key ARN encrypting the API Gateway access log group at rest."}, "api_name": {"default": "crm-agent-eval-api", "description": "Name for the REST API."}, "cognito_user_pool_arn": {"description": "ARN of the Cognito user pool whose tokens the authorizer accepts (the `cognito` module user pool ARN output). A COGNITO_USER_POOLS authorizer validates that the token was issued by this pool; it does not validate the app-client audience."}, "extra_routes": {"default": {}, "description": "Routes that are not toolspec tools, and so are absent from `tool_lambda_invoke_arns`. Merged with\nthe tool map into the single local that generates every integration, route and permission, so\nthese carry the Cognito authorizer on the same terms as the tool routes.\n\nThe permitted keys are the allowlist validated below (`eval_trigger`, `capabilities`, `user_settings`).\n\n`method` is the HTTP method the client calls and defaults to `POST`; `capabilities` is a browser\n`GET` (`frontend/src/components/tuning/capabilityMatrix.ts`). The Lambda integration method is\nalways `POST` for `AWS_PROXY`, whatever the client method.\n"}, "log_retention_days": {"default": 365, "description": "Explicit CloudWatch Logs retention for the API Gateway access log group."}, "stage_name": {"default": "prod", "description": "API Gateway stage name."}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-resource override or addition."}, "throttle_burst_limit": {"default": 50, "description": "Per-route burst limit (concurrent requests) enforced at the default-route throttle setting."}, "throttle_rate_limit": {"default": 25, "description": "Per-route steady-state rate limit (requests/second) enforced at the default-route throttle setting."}, "tool_lambda_function_names": {"description": "Map of tool_name -> that tool's action Lambda function name\n(`module.lambda_action[tool_name].function_name`), used to grant API Gateway\n`lambda:InvokeFunction` per function. Carries exactly the key set of `tool_lambda_invoke_arns`;\nthe REST API resource's precondition fails the plan otherwise.\n"}, "tool_lambda_invoke_arns": {"description": "Map of tool_name -> that tool's action Lambda invoke ARN (`module.lambda_action[tool_name].invoke_arn`),\none entry per routed tool in `crm.toolspec.definitions.ALL_TOOLS`. Every route, integration and\nauthorizer attachment is generated from this map (see `main.tf`). Must not be empty.\n"}, "vpc_endpoint_ids": {"description": "The `execute-api` interface VPC endpoint ids this private API is reachable through. Sets `endpoint_configuration.vpc_endpoint_ids` and is the allowlist in the API resource policy."}}}, "source": "./modules/api"}, "api_origin": {"expressions": {"access_logs_bucket": {"references": ["module.frontend_cdn.logs_bucket_name", "module.frontend_cdn"]}, "access_logs_prefix": {"references": ["local.alb_access_log_prefix"]}, "alb_ingress_security_group_ids": {"references": ["var.api_origin_ingress_security_group_ids"]}, "execute_api_security_group_id": {"references": ["module.vpc.execute_api_security_group_id", "module.vpc"]}, "execute_api_target_ips": {"references": ["data.aws_network_interface.execute_api"]}, "name_prefix": {"references": ["local.name_prefix"]}, "private_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}, "tags": {"references": ["var.data_classification"]}, "vpc_id": {"references": ["module.vpc.vpc_id", "module.vpc"]}}, "module": {"outputs": {"alb_arn": {"description": "Internal ALB ARN. The VPC origin references the ALB by this ARN, which is how CloudFront routes without resolving the origin's domain name.", "expression": {"references": ["aws_lb.this.arn", "aws_lb.this"]}}, "alb_dns_name": {"description": "Internal ALB DNS name, for diagnostics only. It is not the CloudFront origin `domain_name`, which is `module.api.private_origin_domain_name`: API Gateway routes the private API on that Host header.", "expression": {"references": ["aws_lb.this.dns_name", "aws_lb.this"]}}, "alb_security_group_id": {"description": "The ALB's security group id, for asserting its ingress source and single scoped egress.", "expression": {"references": ["aws_security_group.alb.id", "aws_security_group.alb"]}}, "listener_protocol": {"description": "The listener protocol configured on the ALB, for a check asserting the deployed `HTTP` listener.", "expression": {"references": ["aws_lb_listener.this.protocol", "aws_lb_listener.this"]}}, "target_group_arn": {"description": "Target group holding the execute-api endpoint ENI IPs, for the T3 check to assert target health from.", "expression": {"references": ["aws_lb_target_group.execute_api.arn", "aws_lb_target_group.execute_api"]}}, "vpc_origin_id": {"description": "Id of the CloudFront VPC origin. Goes into the distribution origin's `vpc_origin_config.vpc_origin_id` for the `/api/*` behaviour.", "expression": {"references": ["aws_cloudfront_vpc_origin.this.id", "aws_cloudfront_vpc_origin.this"]}}}, "resources": [{"address": "aws_cloudfront_vpc_origin.this", "expressions": {"tags": {"references": ["var.tags"]}, "vpc_origin_endpoint_config": [{"arn": {"references": ["aws_lb.this.arn", "aws_lb.this"]}, "http_port": {"references": ["var.listener_port"]}, "https_port": {"constant_value": 443}, "name": {"references": ["var.name_prefix"]}, "origin_protocol_policy": {"references": ["var.origin_protocol_policy"]}, "origin_ssl_protocols": [{"items": {"constant_value": ["TLSv1.2"]}, "quantity": {"constant_value": 1}}]}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_vpc_origin"}, {"address": "aws_lb.this", "expressions": {"access_logs": [{"bucket": {"references": ["var.access_logs_bucket"]}, "enabled": {"constant_value": true}, "prefix": {"references": ["var.access_logs_prefix"]}}], "drop_invalid_header_fields": {"constant_value": true}, "enable_deletion_protection": {"constant_value": true}, "internal": {"constant_value": true}, "load_balancer_type": {"constant_value": "application"}, "name": {"references": ["var.name_prefix"]}, "security_groups": {"references": ["aws_security_group.alb.id", "aws_security_group.alb"]}, "subnets": {"references": ["var.private_subnet_ids"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lb"}, {"address": "aws_lb_listener.this", "expressions": {"default_action": [{"target_group_arn": {"references": ["aws_lb_target_group.execute_api.arn", "aws_lb_target_group.execute_api"]}, "type": {"constant_value": "forward"}}], "load_balancer_arn": {"references": ["aws_lb.this.arn", "aws_lb.this"]}, "port": {"references": ["var.listener_port"]}, "protocol": {"references": ["var.listener_protocol"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lb_listener"}, {"address": "aws_lb_target_group.execute_api", "expressions": {"health_check": [{"healthy_threshold": {"constant_value": 2}, "interval": {"constant_value": 30}, "matcher": {"constant_value": "200,403"}, "path": {"constant_value": "/"}, "protocol": {"constant_value": "HTTPS"}, "timeout": {"constant_value": 5}, "unhealthy_threshold": {"constant_value": 2}}], "name": {"references": ["var.name_prefix"]}, "port": {"constant_value": 443}, "protocol": {"constant_value": "HTTPS"}, "tags": {"references": ["var.tags"]}, "target_type": {"constant_value": "ip"}, "vpc_id": {"references": ["var.vpc_id"]}}, "mode": "managed", "name": "execute_api", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lb_target_group"}, {"address": "aws_lb_target_group_attachment.execute_api", "count_expression": {"references": ["var.private_subnet_ids"]}, "expressions": {"port": {"constant_value": 443}, "target_group_arn": {"references": ["aws_lb_target_group.execute_api.arn", "aws_lb_target_group.execute_api"]}, "target_id": {"references": ["var.execute_api_target_ips", "count.index"]}}, "mode": "managed", "name": "execute_api", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lb_target_group_attachment"}, {"address": "aws_security_group.alb", "expressions": {"description": {"constant_value": "Internal ALB fronting the private REST API for the CloudFront /api/* VPC origin"}, "name": {"references": ["var.name_prefix"]}, "tags": {"references": ["var.tags", "var.name_prefix"]}, "vpc_id": {"references": ["var.vpc_id"]}}, "mode": "managed", "name": "alb", "provider_config_key": "aws", "schema_version": 1, "type": "aws_security_group"}, {"address": "aws_vpc_security_group_egress_rule.alb_to_endpoint", "expressions": {"description": {"constant_value": "internal ALB to execute-api interface endpoint (443, TLS)"}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "referenced_security_group_id": {"references": ["var.execute_api_security_group_id"]}, "security_group_id": {"references": ["aws_security_group.alb.id", "aws_security_group.alb"]}, "to_port": {"constant_value": 443}}, "mode": "managed", "name": "alb_to_endpoint", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_egress_rule"}, {"address": "aws_vpc_security_group_ingress_rule.alb_from_cloudfront", "expressions": {"description": {"references": ["var.listener_port"]}, "from_port": {"references": ["var.listener_port"]}, "ip_protocol": {"constant_value": "tcp"}, "referenced_security_group_id": {"references": ["each.value"]}, "security_group_id": {"references": ["aws_security_group.alb.id", "aws_security_group.alb"]}, "to_port": {"references": ["var.listener_port"]}}, "for_each_expression": {"references": ["var.alb_ingress_security_group_ids"]}, "mode": "managed", "name": "alb_from_cloudfront", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_ingress_rule"}], "variables": {"access_logs_bucket": {"description": "S3 bucket receiving ALB access logs. Required."}, "access_logs_prefix": {"description": "Key prefix the ALB writes access logs under. No default; it must equal the prefix in the destination bucket policy grant (`//AWSLogs//*`). The root passes one local to both sides."}, "alb_ingress_security_group_ids": {"description": "Security group ids permitted to reach the ALB listener port: the security group the deployed CloudFront VPC origin presents. No default; see the first-deployment steps in `docs/runbook.md`."}, "execute_api_security_group_id": {"description": "Security group id of the `execute-api` interface endpoint, the ALB single egress destination on 443."}, "execute_api_target_ips": {"description": "Private IPv4 addresses of the `execute-api` interface endpoint's ENIs, one per entry in `private_subnet_ids`, resolved in the root. Registered as the target group's IP targets."}, "listener_port": {"default": 80, "description": "ALB listener port. 80 with the `http-only` origin protocol policy; 443 only if an origin certificate exists, which requires a domain the owner controls."}, "listener_protocol": {"default": "HTTP", "description": "ALB listener protocol. `HTTP` on the CloudFront->ALB hop: an accepted deviation from encryption-in-transit on that hop only. The ALB->endpoint hop is HTTPS regardless."}, "name_prefix": {"description": "Resource name prefix, from the root's `local.name_prefix`."}, "origin_protocol_policy": {"default": "http-only", "description": "How CloudFront connects to the VPC origin. Defaults to `http-only`; `match-viewer` is rejected by validation, since the viewer is always HTTPS and this stack has no origin certificate."}, "private_subnet_ids": {"description": "Private subnet ids for the ALB. Also fixes the plan-time count of endpoint ENIs, since the interface endpoint places one ENI per subnet (see the `count` note in main.tf)."}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-resource override or addition."}, "vpc_id": {"description": "Id of the adopted VPC the ALB and target group live in (`modules/vpc`'s vpc id output)."}}}, "source": "./modules/api_origin"}, "cognito": {"expressions": {"mcp_client_generate_secret": {"constant_value": true}, "pre_token_generation_lambda_arn": {"references": ["module.lambda_action_pre_token_generation.function_arn", "module.lambda_action_pre_token_generation"]}, "pre_token_generation_lambda_function_name": {"references": ["module.lambda_action_pre_token_generation.function_name", "module.lambda_action_pre_token_generation"]}, "spa_callback_urls": {"references": ["module.frontend_cdn.distribution_domain_name", "module.frontend_cdn"]}, "spa_logout_urls": {"references": ["module.frontend_cdn.distribution_domain_name", "module.frontend_cdn"]}, "user_pool_name": {"constant_value": "crm-agent-eval"}}, "module": {"outputs": {"admin_group_name": {"description": "Name of the Cognito group whose members are admin.", "expression": {"references": ["aws_cognito_user_group.admin.name", "aws_cognito_user_group.admin"]}}, "allowed_client_ids": {"description": "The SPA and MCP app client ids, for Gateway #1's authorizer and interceptor `COGNITO_ALLOWED_CLIENT_IDS`. Excludes the MCP OAuth client.", "expression": {"references": ["aws_cognito_user_pool_client.spa.id", "aws_cognito_user_pool_client.spa", "aws_cognito_user_pool_client.mcp.id", "aws_cognito_user_pool_client.mcp"]}}, "chat_gateway_allowed_client_ids": {"description": "`allowed_client_ids` plus the MCP OAuth client: Gateway #2's authorizer `allowed_clients` and its interceptor's `COGNITO_ALLOWED_CLIENT_IDS`.", "expression": {"references": ["aws_cognito_user_pool_client.spa.id", "aws_cognito_user_pool_client.spa", "aws_cognito_user_pool_client.mcp.id", "aws_cognito_user_pool_client.mcp", "aws_cognito_user_pool_client.mcp_oauth.id", "aws_cognito_user_pool_client.mcp_oauth"]}}, "chat_scope_identifier": {"description": "Gateway #2's own `supervisor/chat` scope: its `CUSTOM_JWT` `allowedScopes`, the pre-token trigger's and interceptor's `CHAT_SCOPE`. Distinct from `gateway_scope_identifier`.", "expression": {"references": ["aws_cognito_resource_server.supervisor.scope_identifiers[0]", "aws_cognito_resource_server.supervisor.scope_identifiers", "aws_cognito_resource_server.supervisor"]}}, "domain": {"description": "Cognito user pool prefix domain (no custom ACM certificate). The base for the `/oauth2/token` token endpoint the MCP `client_credentials` flow mints against.", "expression": {"references": ["aws_cognito_user_pool_domain.this.domain", "aws_cognito_user_pool_domain.this"]}}, "gateway_scope_identifier": {"description": "Fully-qualified `/` custom scope\n(`aws_cognito_resource_server.gateway.scope_identifiers[0]`) that the MCP app client's\n`client_credentials` token carries, and the value the AgentCore Gateway's `CUSTOM_JWT` authorizer\nallows (`allowedScopes`). The root composition consumes this output for both.\n", "expression": {"references": ["aws_cognito_resource_server.gateway.scope_identifiers[0]", "aws_cognito_resource_server.gateway.scope_identifiers", "aws_cognito_resource_server.gateway"]}}, "mcp_client_id": {"description": "App client id for MCP clients (confidential client).", "expression": {"references": ["aws_cognito_user_pool_client.mcp.id", "aws_cognito_user_pool_client.mcp"]}}, "mcp_client_secret": {"description": "App client secret for the MCP client. Sensitive; held in Terraform state and the gitignored results/tf-outputs.json, never in a tracked file. This stack creates no Secrets Manager entry for it.", "expression": {"references": ["aws_cognito_user_pool_client.mcp.client_secret", "aws_cognito_user_pool_client.mcp"]}, "sensitive": true}, "mcp_oauth_client_id": {"description": "App client id for interactive MCP OAuth clients (public client, no secret; Gateway #2 only).", "expression": {"references": ["aws_cognito_user_pool_client.mcp_oauth.id", "aws_cognito_user_pool_client.mcp_oauth"]}}, "spa_client_id": {"description": "App client id for the SPA (public client, no secret).", "expression": {"references": ["aws_cognito_user_pool_client.spa.id", "aws_cognito_user_pool_client.spa"]}}, "user_pool_arn": {"description": "Cognito user pool ARN.", "expression": {"references": ["aws_cognito_user_pool.this.arn", "aws_cognito_user_pool.this"]}}, "user_pool_endpoint": {"description": "Cognito user pool endpoint, used to derive the OIDC discovery and JWKS URLs.", "expression": {"references": ["aws_cognito_user_pool.this.endpoint", "aws_cognito_user_pool.this"]}}, "user_pool_id": {"description": "Cognito user pool id.", "expression": {"references": ["aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}}}, "resources": [{"address": "aws_cognito_resource_server.gateway", "expressions": {"identifier": {"constant_value": "gateway"}, "name": {"constant_value": "AgentCore Gateway"}, "scope": [{"scope_description": {"constant_value": "Invoke the AgentCore Gateway MCP surface machine-to-machine."}, "scope_name": {"constant_value": "invoke"}}], "user_pool_id": {"references": ["aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}}, "mode": "managed", "name": "gateway", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cognito_resource_server"}, {"address": "aws_cognito_resource_server.supervisor", "expressions": {"identifier": {"constant_value": "supervisor"}, "name": {"constant_value": "AgentCore chat Gateway"}, "scope": [{"scope_description": {"constant_value": "Call chat_with_supervisor on the MCP chat Gateway."}, "scope_name": {"constant_value": "chat"}}], "user_pool_id": {"references": ["aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}}, "mode": "managed", "name": "supervisor", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cognito_resource_server"}, {"address": "aws_cognito_user_group.admin", "expressions": {"description": {"constant_value": "CRM eval administrators: live sweeps, cancel and unlock."}, "name": {"constant_value": "admin"}, "user_pool_id": {"references": ["aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}}, "mode": "managed", "name": "admin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cognito_user_group"}, {"address": "aws_cognito_user_pool.this", "expressions": {"account_recovery_setting": [{"recovery_mechanism": [{"name": {"constant_value": "verified_email"}, "priority": {"constant_value": 1}}]}], "admin_create_user_config": [{"allow_admin_create_user_only": {"constant_value": true}}], "auto_verified_attributes": {"constant_value": ["email"]}, "lambda_config": [{"pre_token_generation_config": [{"lambda_arn": {"references": ["var.pre_token_generation_lambda_arn"]}, "lambda_version": {"constant_value": "V2_0"}}]}], "mfa_configuration": {"references": ["var.mfa_configuration"]}, "name": {"references": ["var.user_pool_name"]}, "password_policy": [{"minimum_length": {"constant_value": 14}, "require_lowercase": {"constant_value": true}, "require_numbers": {"constant_value": true}, "require_symbols": {"constant_value": true}, "require_uppercase": {"constant_value": true}, "temporary_password_validity_days": {"constant_value": 7}}], "schema": [{"attribute_data_type": {"constant_value": "String"}, "mutable": {"constant_value": true}, "name": {"constant_value": "rep_id"}, "string_attribute_constraints": [{"max_length": {"constant_value": "128"}, "min_length": {"constant_value": "1"}}]}, {"attribute_data_type": {"constant_value": "String"}, "mutable": {"constant_value": true}, "name": {"constant_value": "book"}, "string_attribute_constraints": [{"max_length": {"constant_value": "2048"}, "min_length": {"constant_value": "0"}}]}, {"attribute_data_type": {"constant_value": "String"}, "mutable": {"constant_value": true}, "name": {"constant_value": "full_visibility"}, "string_attribute_constraints": [{"max_length": {"constant_value": "8"}, "min_length": {"constant_value": "1"}}]}, {"attribute_data_type": {"constant_value": "String"}, "mutable": {"constant_value": true}, "name": {"constant_value": "tenant"}, "string_attribute_constraints": [{"max_length": {"constant_value": "128"}, "min_length": {"constant_value": "1"}}]}], "software_token_mfa_configuration": [{"enabled": {"constant_value": true}}], "user_pool_tier": {"constant_value": "ESSENTIALS"}, "username_attributes": {"constant_value": ["email"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cognito_user_pool"}, {"address": "aws_cognito_user_pool_client.mcp", "expressions": {"access_token_validity": {"constant_value": 5}, "allowed_oauth_flows": {"constant_value": ["client_credentials"]}, "allowed_oauth_flows_user_pool_client": {"constant_value": true}, "allowed_oauth_scopes": {"references": ["aws_cognito_resource_server.gateway.scope_identifiers[0]", "aws_cognito_resource_server.gateway.scope_identifiers", "aws_cognito_resource_server.gateway", "aws_cognito_resource_server.supervisor.scope_identifiers[0]", "aws_cognito_resource_server.supervisor.scope_identifiers", "aws_cognito_resource_server.supervisor"]}, "enable_token_revocation": {"constant_value": true}, "explicit_auth_flows": {"constant_value": ["ALLOW_REFRESH_TOKEN_AUTH"]}, "generate_secret": {"references": ["var.mcp_client_generate_secret"]}, "name": {"constant_value": "crm-agent-eval-mcp"}, "prevent_user_existence_errors": {"constant_value": "ENABLED"}, "read_attributes": {"references": ["local.writable_profile_attributes", "local.scope_bearing_attributes"]}, "supported_identity_providers": {"constant_value": ["COGNITO"]}, "token_validity_units": [{"access_token": {"constant_value": "minutes"}}], "user_pool_id": {"references": ["aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}, "write_attributes": {"references": ["local.writable_profile_attributes"]}}, "mode": "managed", "name": "mcp", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cognito_user_pool_client"}, {"address": "aws_cognito_user_pool_client.mcp_oauth", "expressions": {"access_token_validity": {"constant_value": 1}, "allowed_oauth_flows": {"constant_value": ["code"]}, "allowed_oauth_flows_user_pool_client": {"constant_value": true}, "allowed_oauth_scopes": {"references": ["aws_cognito_resource_server.supervisor.scope_identifiers[0]", "aws_cognito_resource_server.supervisor.scope_identifiers", "aws_cognito_resource_server.supervisor"]}, "callback_urls": {"constant_value": ["http://localhost:6274/oauth/callback", "http://localhost:6274/oauth/callback/debug", "http://localhost:33418/callback"]}, "enable_token_revocation": {"constant_value": true}, "explicit_auth_flows": {"constant_value": ["ALLOW_REFRESH_TOKEN_AUTH"]}, "generate_secret": {"constant_value": false}, "id_token_validity": {"constant_value": 1}, "name": {"constant_value": "crm-agent-eval-mcp-oauth"}, "prevent_user_existence_errors": {"constant_value": "ENABLED"}, "read_attributes": {"references": ["local.writable_profile_attributes", "local.scope_bearing_attributes"]}, "refresh_token_validity": {"constant_value": 30}, "supported_identity_providers": {"constant_value": ["COGNITO"]}, "token_validity_units": [{"access_token": {"constant_value": "hours"}, "id_token": {"constant_value": "hours"}, "refresh_token": {"constant_value": "days"}}], "user_pool_id": {"references": ["aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}, "write_attributes": {"references": ["local.writable_profile_attributes"]}}, "mode": "managed", "name": "mcp_oauth", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cognito_user_pool_client"}, {"address": "aws_cognito_user_pool_client.spa", "expressions": {"access_token_validity": {"constant_value": 1}, "allowed_oauth_flows": {"constant_value": ["code"]}, "allowed_oauth_flows_user_pool_client": {"constant_value": true}, "allowed_oauth_scopes": {"constant_value": ["openid", "email", "profile"]}, "callback_urls": {"references": ["var.spa_callback_urls"]}, "enable_token_revocation": {"constant_value": true}, "explicit_auth_flows": {"constant_value": ["ALLOW_USER_SRP_AUTH", "ALLOW_REFRESH_TOKEN_AUTH", "ALLOW_ADMIN_USER_PASSWORD_AUTH"]}, "generate_secret": {"constant_value": false}, "id_token_validity": {"constant_value": 1}, "logout_urls": {"references": ["var.spa_logout_urls"]}, "name": {"constant_value": "crm-agent-eval-spa"}, "prevent_user_existence_errors": {"constant_value": "ENABLED"}, "read_attributes": {"references": ["local.writable_profile_attributes", "local.scope_bearing_attributes"]}, "refresh_token_validity": {"constant_value": 30}, "supported_identity_providers": {"constant_value": ["COGNITO"]}, "token_validity_units": [{"access_token": {"constant_value": "hours"}, "id_token": {"constant_value": "hours"}, "refresh_token": {"constant_value": "days"}}], "user_pool_id": {"references": ["aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}, "write_attributes": {"references": ["local.writable_profile_attributes"]}}, "mode": "managed", "name": "spa", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cognito_user_pool_client"}, {"address": "aws_cognito_user_pool_domain.this", "expressions": {"domain": {"references": ["var.user_pool_name", "aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}, "user_pool_id": {"references": ["aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cognito_user_pool_domain"}, {"address": "aws_lambda_permission.pre_token_generation", "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["var.pre_token_generation_lambda_function_name"]}, "principal": {"constant_value": "cognito-idp.amazonaws.com"}, "source_arn": {"references": ["aws_cognito_user_pool.this.arn", "aws_cognito_user_pool.this"]}, "statement_id": {"constant_value": "AllowCognitoInvokePreTokenGeneration"}}, "mode": "managed", "name": "pre_token_generation", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}], "variables": {"mcp_client_generate_secret": {"default": true, "description": "Whether the MCP app client is confidential (generates a client secret) and uses\n`client_credentials`. Defaults to true: the MCP client is a machine-to-machine caller. The stack\ncreates no Secrets Manager entry for the secret; see docs/mcp-client-guide.md.\n"}, "mfa_configuration": {"default": "OPTIONAL", "description": "Pool-level MFA enforcement. Defaults to `OPTIONAL`; the SPA does not implement TOTP enrollment, so\n`ON` makes interactive sign-in through the deployed frontend impossible. TOTP stays enabled either\nway, so a user who enrolls is still challenged.\n\n`OFF` is rejected by validation. Set `ON` once the frontend can complete\n`MFA_SETUP`/`SOFTWARE_TOKEN_MFA`.\n"}, "pre_token_generation_lambda_arn": {"description": "ARN of the pre-token-generation Lambda (V2 event) that stamps `custom:rep_id`,\n`custom:book`, `custom:full_visibility`, and `custom:tenant` into the access\ntoken. Created by the root composition and passed in.\n"}, "pre_token_generation_lambda_function_name": {"description": "Name of the pre-token-generation Lambda, used to scope the\n`aws_lambda_permission` that lets Cognito invoke it. Must be the function\nbehind `pre_token_generation_lambda_arn`.\n"}, "spa_callback_urls": {"description": "Allowed OAuth callback URLs for the SPA app client."}, "spa_logout_urls": {"description": "Allowed OAuth sign-out redirect URLs for the SPA app client."}, "user_pool_name": {"default": "crm-agent-eval", "description": "Name for the Cognito user pool."}}}, "source": "./modules/cognito"}, "dynamodb": {"expressions": {"account_id": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "administrator_principal_arns": {"references": ["var.crm_operator_principal_arns", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "caller_principal_arn": {"references": ["data.aws_iam_session_context.current.issuer_arn", "data.aws_iam_session_context.current"]}, "data_classification": {"references": ["var.data_classification"]}, "data_plane_principal_arns": {"references": ["local.dynamodb_data_plane_role_arns", "var.crm_operator_principal_arns"]}, "name_prefix": {"references": ["local.name_prefix"]}}, "module": {"outputs": {"gsi_arns": {"description": "Map of logical table name to a map of GSI name to that index's full ARN\n(`/index/`). Consumed by `infra/main.tf`'s per-tool\n`dynamodb_grants[].index_arns`: every `dynamodb:Query` in this schema targets a named GSI (see\n`crm.store.store.query_gsi`), so the grant names the index ARN.\n", "expression": {"references": ["local.tables"]}}, "kms_key_arn": {"description": "ARN of the customer-managed KMS key encrypting all eleven tables.", "expression": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}, "kms_key_id": {"description": "Key ID of the customer-managed KMS key encrypting all eleven tables.", "expression": {"references": ["aws_kms_key.dynamodb.key_id", "aws_kms_key.dynamodb"]}}, "table_arns": {"description": "Map of logical table name to table ARN.", "expression": {"references": ["local.tables"]}}, "table_names": {"description": "Map of logical table name to physical DynamoDB table name.", "expression": {"references": ["local.tables"]}}, "table_stream_arns": {"description": "Map of logical table name to stream ARN (null where streams are disabled).", "expression": {"references": ["local.tables"]}}}, "resources": [{"address": "aws_dynamodb_resource_policy.tables", "expressions": {"policy": {"references": ["local.table_policy_arns", "each.key", "local.table_policy_arns", "each.key", "var.data_plane_principal_arns", "local.table_policy_arns", "each.key", "local.table_policy_arns", "each.key", "var.administrator_principal_arns"]}, "resource_arn": {"references": ["each.value.arn", "each.value"]}}, "for_each_expression": {"references": ["local.tables"]}, "mode": "managed", "name": "tables", "provider_config_key": "aws", "schema_version": 0, "type": "aws_dynamodb_resource_policy"}, {"address": "aws_dynamodb_table.accounts", "expressions": {"attribute": [{"name": {"constant_value": "account_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_owner_rep_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "created_at"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "name_lower"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant_owner_rep_id"}, "name": {"constant_value": "gsi_owner"}, "non_key_attributes": {"constant_value": ["account_id", "owner_rep_id", "name", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["account_id", "name", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "name_lower"}}], "hash_key": {"constant_value": "account_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "accounts", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.activities", "expressions": {"attribute": [{"name": {"constant_value": "activity_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_opportunity_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "occurred_at"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_account_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "created_at"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant_opportunity_id"}, "name": {"constant_value": "gsi_opportunity"}, "non_key_attributes": {"constant_value": ["activity_id", "opportunity_id", "kind", "subject", "body", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "occurred_at"}}, {"hash_key": {"constant_value": "tenant_account_id"}, "name": {"constant_value": "gsi_account"}, "non_key_attributes": {"constant_value": ["activity_id", "account_id", "opportunity_id", "kind", "subject", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "occurred_at"}}, {"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["activity_id", "opportunity_id", "kind", "subject", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}], "hash_key": {"constant_value": "activity_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "activities", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.audit_records", "expressions": {"attribute": [{"name": {"constant_value": "audit_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_target_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "created_at"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_actor_rep_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant_target_id"}, "name": {"constant_value": "gsi_target"}, "non_key_attributes": {"constant_value": ["audit_id", "target_table", "target_id", "actor_rep_id", "reversed_at", "account_id", "status", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant_actor_rep_id"}, "name": {"constant_value": "gsi_actor"}, "non_key_attributes": {"constant_value": ["audit_id", "actor_rep_id", "target_table", "target_id", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["audit_id", "account_id", "target_id", "target_table", "status", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}], "hash_key": {"constant_value": "audit_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "audit_records", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.contacts", "expressions": {"attribute": [{"name": {"constant_value": "contact_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_account_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "created_at"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "name_lower"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant_account_id"}, "name": {"constant_value": "gsi_account"}, "non_key_attributes": {"constant_value": ["contact_id", "account_id", "name", "status", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["contact_id", "account_id", "name", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "name_lower"}}], "hash_key": {"constant_value": "contact_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "contacts", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.eval_results", "expressions": {"attribute": [{"name": {"constant_value": "run_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "result_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "run_id_task_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "arm"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "run_id_task_id"}, "name": {"constant_value": "gsi_task"}, "non_key_attributes": {"constant_value": ["tenant", "run_id", "result_id", "arm"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "arm"}}], "hash_key": {"constant_value": "run_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "range_key": {"constant_value": "result_id"}, "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "eval_results", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.eval_runs", "expressions": {"attribute": [{"name": {"constant_value": "run_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "status"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "started_at"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "status"}, "name": {"constant_value": "gsi_status"}, "non_key_attributes": {"constant_value": ["tenant", "run_id", "status"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "started_at"}}], "hash_key": {"constant_value": "run_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "eval_runs", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.notes", "expressions": {"attribute": [{"name": {"constant_value": "note_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_opportunity_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "created_at"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant_opportunity_id"}, "name": {"constant_value": "gsi_opportunity"}, "non_key_attributes": {"constant_value": ["note_id", "opportunity_id", "body", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["note_id", "opportunity_id", "body", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}], "hash_key": {"constant_value": "note_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "notes", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.opportunities", "expressions": {"attribute": [{"name": {"constant_value": "opportunity_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_account_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "created_at"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_owner_rep_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "stage_close_date"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_stage"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "close_date"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "name_lower"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant_account_id"}, "name": {"constant_value": "gsi_account"}, "non_key_attributes": {"constant_value": ["opportunity_id", "account_id", "name", "name_lower", "owner_rep_id", "stage", "close_date", "value", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant_owner_rep_id"}, "name": {"constant_value": "gsi_owner_stage"}, "non_key_attributes": {"constant_value": ["opportunity_id", "account_id", "name", "name_lower", "owner_rep_id", "stage", "close_date", "value", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "stage_close_date"}}, {"hash_key": {"constant_value": "tenant_stage"}, "name": {"constant_value": "gsi_stage"}, "non_key_attributes": {"constant_value": ["opportunity_id", "account_id", "name", "name_lower", "owner_rep_id", "stage", "close_date", "value", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "close_date"}}, {"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["opportunity_id", "account_id", "name", "owner_rep_id", "stage", "close_date", "value", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "name_lower"}}], "hash_key": {"constant_value": "opportunity_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "opportunities", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.proposals", "expressions": {"attribute": [{"name": {"constant_value": "proposal_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_status"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "created_at"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_actor_rep_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_target_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant_status"}, "name": {"constant_value": "gsi_status"}, "non_key_attributes": {"constant_value": ["proposal_id", "status", "target_table", "target_id", "actor_rep_id", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant_actor_rep_id"}, "name": {"constant_value": "gsi_actor"}, "non_key_attributes": {"constant_value": ["proposal_id", "actor_rep_id", "status", "target_table", "target_id", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant_target_id"}, "name": {"constant_value": "gsi_target"}, "non_key_attributes": {"constant_value": ["proposal_id", "target_table", "target_id", "status", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["proposal_id", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}], "hash_key": {"constant_value": "proposal_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "proposals", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.reps", "expressions": {"attribute": [{"name": {"constant_value": "rep_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["rep_id", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "rep_id"}}], "hash_key": {"constant_value": "rep_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "reps", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.usage_records", "expressions": {"attribute": [{"name": {"constant_value": "usage_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_correlation_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "created_at"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_run_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant_correlation_id"}, "name": {"constant_value": "gsi_correlation"}, "non_key_attributes": {"constant_value": ["usage_id", "correlation_id", "run_id", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant_run_id"}, "name": {"constant_value": "gsi_run"}, "non_key_attributes": {"constant_value": ["usage_id", "run_id", "correlation_id", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["usage_id", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}], "hash_key": {"constant_value": "usage_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "usage_records", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_kms_alias.dynamodb", "expressions": {"name": {"references": ["var.name_prefix"]}, "target_key_id": {"references": ["aws_kms_key.dynamodb.key_id", "aws_kms_key.dynamodb"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_alias"}, {"address": "aws_kms_key.dynamodb", "expressions": {"deletion_window_in_days": {"constant_value": 30}, "description": {"constant_value": "CMK for CRM DynamoDB table encryption at rest"}, "enable_key_rotation": {"constant_value": true}, "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key"}, {"address": "aws_kms_key_policy.dynamodb", "expressions": {"bypass_policy_lockout_safety_check": {"constant_value": false}, "key_id": {"references": ["aws_kms_key.dynamodb.id", "aws_kms_key.dynamodb"]}, "policy": {"references": ["var.account_id", "var.data_plane_principal_arns", "var.administrator_principal_arns"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key_policy"}, {"address": "data.aws_partition.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_partition"}, {"address": "data.aws_region.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_region"}], "variables": {"account_id": {"description": "Account id of the account-root statement in the CMK key policy."}, "administrator_principal_arns": {"description": "IAM role or user ARNs, or the account root, admitted to table and CMK administration. Every other principal is denied by the table and key policies."}, "caller_principal_arn": {"description": "Role or user ARN of the principal running this plan. The table and key policies refuse to plan unless it is a listed administrator other than the account root, so no apply can lock its own caller out."}, "data_classification": {"default": "confidential", "description": "Value for the `data-classification` tag on resources in this module."}, "data_plane_principal_arns": {"description": "IAM role or user ARNs admitted to the tables' data plane and to the CMK's key use. Every other principal is denied by the table and key policies."}, "name_prefix": {"default": "", "description": "Prefix applied to table and alias names, e.g. tenant or environment scoping."}}}, "source": "./modules/dynamodb"}, "eni_function_code_deny": {"expressions": {"name_prefix": {"references": ["local.name_prefix"]}}, "module": {"outputs": {"policy_arn": {"description": "ARN of the ENI function-code Deny policy, passed to every `lambda_action` and `agent_relay` instantiation.", "expression": {"references": ["aws_iam_policy.this.arn", "aws_iam_policy.this"]}}}, "resources": [{"address": "aws_iam_policy.this", "expressions": {"description": {"constant_value": "Denies the Hyperplane ENI actions to Lambda function code; Lambda's own ENI management is unaffected."}, "name": {"references": ["var.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.this.json", "data.aws_iam_policy_document.this"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "data.aws_iam_policy_document.this", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:DetachNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "condition": [{"test": {"constant_value": "Null"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "lambda:SourceFunctionArn"}}], "effect": {"constant_value": "Deny"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "DenyEniActionsToFunctionCode"}}]}, "mode": "data", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"name_prefix": {"description": "Deployment name prefix, from the root composition's `local.name_prefix`. Part of the policy name."}}}, "source": "./modules/eni_function_code_deny"}, "eval_artifacts": {"expressions": {"access_log_bucket_id": {"references": ["module.frontend_cdn.logs_bucket_name", "module.frontend_cdn"]}, "account_id": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "administrator_principal_arns": {"references": ["var.crm_operator_principal_arns", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "caller_principal_arn": {"references": ["data.aws_iam_session_context.current.issuer_arn", "data.aws_iam_session_context.current"]}, "data_classification": {"references": ["var.data_classification"]}, "data_plane_principal_arns": {"references": ["local.eval_artifacts_principal_arns", "var.crm_operator_principal_arns"]}, "kms_key_arn": {"references": ["aws_kms_key.eval_artifacts.arn", "aws_kms_key.eval_artifacts"]}, "name_prefix": {"references": ["local.name_prefix"]}, "writer_role_name": {"constant_value": null}}, "module": {"outputs": {"artifact_prefix": {"description": "The single key prefix artefacts are written under, and the only prefix the writer grant covers.", "expression": {"references": ["var.artifact_prefix"]}}, "bucket_arn": {"description": "ARN of the eval-artefacts bucket, for a consumer composing its own policy against it.", "expression": {"references": ["aws_s3_bucket.this.arn", "aws_s3_bucket.this"]}}, "bucket_name": {"description": "Name of the eval-artefacts bucket, which embeds the account id. Read by application code and the smoke suite.", "expression": {"references": ["aws_s3_bucket.this.id", "aws_s3_bucket.this"]}}}, "resources": [{"address": "aws_iam_role_policy.writer", "count_expression": {"references": ["var.writer_role_name"]}, "expressions": {"name": {"references": ["var.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.writer.json", "data.aws_iam_policy_document.writer"]}, "role": {"references": ["var.writer_role_name"]}}, "mode": "managed", "name": "writer", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_s3_bucket.this", "expressions": {"bucket": {"references": ["local.bucket_name"]}, "force_destroy": {"constant_value": true}, "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket"}, {"address": "aws_s3_bucket_lifecycle_configuration.this", "expressions": {"bucket": {"references": ["aws_s3_bucket.this.id", "aws_s3_bucket.this"]}, "rule": [{"abort_incomplete_multipart_upload": [{"days_after_initiation": {"constant_value": 7}}], "expiration": [{"days": {"references": ["var.artifact_retention_days"]}}], "filter": [{"prefix": {"references": ["var.artifact_prefix"]}}], "id": {"constant_value": "expire-artifacts"}, "noncurrent_version_expiration": [{"noncurrent_days": {"references": ["var.artifact_retention_days"]}}], "status": {"constant_value": "Enabled"}}, {"abort_incomplete_multipart_upload": [{"days_after_initiation": {"constant_value": 7}}], "filter": [{}], "id": {"constant_value": "expire-noncurrent-and-abort-uploads"}, "noncurrent_version_expiration": [{"noncurrent_days": {"references": ["var.artifact_retention_days"]}}], "status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 1, "type": "aws_s3_bucket_lifecycle_configuration"}, {"address": "aws_s3_bucket_logging.this", "expressions": {"bucket": {"references": ["aws_s3_bucket.this.id", "aws_s3_bucket.this"]}, "target_bucket": {"references": ["var.access_log_bucket_id"]}, "target_prefix": {"constant_value": "s3-access-logs/eval-artifacts/"}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_logging"}, {"address": "aws_s3_bucket_ownership_controls.this", "expressions": {"bucket": {"references": ["aws_s3_bucket.this.id", "aws_s3_bucket.this"]}, "rule": [{"object_ownership": {"constant_value": "BucketOwnerEnforced"}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_ownership_controls"}, {"address": "aws_s3_bucket_policy.this", "expressions": {"bucket": {"references": ["aws_s3_bucket.this.id", "aws_s3_bucket.this"]}, "policy": {"references": ["data.aws_iam_policy_document.bucket.json", "data.aws_iam_policy_document.bucket"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_policy"}, {"address": "aws_s3_bucket_public_access_block.this", "expressions": {"block_public_acls": {"constant_value": true}, "block_public_policy": {"constant_value": true}, "bucket": {"references": ["aws_s3_bucket.this.id", "aws_s3_bucket.this"]}, "ignore_public_acls": {"constant_value": true}, "restrict_public_buckets": {"constant_value": true}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_public_access_block"}, {"address": "aws_s3_bucket_server_side_encryption_configuration.this", "expressions": {"bucket": {"references": ["aws_s3_bucket.this.id", "aws_s3_bucket.this"]}, "rule": [{"apply_server_side_encryption_by_default": [{"kms_master_key_id": {"references": ["var.kms_key_arn"]}, "sse_algorithm": {"constant_value": "aws:kms"}}], "bucket_key_enabled": {"constant_value": true}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_server_side_encryption_configuration"}, {"address": "aws_s3_bucket_versioning.this", "expressions": {"bucket": {"references": ["aws_s3_bucket.this.id", "aws_s3_bucket.this"]}, "versioning_configuration": [{"status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_versioning"}, {"address": "data.aws_iam_policy_document.bucket", "expressions": {"statement": [{"actions": {"constant_value": ["s3:*"]}, "condition": [{"test": {"constant_value": "Bool"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:SecureTransport"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["local.bucket_arn", "local.bucket_arn"]}, "sid": {"constant_value": "DenyInsecureTransport"}}, {"actions": {"constant_value": ["s3:PutObject"]}, "condition": [{"test": {"constant_value": "StringNotEquals"}, "values": {"constant_value": ["aws:kms"]}, "variable": {"constant_value": "s3:x-amz-server-side-encryption"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["local.bucket_arn"]}, "sid": {"constant_value": "DenyUnencryptedObjectUploads"}}, {"actions": {"constant_value": ["s3:GetObject", "s3:GetObjectVersion", "s3:GetObjectAttributes", "s3:GetObjectVersionAttributes", "s3:GetObjectTagging", "s3:GetObjectVersionTagging", "s3:RestoreObject", "s3:ListBucket", "s3:ListBucketVersions", "s3:ListBucketMultipartUploads", "s3:ListMultipartUploadParts", "s3:PutObject", "s3:PutObjectTagging", "s3:DeleteObject", "s3:DeleteObjectVersion", "s3:DeleteObjectTagging", "s3:AbortMultipartUpload", "s3:PutObjectVersionTagging", "s3:DeleteObjectVersionTagging"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.data_plane_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"references": ["local.bucket_arn", "local.bucket_arn"]}, "sid": {"constant_value": "DenyObjectDataPlaneToNonProjectPrincipals"}}, {"actions": {"constant_value": ["s3:DeleteBucket", "s3:PutBucketPolicy", "s3:DeleteBucketPolicy", "s3:PutBucketVersioning", "s3:PutEncryptionConfiguration", "s3:PutLifecycleConfiguration", "s3:PutBucketLogging", "s3:PutBucketPublicAccessBlock", "s3:PutBucketOwnershipControls", "s3:PutBucketAcl", "s3:PutBucketTagging", "s3:PutReplicationConfiguration", "s3:PutInventoryConfiguration", "s3:PutBucketNotification", "s3:PutBucketObjectLockConfiguration", "s3:PutBucketRequestPayment", "s3:PutBucketWebsite", "s3:PutBucketCORS", "s3:PutAccelerateConfiguration", "s3:PutIntelligentTieringConfiguration", "s3:PutAnalyticsConfiguration", "s3:PutMetricsConfiguration"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.administrator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"references": ["local.bucket_arn"]}, "sid": {"constant_value": "DenyBucketAdministrationToNonOperators"}}]}, "mode": "data", "name": "bucket", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.writer", "expressions": {"statement": [{"actions": {"constant_value": ["s3:PutObject", "s3:GetObject"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["local.bucket_arn", "var.artifact_prefix"]}, "sid": {"constant_value": "WriteAndReadArtifactPrefix"}}, {"actions": {"constant_value": ["kms:GenerateDataKey", "kms:Decrypt"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.kms_key_arn"]}, "sid": {"constant_value": "UseBucketCmk"}}]}, "mode": "data", "name": "writer", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_partition.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_partition"}], "variables": {"access_log_bucket_id": {"description": "Bucket id receiving this bucket S3 access logs. Must be a different bucket."}, "account_id": {"description": "AWS account id, part of the globally-unique bucket name. Passed in by the caller so the module plans offline."}, "administrator_principal_arns": {"description": "IAM role or user ARNs, or the account root, admitted to bucket administration. Every other principal is denied it by the bucket policy."}, "artifact_prefix": {"default": "sweeps", "description": "Single key prefix all artefacts are written under, and the only prefix the writer grant covers."}, "artifact_retention_days": {"default": 30, "description": "Lifecycle expiry in days, applied to current objects, noncurrent versions and incomplete multipart\nuploads alike. Artefacts are reproducible from a sweep with the same arguments and `dataset_seed`.\n"}, "caller_principal_arn": {"description": "Role or user ARN of the principal running this plan. The bucket policy refuses to plan unless it is a listed administrator other than the account root, so no apply can lock its own caller out."}, "data_classification": {"description": "Value of the mandatory `data-classification` tag."}, "data_plane_principal_arns": {"description": "IAM role or user ARNs admitted to the bucket's object reads, lists and writes. Every other principal is denied them by the bucket policy."}, "kms_key_arn": {"description": "Customer-managed key ARN encrypting this bucket's objects, and the key the writer grant covers.\nCreated by the caller; it must be a dedicated key (see README).\n"}, "name_prefix": {"description": "Deployment name prefix, from the root composition's `local.name_prefix`. Part of the bucket name alongside the account id."}, "writer_role_name": {"default": null, "description": "IAM role name the writer policy is attached to (the sweep worker's role). `null` (the default)\nattaches nothing. The grant's scope comes from the policy's own resources, not from this value.\n"}}}, "source": "./modules/eval_artifacts"}, "frontend_cdn": {"expressions": {"administrator_principal_arns": {"references": ["var.crm_operator_principal_arns", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "agent_relay_function_name": {"references": ["module.agent_relay.function_name", "module.agent_relay"]}, "agent_relay_function_url_domain": {"references": ["module.agent_relay.function_url_domain", "module.agent_relay"]}, "alb_access_log_prefix": {"references": ["local.alb_access_log_prefix"]}, "api_gateway_domain_name": {"references": ["module.api.private_origin_domain_name", "module.api"]}, "api_gateway_stage_name": {"references": ["module.api.stage_name", "module.api"]}, "api_origin_vpc_origin_id": {"references": ["module.api_origin.vpc_origin_id", "module.api_origin"]}, "caller_principal_arn": {"references": ["data.aws_iam_session_context.current.issuer_arn", "data.aws_iam_session_context.current"]}, "data_classification": {"references": ["var.data_classification"]}, "log_retention_days": {"constant_value": 90}, "name_prefix": {"references": ["local.name_prefix"]}, "operator_principal_arns": {"references": ["var.crm_operator_principal_arns"]}, "origin_noncurrent_version_retention_days": {"constant_value": 30}}, "module": {"outputs": {"distribution_arn": {"description": "ARN of the CloudFront distribution, used by the origin bucket policy's `AWS:SourceArn` condition.", "expression": {"references": ["aws_cloudfront_distribution.frontend.arn", "aws_cloudfront_distribution.frontend"]}}, "distribution_domain_name": {"description": "CloudFront distribution domain name (e.g. `d111111abcdef8.cloudfront.net`).", "expression": {"references": ["aws_cloudfront_distribution.frontend.domain_name", "aws_cloudfront_distribution.frontend"]}}, "distribution_id": {"description": "ID of the CloudFront distribution.", "expression": {"references": ["aws_cloudfront_distribution.frontend.id", "aws_cloudfront_distribution.frontend"]}}, "kms_key_arn": {"description": "ARN of the customer-managed KMS key encrypting the origin bucket.", "expression": {"references": ["aws_kms_key.frontend.arn", "aws_kms_key.frontend"]}}, "logs_bucket_name": {"description": "Name of the S3 bucket receiving S3 access logs and CloudFront access logs.", "expression": {"references": ["aws_s3_bucket.logs.id", "aws_s3_bucket.logs"]}}, "origin_bucket_arn": {"description": "ARN of the private S3 origin bucket.", "expression": {"references": ["aws_s3_bucket.origin.arn", "aws_s3_bucket.origin"]}}, "origin_bucket_name": {"description": "Name of the private S3 bucket that holds the frontend static build.", "expression": {"references": ["aws_s3_bucket.origin.id", "aws_s3_bucket.origin"]}}}, "resources": [{"address": "aws_cloudfront_distribution.frontend", "expressions": {"comment": {"references": ["var.name_prefix"]}, "default_cache_behavior": [{"allowed_methods": {"constant_value": ["GET", "HEAD"]}, "cache_policy_id": {"references": ["data.aws_cloudfront_cache_policy.caching_optimized.id", "data.aws_cloudfront_cache_policy.caching_optimized"]}, "cached_methods": {"constant_value": ["GET", "HEAD"]}, "compress": {"constant_value": true}, "function_association": [{"event_type": {"constant_value": "viewer-request"}, "function_arn": {"references": ["aws_cloudfront_function.spa_history_fallback.arn", "aws_cloudfront_function.spa_history_fallback"]}}], "response_headers_policy_id": {"references": ["data.aws_cloudfront_response_headers_policy.security_headers.id", "data.aws_cloudfront_response_headers_policy.security_headers"]}, "target_origin_id": {"constant_value": "s3-frontend-origin"}, "viewer_protocol_policy": {"constant_value": "redirect-to-https"}}], "default_root_object": {"constant_value": "index.html"}, "enabled": {"constant_value": true}, "logging_config": [{"bucket": {"references": ["aws_s3_bucket.logs.bucket_domain_name", "aws_s3_bucket.logs"]}, "include_cookies": {"constant_value": false}, "prefix": {"constant_value": "cloudfront-access-logs/"}}], "ordered_cache_behavior": [{"allowed_methods": {"constant_value": ["GET", "HEAD", "OPTIONS", "PUT", "POST", "PATCH", "DELETE"]}, "cache_policy_id": {"references": ["data.aws_cloudfront_cache_policy.caching_disabled.id", "data.aws_cloudfront_cache_policy.caching_disabled"]}, "cached_methods": {"constant_value": ["GET", "HEAD"]}, "compress": {"constant_value": true}, "function_association": [{"event_type": {"constant_value": "viewer-request"}, "function_arn": {"references": ["aws_cloudfront_function.api_path_rewrite.arn", "aws_cloudfront_function.api_path_rewrite"]}}], "origin_request_policy_id": {"references": ["data.aws_cloudfront_origin_request_policy.all_viewer_except_host.id", "data.aws_cloudfront_origin_request_policy.all_viewer_except_host"]}, "path_pattern": {"constant_value": "/api/*"}, "response_headers_policy_id": {"references": ["data.aws_cloudfront_response_headers_policy.security_headers.id", "data.aws_cloudfront_response_headers_policy.security_headers"]}, "target_origin_id": {"constant_value": "api-gateway-origin"}, "viewer_protocol_policy": {"constant_value": "https-only"}}, {"allowed_methods": {"constant_value": ["GET", "HEAD", "OPTIONS", "PUT", "POST", "PATCH", "DELETE"]}, "cache_policy_id": {"references": ["data.aws_cloudfront_cache_policy.caching_disabled.id", "data.aws_cloudfront_cache_policy.caching_disabled"]}, "cached_methods": {"constant_value": ["GET", "HEAD"]}, "compress": {"constant_value": false}, "origin_request_policy_id": {"references": ["aws_cloudfront_origin_request_policy.agent_relay.id", "aws_cloudfront_origin_request_policy.agent_relay"]}, "path_pattern": {"constant_value": "/agent/*"}, "response_headers_policy_id": {"references": ["data.aws_cloudfront_response_headers_policy.security_headers.id", "data.aws_cloudfront_response_headers_policy.security_headers"]}, "target_origin_id": {"constant_value": "agent-relay-origin"}, "viewer_protocol_policy": {"constant_value": "https-only"}}], "origin": [{"domain_name": {"references": ["aws_s3_bucket.origin.bucket_regional_domain_name", "aws_s3_bucket.origin"]}, "origin_access_control_id": {"references": ["aws_cloudfront_origin_access_control.origin.id", "aws_cloudfront_origin_access_control.origin"]}, "origin_id": {"constant_value": "s3-frontend-origin"}}, {"domain_name": {"references": ["var.api_gateway_domain_name"]}, "origin_id": {"constant_value": "api-gateway-origin"}, "vpc_origin_config": [{"vpc_origin_id": {"references": ["var.api_origin_vpc_origin_id"]}}]}, {"custom_origin_config": [{"http_port": {"constant_value": 80}, "https_port": {"constant_value": 443}, "origin_protocol_policy": {"constant_value": "https-only"}, "origin_read_timeout": {"constant_value": 60}, "origin_ssl_protocols": {"constant_value": ["TLSv1.2"]}}], "domain_name": {"references": ["var.agent_relay_function_url_domain"]}, "origin_access_control_id": {"references": ["aws_cloudfront_origin_access_control.agent_relay.id", "aws_cloudfront_origin_access_control.agent_relay"]}, "origin_id": {"constant_value": "agent-relay-origin"}}], "price_class": {"constant_value": "PriceClass_100"}, "restrictions": [{"geo_restriction": [{"restriction_type": {"constant_value": "none"}}]}], "tags": {"references": ["var.data_classification"]}, "viewer_certificate": [{"cloudfront_default_certificate": {"constant_value": true}}]}, "mode": "managed", "name": "frontend", "provider_config_key": "aws", "schema_version": 1, "type": "aws_cloudfront_distribution"}, {"address": "aws_cloudfront_function.api_path_rewrite", "expressions": {"code": {"references": ["path.module", "var.api_gateway_stage_name"]}, "comment": {"constant_value": "Rewrite /api/* onto the REST API's stage path"}, "name": {"references": ["var.name_prefix"]}, "publish": {"constant_value": true}, "runtime": {"constant_value": "cloudfront-js-2.0"}}, "mode": "managed", "name": "api_path_rewrite", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_function"}, {"address": "aws_cloudfront_function.spa_history_fallback", "expressions": {"code": {"references": ["path.module"]}, "comment": {"constant_value": "Serve /index.html for SPA client-side routes"}, "name": {"references": ["var.name_prefix"]}, "publish": {"constant_value": true}, "runtime": {"constant_value": "cloudfront-js-2.0"}}, "mode": "managed", "name": "spa_history_fallback", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_function"}, {"address": "aws_cloudfront_origin_access_control.agent_relay", "expressions": {"description": {"constant_value": "SigV4-signs origin requests to the relay's AWS_IAM Function URL"}, "name": {"references": ["var.name_prefix"]}, "origin_access_control_origin_type": {"constant_value": "lambda"}, "signing_behavior": {"constant_value": "always"}, "signing_protocol": {"constant_value": "sigv4"}}, "mode": "managed", "name": "agent_relay", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_origin_access_control"}, {"address": "aws_cloudfront_origin_access_control.origin", "expressions": {"name": {"references": ["var.name_prefix"]}, "origin_access_control_origin_type": {"constant_value": "s3"}, "signing_behavior": {"constant_value": "always"}, "signing_protocol": {"constant_value": "sigv4"}}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_origin_access_control"}, {"address": "aws_cloudfront_origin_request_policy.agent_relay", "expressions": {"comment": {"constant_value": "Forward every viewer header except Host to the relay origin"}, "cookies_config": [{"cookie_behavior": {"constant_value": "all"}}], "headers_config": [{"header_behavior": {"constant_value": "allExcept"}, "headers": [{"items": {"constant_value": ["host"]}}]}], "name": {"references": ["var.name_prefix"]}, "query_strings_config": [{"query_string_behavior": {"constant_value": "all"}}]}, "mode": "managed", "name": "agent_relay", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_origin_request_policy"}, {"address": "aws_kms_alias.frontend", "expressions": {"name": {"references": ["var.name_prefix"]}, "target_key_id": {"references": ["aws_kms_key.frontend.key_id", "aws_kms_key.frontend"]}}, "mode": "managed", "name": "frontend", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_alias"}, {"address": "aws_kms_key.frontend", "expressions": {"deletion_window_in_days": {"constant_value": 30}, "description": {"constant_value": "CMK for CRM frontend CDN origin bucket encryption at rest"}, "enable_key_rotation": {"constant_value": true}, "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "frontend", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key"}, {"address": "aws_kms_key_policy.frontend", "expressions": {"bypass_policy_lockout_safety_check": {"constant_value": false}, "key_id": {"references": ["aws_kms_key.frontend.id", "aws_kms_key.frontend"]}, "policy": {"references": ["data.aws_iam_policy_document.frontend_kms.json", "data.aws_iam_policy_document.frontend_kms"]}}, "mode": "managed", "name": "frontend", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key_policy"}, {"address": "aws_lambda_permission.agent_relay_function_url", "expressions": {"action": {"constant_value": "lambda:InvokeFunctionUrl"}, "function_name": {"references": ["var.agent_relay_function_name"]}, "function_url_auth_type": {"constant_value": "AWS_IAM"}, "principal": {"constant_value": "cloudfront.amazonaws.com"}, "source_arn": {"references": ["aws_cloudfront_distribution.frontend.arn", "aws_cloudfront_distribution.frontend"]}, "statement_id": {"constant_value": "AllowCloudFrontOacInvokeFunctionUrl"}}, "mode": "managed", "name": "agent_relay_function_url", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "aws_lambda_permission.agent_relay_invoke_function", "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["var.agent_relay_function_name"]}, "principal": {"constant_value": "cloudfront.amazonaws.com"}, "source_arn": {"references": ["aws_cloudfront_distribution.frontend.arn", "aws_cloudfront_distribution.frontend"]}, "statement_id": {"constant_value": "AllowCloudFrontOacInvokeFunction"}}, "mode": "managed", "name": "agent_relay_invoke_function", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "aws_s3_bucket.logs", "expressions": {"bucket": {"references": ["var.name_prefix", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "force_destroy": {"constant_value": true}, "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket"}, {"address": "aws_s3_bucket.origin", "expressions": {"bucket": {"references": ["var.name_prefix", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "force_destroy": {"constant_value": true}, "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket"}, {"address": "aws_s3_bucket_lifecycle_configuration.logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.logs.id", "aws_s3_bucket.logs"]}, "rule": [{"abort_incomplete_multipart_upload": [{"days_after_initiation": {"constant_value": 7}}], "expiration": [{"days": {"references": ["var.log_retention_days"]}}], "filter": [{}], "id": {"constant_value": "expire-access-logs"}, "noncurrent_version_expiration": [{"noncurrent_days": {"references": ["var.log_retention_days"]}}], "status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 1, "type": "aws_s3_bucket_lifecycle_configuration"}, {"address": "aws_s3_bucket_lifecycle_configuration.origin", "expressions": {"bucket": {"references": ["aws_s3_bucket.origin.id", "aws_s3_bucket.origin"]}, "rule": [{"abort_incomplete_multipart_upload": [{"days_after_initiation": {"constant_value": 7}}], "filter": [{}], "id": {"constant_value": "expire-superseded-builds"}, "noncurrent_version_expiration": [{"noncurrent_days": {"references": ["var.origin_noncurrent_version_retention_days"]}}], "status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 1, "type": "aws_s3_bucket_lifecycle_configuration"}, {"address": "aws_s3_bucket_logging.origin", "expressions": {"bucket": {"references": ["aws_s3_bucket.origin.id", "aws_s3_bucket.origin"]}, "target_bucket": {"references": ["aws_s3_bucket.logs.id", "aws_s3_bucket.logs"]}, "target_prefix": {"constant_value": "s3-access-logs/origin/"}}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_logging"}, {"address": "aws_s3_bucket_ownership_controls.logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.logs.id", "aws_s3_bucket.logs"]}, "rule": [{"object_ownership": {"constant_value": "BucketOwnerPreferred"}}]}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_ownership_controls"}, {"address": "aws_s3_bucket_ownership_controls.origin", "expressions": {"bucket": {"references": ["aws_s3_bucket.origin.id", "aws_s3_bucket.origin"]}, "rule": [{"object_ownership": {"constant_value": "BucketOwnerEnforced"}}]}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_ownership_controls"}, {"address": "aws_s3_bucket_policy.logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.logs.id", "aws_s3_bucket.logs"]}, "policy": {"references": ["data.aws_iam_policy_document.logs_tls_deny.json", "data.aws_iam_policy_document.logs_tls_deny"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_policy"}, {"address": "aws_s3_bucket_policy.origin", "expressions": {"bucket": {"references": ["aws_s3_bucket.origin.id", "aws_s3_bucket.origin"]}, "policy": {"references": ["data.aws_iam_policy_document.origin.json", "data.aws_iam_policy_document.origin"]}}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_policy"}, {"address": "aws_s3_bucket_public_access_block.logs", "expressions": {"block_public_acls": {"constant_value": true}, "block_public_policy": {"constant_value": true}, "bucket": {"references": ["aws_s3_bucket.logs.id", "aws_s3_bucket.logs"]}, "ignore_public_acls": {"constant_value": true}, "restrict_public_buckets": {"constant_value": true}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_public_access_block"}, {"address": "aws_s3_bucket_public_access_block.origin", "expressions": {"block_public_acls": {"constant_value": true}, "block_public_policy": {"constant_value": true}, "bucket": {"references": ["aws_s3_bucket.origin.id", "aws_s3_bucket.origin"]}, "ignore_public_acls": {"constant_value": true}, "restrict_public_buckets": {"constant_value": true}}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_public_access_block"}, {"address": "aws_s3_bucket_server_side_encryption_configuration.logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.logs.id", "aws_s3_bucket.logs"]}, "rule": [{"apply_server_side_encryption_by_default": [{"sse_algorithm": {"constant_value": "AES256"}}], "bucket_key_enabled": {"constant_value": true}}]}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_server_side_encryption_configuration"}, {"address": "aws_s3_bucket_server_side_encryption_configuration.origin", "expressions": {"bucket": {"references": ["aws_s3_bucket.origin.id", "aws_s3_bucket.origin"]}, "rule": [{"apply_server_side_encryption_by_default": [{"kms_master_key_id": {"references": ["aws_kms_key.frontend.arn", "aws_kms_key.frontend"]}, "sse_algorithm": {"constant_value": "aws:kms"}}], "bucket_key_enabled": {"constant_value": true}}]}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_server_side_encryption_configuration"}, {"address": "aws_s3_bucket_versioning.logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.logs.id", "aws_s3_bucket.logs"]}, "versioning_configuration": [{"status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_versioning"}, {"address": "aws_s3_bucket_versioning.origin", "expressions": {"bucket": {"references": ["aws_s3_bucket.origin.id", "aws_s3_bucket.origin"]}, "versioning_configuration": [{"status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_versioning"}, {"address": "data.aws_caller_identity.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_caller_identity"}, {"address": "data.aws_cloudfront_cache_policy.caching_disabled", "expressions": {"name": {"constant_value": "Managed-CachingDisabled"}}, "mode": "data", "name": "caching_disabled", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_cache_policy"}, {"address": "data.aws_cloudfront_cache_policy.caching_optimized", "expressions": {"name": {"constant_value": "Managed-CachingOptimized"}}, "mode": "data", "name": "caching_optimized", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_cache_policy"}, {"address": "data.aws_cloudfront_origin_request_policy.all_viewer_except_host", "expressions": {"name": {"constant_value": "Managed-AllViewerExceptHostHeader"}}, "mode": "data", "name": "all_viewer_except_host", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_origin_request_policy"}, {"address": "data.aws_cloudfront_response_headers_policy.security_headers", "expressions": {"name": {"constant_value": "Managed-SecurityHeadersPolicy"}}, "mode": "data", "name": "security_headers", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_response_headers_policy"}, {"address": "data.aws_iam_policy_document.frontend_kms", "expressions": {"statement": [{"actions": {"constant_value": ["kms:*"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "type": {"constant_value": "AWS"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "EnableIAMUserPermissions"}}, {"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["aws_cloudfront_distribution.frontend.arn", "aws_cloudfront_distribution.frontend"]}, "variable": {"constant_value": "AWS:SourceArn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["cloudfront.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "AllowCloudFrontOACDecrypt"}}, {"actions": {"constant_value": ["kms:Decrypt", "kms:Encrypt", "kms:GenerateDataKey*", "kms:ReEncrypt*", "kms:CreateGrant"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.operator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}, {"test": {"constant_value": "Bool"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:PrincipalIsAWSService"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "DenyKeyUseToNonProjectPrincipals"}}, {"actions": {"constant_value": ["kms:PutKeyPolicy", "kms:ScheduleKeyDeletion", "kms:DisableKey", "kms:RevokeGrant", "kms:DisableKeyRotation", "kms:CreateAlias", "kms:UpdateAlias", "kms:DeleteAlias", "kms:TagResource", "kms:UntagResource", "kms:UpdateKeyDescription"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.administrator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "DenyKeyAdministrationToNonOperators"}}]}, "mode": "data", "name": "frontend_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs_tls_deny", "expressions": {"statement": [{"actions": {"constant_value": ["s3:PutObject"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "aws:SourceAccount"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["logging.s3.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"references": ["aws_s3_bucket.logs.arn", "aws_s3_bucket.logs"]}, "sid": {"constant_value": "AllowS3ServerAccessLogDelivery"}}, {"actions": {"constant_value": ["s3:PutObject"]}, "condition": [{"test": {"constant_value": "ArnLike"}, "values": {"references": ["data.aws_partition.current.partition", "data.aws_partition.current", "data.aws_region.current.region", "data.aws_region.current", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "aws:SourceArn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["logdelivery.elasticloadbalancing.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"references": ["aws_s3_bucket.logs.arn", "aws_s3_bucket.logs", "var.alb_access_log_prefix", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "sid": {"constant_value": "AllowAlbAccessLogDelivery"}}, {"actions": {"constant_value": ["s3:*"]}, "condition": [{"test": {"constant_value": "Bool"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:SecureTransport"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["aws_s3_bucket.logs.arn", "aws_s3_bucket.logs", "aws_s3_bucket.logs.arn", "aws_s3_bucket.logs"]}, "sid": {"constant_value": "DenyInsecureTransport"}}]}, "mode": "data", "name": "logs_tls_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.origin", "expressions": {"statement": [{"actions": {"constant_value": ["s3:*"]}, "condition": [{"test": {"constant_value": "Bool"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:SecureTransport"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["aws_s3_bucket.origin.arn", "aws_s3_bucket.origin", "aws_s3_bucket.origin.arn", "aws_s3_bucket.origin"]}, "sid": {"constant_value": "DenyInsecureTransport"}}, {"actions": {"constant_value": ["s3:GetObject"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["aws_cloudfront_distribution.frontend.arn", "aws_cloudfront_distribution.frontend"]}, "variable": {"constant_value": "AWS:SourceArn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["cloudfront.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"references": ["aws_s3_bucket.origin.arn", "aws_s3_bucket.origin"]}, "sid": {"constant_value": "AllowCloudFrontOACRead"}}, {"actions": {"constant_value": ["s3:PutObject", "s3:PutObjectTagging", "s3:DeleteObject", "s3:DeleteObjectVersion", "s3:DeleteObjectTagging", "s3:AbortMultipartUpload", "s3:PutObjectVersionTagging", "s3:DeleteObjectVersionTagging"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.operator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"references": ["aws_s3_bucket.origin.arn", "aws_s3_bucket.origin", "aws_s3_bucket.origin.arn", "aws_s3_bucket.origin"]}, "sid": {"constant_value": "DenyObjectWritesToNonOperators"}}, {"actions": {"constant_value": ["s3:DeleteBucket", "s3:PutBucketPolicy", "s3:DeleteBucketPolicy", "s3:PutBucketVersioning", "s3:PutEncryptionConfiguration", "s3:PutLifecycleConfiguration", "s3:PutBucketLogging", "s3:PutBucketPublicAccessBlock", "s3:PutBucketOwnershipControls", "s3:PutBucketAcl", "s3:PutBucketTagging", "s3:PutReplicationConfiguration", "s3:PutInventoryConfiguration", "s3:PutBucketNotification", "s3:PutBucketObjectLockConfiguration", "s3:PutBucketRequestPayment", "s3:PutBucketWebsite", "s3:PutBucketCORS", "s3:PutAccelerateConfiguration", "s3:PutIntelligentTieringConfiguration", "s3:PutAnalyticsConfiguration", "s3:PutMetricsConfiguration"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.administrator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"references": ["aws_s3_bucket.origin.arn", "aws_s3_bucket.origin"]}, "sid": {"constant_value": "DenyBucketAdministrationToNonOperators"}}]}, "mode": "data", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_partition.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_partition"}, {"address": "data.aws_region.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_region"}], "variables": {"administrator_principal_arns": {"description": "IAM role or user ARNs, or the account root, admitted to administration of the frontend CMK and the origin bucket. Every other principal is denied it."}, "agent_relay_function_name": {"description": "The relay function name (`module.agent_relay.function_name`), for the distribution-scoped `lambda:InvokeFunctionUrl` permission this module declares."}, "agent_relay_function_url_domain": {"description": "Host portion of the relay's Lambda Function URL that the `/agent/*` behaviour routes to (`module.agent_relay.function_url_domain`). The browser reaches the Runtime only through the relay."}, "alb_access_log_prefix": {"description": "Key prefix the internal ALB writes access logs under, used to scope this module ELB log-delivery grant to `//AWSLogs//*`. No default; it must equal the prefix the load balancer is configured with, and the root passes one local to both modules."}, "api_gateway_domain_name": {"description": "Origin hostname for the `/api/*` behaviour, from `module.api.private_origin_domain_name` (`-.execute-api..amazonaws.com`). It is the `Host` header the private REST API routes on, not a name CloudFront resolves; the VPC origin routes by ALB ARN."}, "api_gateway_stage_name": {"description": "Stage name the REST API serves its routes beneath (`infra/modules/api/` `stage_name`). The `/api/*` viewer-request function rewrites `/api/` to `//`, since CloudFront forwards the viewer path to a custom origin unchanged."}, "api_origin_vpc_origin_id": {"description": "Id of the CloudFront VPC origin fronting the private REST API (`module.api_origin.vpc_origin_id`), consumed by the `/api/*` origin `vpc_origin_config`."}, "caller_principal_arn": {"description": "Role or user ARN of the principal running this plan. The key and origin-bucket policies refuse to plan unless it is a listed administrator other than the account root, so no apply can lock its own caller out."}, "data_classification": {"default": "confidential", "description": "Value for the `data-classification` tag on resources in this module."}, "log_retention_days": {"default": 90, "description": "Retention, in days, for the S3 bucket holding S3 access logs and CloudFront access logs."}, "name_prefix": {"default": "", "description": "Prefix applied to resource names, e.g. project or environment scoping."}, "operator_principal_arns": {"description": "IAM role or user ARNs of the operators: the only non-service principals admitted to frontend-CMK use and to writes into the origin bucket."}, "origin_noncurrent_version_retention_days": {"default": 30, "description": "Days a superseded (noncurrent) object version in the origin bucket is kept before it expires. Current objects never expire."}}}, "source": "./modules/frontend_cdn"}, "lambda_action": {"expressions": {"attach_gateway_target_grant": {"constant_value": true}, "denied_own_table_actions": {"references": ["local.tool_dynamodb_grants", "each.key", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "local.tool_dynamodb_grants", "each.key", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb", "local.tool_dynamodb_grants", "each.key"]}, "dynamodb_grants": {"references": ["local.tool_dynamodb_grants", "each.key", "module.dynamodb.table_arns", "module.dynamodb", "local.tool_query_indexes", "each.key", "local.tool_query_indexes", "each.key", "module.dynamodb.gsi_arns", "module.dynamodb", "module.dynamodb.gsi_arns", "module.dynamodb", "local.tool_query_indexes", "each.key"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["local.name_prefix"]}, "filename": {"references": ["var.lambda_build_dir", "each.key"]}, "function_name": {"references": ["each.key"]}, "gateway_target_role_arn": {"references": ["aws_iam_role.agentcore_gateway.arn", "aws_iam_role.agentcore_gateway"]}, "handler": {"references": ["each.value.handler", "each.value"]}, "memory_size_mb": {"constant_value": 256}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency", "each.key"]}, "runtime": {"constant_value": "python3.13"}, "source_code_hash": {"references": ["var.lambda_build_dir", "each.key"]}, "table_action_role_matrix_entries": {"references": ["local.tool_dynamodb_grants", "each.key", "each.key"]}, "timeout_seconds": {"constant_value": 30}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "for_each_expression": {"references": ["local.tools"]}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.13", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_capabilities": {"expressions": {"denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_grants": {"constant_value": []}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"constant_value": {"PYTHONPATH": "/var/task/src"}}, "filename": {"references": ["local.eval_lambda_zip"]}, "function_name": {"constant_value": "crm-agent-eval-capabilities"}, "gateway_target_role_arn": {"constant_value": null}, "handler": {"constant_value": "crm.handlers.capabilities.handler"}, "memory_size_mb": {"constant_value": 256}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"capabilities\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.13"}, "source_code_hash": {"references": ["local.eval_lambda_zip"]}, "timeout_seconds": {"constant_value": 10}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.13", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_chat_interceptor": {"expressions": {"attach_gateway_target_grant": {"constant_value": true}, "denied_own_table_actions": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_grants": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb", "local.gateway_service_principal_rep_id"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["var.aws_region", "module.cognito.user_pool_id", "module.cognito", "module.cognito.chat_gateway_allowed_client_ids", "module.cognito", "var.aws_region", "module.cognito.user_pool_id", "module.cognito", "module.cognito.chat_scope_identifier", "module.cognito", "local.gateway_service_principal_rep_id", "local.name_prefix"]}, "filename": {"references": ["var.lambda_build_dir"]}, "function_name": {"references": ["local.name_prefix"]}, "gateway_target_role_arn": {"references": ["module.mcp_chat_gateway.role_arn", "module.mcp_chat_gateway"]}, "handler": {"constant_value": "gateway.identity_interceptor.lambda_handler"}, "memory_size_mb": {"constant_value": 256}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"chat_interceptor\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.13"}, "source_code_hash": {"references": ["var.lambda_build_dir"]}, "table_action_role_matrix_entries": {"references": ["local.name_prefix"]}, "timeout_seconds": {"constant_value": 10}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.13", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_chat_target": {"expressions": {"attach_gateway_target_grant": {"constant_value": true}, "denied_own_table_actions": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_grants": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb", "module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["local.name_prefix", "module.agentcore.agent_runtime_arn", "module.agentcore", "local.relay_runtime_qualifier"]}, "filename": {"references": ["var.lambda_build_dir"]}, "function_name": {"references": ["local.name_prefix"]}, "gateway_target_role_arn": {"references": ["module.mcp_chat_gateway.role_arn", "module.mcp_chat_gateway"]}, "handler": {"constant_value": "gateway.chat_target.lambda_handler"}, "memory_size_mb": {"constant_value": 512}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"chat_target\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.13"}, "source_code_hash": {"references": ["var.lambda_build_dir"]}, "table_action_role_matrix_entries": {"references": ["local.name_prefix", "local.name_prefix"]}, "timeout_seconds": {"constant_value": 660}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.13", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_eval_trigger": {"expressions": {"denied_own_table_actions": {"references": ["module.dynamodb.table_arns[\"eval_runs\"]", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "local.eval_trigger_eval_runs_grants", "module.dynamodb.table_arns[\"eval_runs\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_grants": {"references": ["local.eval_trigger_eval_runs_grants"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["local.name_prefix", "local.eval_sweep_state_machine_arn", "module.eval_artifacts.bucket_name", "module.eval_artifacts", "module.eval_artifacts.artifact_prefix", "module.eval_artifacts"]}, "filename": {"references": ["local.eval_lambda_zip"]}, "function_name": {"constant_value": "crm-agent-eval-eval-trigger"}, "gateway_target_role_arn": {"constant_value": null}, "handler": {"constant_value": "crm.handlers.eval_trigger.handler"}, "memory_size_mb": {"constant_value": 512}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"eval_trigger\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.13"}, "source_code_hash": {"references": ["local.eval_lambda_zip"]}, "timeout_seconds": {"constant_value": 30}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.13", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_interceptor": {"expressions": {"attach_gateway_target_grant": {"constant_value": true}, "denied_own_table_actions": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_grants": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb", "local.gateway_service_principal_rep_id"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["var.aws_region", "module.cognito.user_pool_id", "module.cognito", "module.cognito.allowed_client_ids", "module.cognito", "var.aws_region", "module.cognito.user_pool_id", "module.cognito", "module.cognito.gateway_scope_identifier", "module.cognito", "local.gateway_service_principal_rep_id", "local.name_prefix"]}, "filename": {"references": ["var.lambda_build_dir"]}, "function_name": {"constant_value": "crm-agent-eval-identity-interceptor"}, "gateway_target_role_arn": {"references": ["aws_iam_role.agentcore_gateway.arn", "aws_iam_role.agentcore_gateway"]}, "handler": {"constant_value": "gateway.identity_interceptor.lambda_handler"}, "memory_size_mb": {"constant_value": 256}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"identity_interceptor\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.13"}, "source_code_hash": {"references": ["var.lambda_build_dir"]}, "table_action_role_matrix_entries": {"constant_value": [{"action": "dynamodb:GetItem", "isolation_mechanism": "leading_keys", "leading_keys_enforced": true, "role": "crm-agent-eval-identity-interceptor-role", "table": "reps"}]}, "timeout_seconds": {"constant_value": 10}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.13", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_pre_token_generation": {"expressions": {"attach_gateway_target_grant": {"constant_value": true}, "denied_own_table_actions": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_grants": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["local.name_prefix", "local.chat_scope_identifier"]}, "filename": {"references": ["var.lambda_build_dir"]}, "function_name": {"constant_value": "crm-agent-eval-pre-token-generation"}, "gateway_target_role_arn": {"references": ["aws_iam_role.agentcore_gateway.arn", "aws_iam_role.agentcore_gateway"]}, "handler": {"constant_value": "crm.auth.pre_token_generation.lambda_handler"}, "memory_size_mb": {"constant_value": 128}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"pre_token_generation\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.13"}, "source_code_hash": {"references": ["var.lambda_build_dir"]}, "table_action_role_matrix_entries": {"constant_value": [{"action": "dynamodb:GetItem", "isolation_mechanism": "not_applicable", "leading_keys_enforced": false, "role": "crm-agent-eval-pre-token-generation-role", "table": "reps"}]}, "timeout_seconds": {"constant_value": 10}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.13", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_sweep_control": {"expressions": {"denied_own_table_actions": {"references": ["local.sweep_control_granted_tables", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "local.sweep_control_dynamodb_grants", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb", "local.sweep_control_granted_tables"]}, "dynamodb_allow_statements_per_policy": {"constant_value": 20}, "dynamodb_grants": {"references": ["local.sweep_control_dynamodb_grants", "module.dynamodb.table_arns", "module.dynamodb", "module.dynamodb.gsi_arns", "module.dynamodb", "module.dynamodb.gsi_arns", "module.dynamodb"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "dynamodb_policy_managed": {"constant_value": true}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["local.name_prefix", "module.eval_artifacts.bucket_name", "module.eval_artifacts", "module.eval_artifacts.artifact_prefix", "module.eval_artifacts"]}, "filename": {"references": ["local.eval_lambda_zip"]}, "function_name": {"constant_value": "crm-agent-eval-sweep-control"}, "gateway_target_role_arn": {"constant_value": null}, "handler": {"constant_value": "eval.sfn_handlers.sweep_control_handler"}, "memory_size_mb": {"constant_value": 1024}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"sweep_control\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.13"}, "source_code_hash": {"references": ["local.eval_lambda_zip"]}, "tags": {"references": ["var.data_classification"]}, "timeout_seconds": {"constant_value": 120}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.13", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_sweep_task": {"expressions": {"denied_own_table_actions": {"references": ["local.sweep_task_granted_tables", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "local.sweep_task_dynamodb_grants", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb", "local.sweep_task_granted_tables"]}, "dynamodb_grants": {"references": ["local.sweep_task_dynamodb_grants", "module.dynamodb.table_arns", "module.dynamodb", "module.dynamodb.gsi_arns", "module.dynamodb"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "dynamodb_policy_managed": {"constant_value": true}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["local.name_prefix", "module.agentcore.agent_runtime_arn", "module.agentcore", "local.relay_runtime_qualifier"]}, "filename": {"references": ["local.eval_lambda_zip"]}, "function_name": {"constant_value": "crm-agent-eval-sweep-task"}, "gateway_target_role_arn": {"constant_value": null}, "handler": {"constant_value": "eval.sfn_handlers.sweep_task_handler"}, "memory_size_mb": {"constant_value": 1024}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"sweep_task\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.13"}, "source_code_hash": {"references": ["local.eval_lambda_zip"]}, "tags": {"references": ["var.data_classification"]}, "timeout_seconds": {"constant_value": 300}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.13", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_user_settings": {"expressions": {"denied_own_table_actions": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_grants": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["local.name_prefix"]}, "filename": {"references": ["local.eval_lambda_zip"]}, "function_name": {"references": ["local.name_prefix"]}, "gateway_target_role_arn": {"constant_value": null}, "handler": {"constant_value": "crm.handlers.user_settings.handler"}, "memory_size_mb": {"constant_value": 256}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"user_settings\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.13"}, "source_code_hash": {"references": ["local.eval_lambda_zip"]}, "table_action_role_matrix_entries": {"references": ["local.name_prefix"]}, "timeout_seconds": {"constant_value": 10}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.13", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "mcp_chat_gateway": {"expressions": {"account_id": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "aws_region": {"references": ["var.aws_region"]}, "chat_target_lambda_arn": {"references": ["module.lambda_action_chat_target.function_arn", "module.lambda_action_chat_target"]}, "cognito_allowed_client_ids": {"references": ["module.cognito.chat_gateway_allowed_client_ids", "module.cognito"]}, "cognito_allowed_scopes": {"references": ["module.cognito.chat_scope_identifier", "module.cognito"]}, "cognito_discovery_url": {"references": ["var.aws_region", "module.cognito.user_pool_id", "module.cognito"]}, "gateway_name": {"references": ["local.name_prefix"]}, "identity_interceptor_lambda_arn": {"references": ["module.lambda_action_chat_interceptor.function_arn", "module.lambda_action_chat_interceptor"]}, "identity_interceptor_lambda_function_name": {"references": ["module.lambda_action_chat_interceptor.function_name", "module.lambda_action_chat_interceptor"]}, "role_name": {"references": ["local.name_prefix"]}, "tags": {"references": ["var.data_classification"]}}, "module": {"outputs": {"gateway_arn": {"description": "Gateway #2 ARN; the interceptor permission's `source_arn`.", "expression": {"references": ["aws_bedrockagentcore_gateway.this.gateway_arn", "aws_bedrockagentcore_gateway.this"]}}, "gateway_id": {"description": "Gateway #2 id.", "expression": {"references": ["aws_bedrockagentcore_gateway.this.gateway_id", "aws_bedrockagentcore_gateway.this"]}}, "gateway_url": {"description": "MCP endpoint URL of Gateway #2.", "expression": {"references": ["aws_bedrockagentcore_gateway.this.gateway_url", "aws_bedrockagentcore_gateway.this"]}}, "role_arn": {"description": "Gateway #2 execution role ARN; the only Gateway principal admitted by the chat target's resource policy.", "expression": {"references": ["aws_iam_role.gateway.arn", "aws_iam_role.gateway"]}}, "role_name": {"description": "Gateway #2 execution role name.", "expression": {"references": ["aws_iam_role.gateway.name", "aws_iam_role.gateway"]}}}, "resources": [{"address": "aws_bedrockagentcore_gateway.this", "depends_on": ["aws_iam_role_policy.gateway"], "expressions": {"authorizer_configuration": [{"custom_jwt_authorizer": [{"allowed_audience": {"constant_value": null}, "allowed_clients": {"references": ["var.cognito_allowed_client_ids"]}, "allowed_scopes": {"references": ["var.cognito_allowed_scopes"]}, "discovery_url": {"references": ["var.cognito_discovery_url"]}}]}], "authorizer_type": {"constant_value": "CUSTOM_JWT"}, "interceptor_configuration": [{"input_configuration": [{"pass_request_headers": {"constant_value": true}}], "interception_points": {"constant_value": ["REQUEST"]}, "interceptor": [{"lambda": [{"arn": {"references": ["var.identity_interceptor_lambda_arn"]}}]}]}], "name": {"references": ["var.gateway_name"]}, "protocol_configuration": [{"mcp": [{"supported_versions": {"constant_value": ["2025-03-26", "2025-06-18", "2025-11-25"]}}]}], "protocol_type": {"constant_value": "MCP"}, "region": {"references": ["var.aws_region"]}, "role_arn": {"references": ["aws_iam_role.gateway.arn", "aws_iam_role.gateway"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_bedrockagentcore_gateway"}, {"address": "aws_bedrockagentcore_gateway_target.chat", "expressions": {"credential_provider_configuration": [{"gateway_iam_role": [{}]}], "description": {"constant_value": "Gateway target for chat_with_supervisor, backed by the chat_target Lambda."}, "gateway_identifier": {"references": ["aws_bedrockagentcore_gateway.this.gateway_id", "aws_bedrockagentcore_gateway.this"]}, "name": {"constant_value": "chat-with-supervisor"}, "target_configuration": [{"mcp": [{"lambda": [{"lambda_arn": {"references": ["var.chat_target_lambda_arn"]}, "tool_schema": [{"inline_payload": [{"description": {"constant_value": "Send one message to the CRM supervisor agent and receive its answer. Pass the returned conversation_id on later calls to continue the same conversation."}, "input_schema": [{"property": [{"description": {"constant_value": "The message to send, 1 to 8000 characters."}, "name": {"constant_value": "message"}, "required": {"constant_value": true}, "type": {"constant_value": "string"}}, {"description": {"constant_value": "A conversation_id returned by an earlier call; omit to start a new conversation."}, "name": {"constant_value": "conversation_id"}, "required": {"constant_value": false}, "type": {"constant_value": "string"}}], "type": {"constant_value": "object"}}], "name": {"constant_value": "chat_with_supervisor"}}]}]}]}]}]}, "mode": "managed", "name": "chat", "provider_config_key": "aws", "schema_version": 0, "type": "aws_bedrockagentcore_gateway_target"}, {"address": "aws_iam_role.gateway", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.role_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "gateway", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.gateway", "expressions": {"name": {"references": ["var.role_name"]}, "policy": {"references": ["data.aws_iam_policy_document.gateway_permissions.json", "data.aws_iam_policy_document.gateway_permissions"]}, "role": {"references": ["aws_iam_role.gateway.id", "aws_iam_role.gateway"]}}, "mode": "managed", "name": "gateway", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_lambda_permission.gateway_invoke_interceptor", "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["var.identity_interceptor_lambda_function_name"]}, "principal": {"constant_value": "bedrock-agentcore.amazonaws.com"}, "source_account": {"references": ["var.account_id"]}, "source_arn": {"references": ["aws_bedrockagentcore_gateway.this.gateway_arn", "aws_bedrockagentcore_gateway.this"]}, "statement_id": {"constant_value": "AllowChatGatewayInvokeIdentityInterceptor"}}, "mode": "managed", "name": "gateway_invoke_interceptor", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["var.account_id"]}, "variable": {"constant_value": "aws:SourceAccount"}}, {"test": {"constant_value": "ArnLike"}, "values": {"references": ["var.aws_region", "var.account_id"]}, "variable": {"constant_value": "aws:SourceArn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["bedrock-agentcore.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.gateway_permissions", "expressions": {"statement": [{"actions": {"constant_value": ["lambda:InvokeFunction"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.chat_target_lambda_arn"]}, "sid": {"constant_value": "InvokeChatTarget"}}, {"actions": {"constant_value": ["lambda:InvokeFunction"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.identity_interceptor_lambda_arn"]}, "sid": {"constant_value": "InvokeInterceptor"}}]}, "mode": "data", "name": "gateway_permissions", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"account_id": {"description": "Account id for the trust policy's `aws:SourceAccount` and `aws:SourceArn` conditions and the interceptor permission's `source_account`."}, "aws_region": {"description": "Region of the gateway; also the region segment of the trust policy's `aws:SourceArn` pattern."}, "chat_target_lambda_arn": {"description": "ARN of the `chat_with_supervisor` target Lambda; the only target this gateway's role may invoke."}, "cognito_allowed_client_ids": {"description": "Cognito app client ids the `CUSTOM_JWT` authorizer accepts, as on Gateway #1."}, "cognito_allowed_scopes": {"description": "Scopes the `CUSTOM_JWT` authorizer accepts: this gateway's own chat scope, never Gateway #1's."}, "cognito_discovery_url": {"description": "OIDC discovery URL of the Cognito user pool, as on Gateway #1."}, "gateway_name": {"description": "Name of the AgentCore Gateway."}, "identity_interceptor_lambda_arn": {"description": "ARN of the shared REQUEST interceptor Lambda."}, "identity_interceptor_lambda_function_name": {"description": "Function name of the shared REQUEST interceptor Lambda, for this gateway's invoke permission."}, "role_name": {"description": "Name of this gateway's own execution role."}, "tags": {"default": {}, "description": "Tags for the gateway and its role. The provider's default_tags carries the mandatory set."}}}, "source": "./modules/mcp_chat_gateway"}, "observability": {"expressions": {"administrator_principal_arns": {"references": ["var.crm_operator_principal_arns", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "caller_principal_arn": {"references": ["data.aws_iam_session_context.current.issuer_arn", "data.aws_iam_session_context.current"]}, "data_classification": {"references": ["var.data_classification"]}, "log_retention_days": {"constant_value": 365}, "logs_key_user_principal_arns": {"references": ["local.logs_key_user_role_arns", "var.crm_operator_principal_arns"]}, "name_prefix": {"references": ["local.name_prefix"]}, "operator_principal_arns": {"references": ["var.crm_operator_principal_arns"]}}, "module": {"outputs": {"cloudtrail_access_logs_bucket_name": {"description": "Name of the S3 bucket receiving the CloudTrail delivery bucket's own S3 server access logs (`aws_s3_bucket_logging.cloudtrail`'s target). Distinct from `cloudtrail_s3_bucket_name`, which is the source of those logs.", "expression": {"references": ["aws_s3_bucket.cloudtrail_access_logs.id", "aws_s3_bucket.cloudtrail_access_logs"]}}, "cloudtrail_arn": {"description": "ARN of the CloudTrail trail for API activity.", "expression": {"references": ["aws_cloudtrail.this.arn", "aws_cloudtrail.this"]}}, "cloudtrail_kms_key_arn": {"description": "ARN of the customer-managed KMS key encrypting the CloudTrail S3 destination bucket.", "expression": {"references": ["aws_kms_key.cloudtrail.arn", "aws_kms_key.cloudtrail"]}}, "cloudtrail_s3_bucket_name": {"description": "Name of the S3 bucket CloudTrail delivers log files to: the log source whose access logs land in `cloudtrail_access_logs_bucket_name`.", "expression": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}}, "cloudwatch_logs_kms_key_arn": {"description": "ARN of the customer-managed KMS key for CloudWatch Logs log-group encryption. Sibling modules' `aws_cloudwatch_log_group` resources pass this as `kms_key_id`.", "expression": {"references": ["aws_kms_key.logs.arn", "aws_kms_key.logs"]}}, "cloudwatch_logs_kms_key_id": {"description": "Key ID of the customer-managed KMS key for CloudWatch Logs log-group encryption.", "expression": {"references": ["aws_kms_key.logs.key_id", "aws_kms_key.logs"]}}, "eval_metric_namespace": {"description": "CloudWatch custom metric namespace reserved for eval-run metrics; passthrough of `var.eval_metric_namespace`.", "expression": {"references": ["var.eval_metric_namespace"]}}}, "resources": [{"address": "aws_cloudtrail.this", "depends_on": ["aws_s3_bucket_policy.cloudtrail"], "expressions": {"cloud_watch_logs_group_arn": {"references": ["var.enable_cloudtrail_cloudwatch_logs", "aws_cloudwatch_log_group.cloudtrail[0].arn", "aws_cloudwatch_log_group.cloudtrail[0]", "aws_cloudwatch_log_group.cloudtrail"]}, "cloud_watch_logs_role_arn": {"references": ["var.enable_cloudtrail_cloudwatch_logs", "aws_iam_role.cloudtrail_cloudwatch_logs[0].arn", "aws_iam_role.cloudtrail_cloudwatch_logs[0]", "aws_iam_role.cloudtrail_cloudwatch_logs"]}, "enable_log_file_validation": {"constant_value": true}, "event_selector": [{"include_management_events": {"constant_value": true}, "read_write_type": {"constant_value": "All"}}], "include_global_service_events": {"constant_value": true}, "is_multi_region_trail": {"constant_value": true}, "kms_key_id": {"references": ["aws_kms_key.cloudtrail.arn", "aws_kms_key.cloudtrail"]}, "name": {"references": ["local.cloudtrail_name"]}, "s3_bucket_name": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}, "tags": {"references": ["var.tags", "var.data_classification"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 1, "type": "aws_cloudtrail"}, {"address": "aws_cloudwatch_log_group.cloudtrail", "count_expression": {"references": ["var.enable_cloudtrail_cloudwatch_logs"]}, "expressions": {"kms_key_id": {"references": ["aws_kms_key.logs.arn", "aws_kms_key.logs"]}, "name": {"references": ["var.name_prefix"]}, "retention_in_days": {"references": ["var.log_retention_days"]}, "tags": {"references": ["var.tags", "var.data_classification"]}}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_role.cloudtrail_cloudwatch_logs", "count_expression": {"references": ["var.enable_cloudtrail_cloudwatch_logs"]}, "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.cloudtrail_cloudwatch_logs_assume[0].json", "data.aws_iam_policy_document.cloudtrail_cloudwatch_logs_assume[0]", "data.aws_iam_policy_document.cloudtrail_cloudwatch_logs_assume"]}, "name": {"references": ["var.name_prefix"]}, "tags": {"references": ["var.tags", "var.data_classification"]}}, "mode": "managed", "name": "cloudtrail_cloudwatch_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.cloudtrail_cloudwatch_logs", "count_expression": {"references": ["var.enable_cloudtrail_cloudwatch_logs"]}, "expressions": {"name": {"references": ["var.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.cloudtrail_cloudwatch_logs_delivery[0].json", "data.aws_iam_policy_document.cloudtrail_cloudwatch_logs_delivery[0]", "data.aws_iam_policy_document.cloudtrail_cloudwatch_logs_delivery"]}, "role": {"references": ["aws_iam_role.cloudtrail_cloudwatch_logs[0].id", "aws_iam_role.cloudtrail_cloudwatch_logs[0]", "aws_iam_role.cloudtrail_cloudwatch_logs"]}}, "mode": "managed", "name": "cloudtrail_cloudwatch_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_kms_alias.cloudtrail", "expressions": {"name": {"references": ["var.name_prefix"]}, "target_key_id": {"references": ["aws_kms_key.cloudtrail.key_id", "aws_kms_key.cloudtrail"]}}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_alias"}, {"address": "aws_kms_alias.logs", "expressions": {"name": {"references": ["var.name_prefix"]}, "target_key_id": {"references": ["aws_kms_key.logs.key_id", "aws_kms_key.logs"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_alias"}, {"address": "aws_kms_key.cloudtrail", "expressions": {"bypass_policy_lockout_safety_check": {"constant_value": false}, "deletion_window_in_days": {"constant_value": 30}, "description": {"constant_value": "CMK for CloudTrail S3 log destination encryption at rest"}, "enable_key_rotation": {"constant_value": true}, "policy": {"references": ["data.aws_iam_policy_document.cloudtrail_cmk.json", "data.aws_iam_policy_document.cloudtrail_cmk"]}, "tags": {"references": ["var.tags", "var.data_classification"]}}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key"}, {"address": "aws_kms_key.logs", "expressions": {"bypass_policy_lockout_safety_check": {"constant_value": false}, "deletion_window_in_days": {"constant_value": 30}, "description": {"constant_value": "CMK for CloudWatch Logs log group encryption at rest"}, "enable_key_rotation": {"constant_value": true}, "policy": {"references": ["data.aws_iam_policy_document.cloudwatch_logs_cmk.json", "data.aws_iam_policy_document.cloudwatch_logs_cmk"]}, "tags": {"references": ["var.tags", "var.data_classification"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key"}, {"address": "aws_s3_bucket.cloudtrail", "expressions": {"bucket": {"references": ["var.name_prefix", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "force_destroy": {"constant_value": true}, "tags": {"references": ["var.tags", "var.data_classification"]}}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket"}, {"address": "aws_s3_bucket.cloudtrail_access_logs", "expressions": {"bucket": {"references": ["var.name_prefix", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "force_destroy": {"constant_value": true}, "tags": {"references": ["var.tags", "var.data_classification"]}}, "mode": "managed", "name": "cloudtrail_access_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket"}, {"address": "aws_s3_bucket_lifecycle_configuration.cloudtrail", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}, "rule": [{"abort_incomplete_multipart_upload": [{"days_after_initiation": {"constant_value": 7}}], "expiration": [{"days": {"references": ["var.cloudtrail_s3_log_retention_days"]}}], "filter": [{}], "id": {"constant_value": "expire-trail-logs"}, "noncurrent_version_expiration": [{"noncurrent_days": {"references": ["var.cloudtrail_s3_log_retention_days"]}}], "status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 1, "type": "aws_s3_bucket_lifecycle_configuration"}, {"address": "aws_s3_bucket_lifecycle_configuration.cloudtrail_access_logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail_access_logs.id", "aws_s3_bucket.cloudtrail_access_logs"]}, "rule": [{"abort_incomplete_multipart_upload": [{"days_after_initiation": {"constant_value": 7}}], "expiration": [{"days": {"references": ["var.cloudtrail_s3_log_retention_days"]}}], "filter": [{}], "id": {"constant_value": "expire-access-logs"}, "noncurrent_version_expiration": [{"noncurrent_days": {"references": ["var.cloudtrail_s3_log_retention_days"]}}], "status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "cloudtrail_access_logs", "provider_config_key": "aws", "schema_version": 1, "type": "aws_s3_bucket_lifecycle_configuration"}, {"address": "aws_s3_bucket_logging.cloudtrail", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}, "target_bucket": {"references": ["aws_s3_bucket.cloudtrail_access_logs.id", "aws_s3_bucket.cloudtrail_access_logs"]}, "target_prefix": {"constant_value": "s3-access-logs/cloudtrail/"}}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_logging"}, {"address": "aws_s3_bucket_ownership_controls.cloudtrail", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}, "rule": [{"object_ownership": {"constant_value": "BucketOwnerEnforced"}}]}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_ownership_controls"}, {"address": "aws_s3_bucket_ownership_controls.cloudtrail_access_logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail_access_logs.id", "aws_s3_bucket.cloudtrail_access_logs"]}, "rule": [{"object_ownership": {"constant_value": "BucketOwnerEnforced"}}]}, "mode": "managed", "name": "cloudtrail_access_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_ownership_controls"}, {"address": "aws_s3_bucket_policy.cloudtrail", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}, "policy": {"references": ["data.aws_iam_policy_document.cloudtrail_bucket.json", "data.aws_iam_policy_document.cloudtrail_bucket"]}}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_policy"}, {"address": "aws_s3_bucket_policy.cloudtrail_access_logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail_access_logs.id", "aws_s3_bucket.cloudtrail_access_logs"]}, "policy": {"references": ["data.aws_iam_policy_document.cloudtrail_access_logs_tls_deny.json", "data.aws_iam_policy_document.cloudtrail_access_logs_tls_deny"]}}, "mode": "managed", "name": "cloudtrail_access_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_policy"}, {"address": "aws_s3_bucket_public_access_block.cloudtrail", "expressions": {"block_public_acls": {"constant_value": true}, "block_public_policy": {"constant_value": true}, "bucket": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}, "ignore_public_acls": {"constant_value": true}, "restrict_public_buckets": {"constant_value": true}}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_public_access_block"}, {"address": "aws_s3_bucket_public_access_block.cloudtrail_access_logs", "expressions": {"block_public_acls": {"constant_value": true}, "block_public_policy": {"constant_value": true}, "bucket": {"references": ["aws_s3_bucket.cloudtrail_access_logs.id", "aws_s3_bucket.cloudtrail_access_logs"]}, "ignore_public_acls": {"constant_value": true}, "restrict_public_buckets": {"constant_value": true}}, "mode": "managed", "name": "cloudtrail_access_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_public_access_block"}, {"address": "aws_s3_bucket_server_side_encryption_configuration.cloudtrail", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}, "rule": [{"apply_server_side_encryption_by_default": [{"kms_master_key_id": {"references": ["aws_kms_key.cloudtrail.arn", "aws_kms_key.cloudtrail"]}, "sse_algorithm": {"constant_value": "aws:kms"}}], "bucket_key_enabled": {"constant_value": true}}]}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_server_side_encryption_configuration"}, {"address": "aws_s3_bucket_server_side_encryption_configuration.cloudtrail_access_logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail_access_logs.id", "aws_s3_bucket.cloudtrail_access_logs"]}, "rule": [{"apply_server_side_encryption_by_default": [{"sse_algorithm": {"constant_value": "AES256"}}], "bucket_key_enabled": {"constant_value": true}}]}, "mode": "managed", "name": "cloudtrail_access_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_server_side_encryption_configuration"}, {"address": "aws_s3_bucket_versioning.cloudtrail", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}, "versioning_configuration": [{"status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_versioning"}, {"address": "aws_s3_bucket_versioning.cloudtrail_access_logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail_access_logs.id", "aws_s3_bucket.cloudtrail_access_logs"]}, "versioning_configuration": [{"status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "cloudtrail_access_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_versioning"}, {"address": "data.aws_caller_identity.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_caller_identity"}, {"address": "data.aws_iam_policy_document.cloudtrail_access_logs_tls_deny", "expressions": {"statement": [{"actions": {"constant_value": ["s3:PutObject"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "aws:SourceAccount"}}, {"test": {"constant_value": "ArnLike"}, "values": {"references": ["aws_s3_bucket.cloudtrail.arn", "aws_s3_bucket.cloudtrail"]}, "variable": {"constant_value": "aws:SourceArn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["logging.s3.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"references": ["aws_s3_bucket.cloudtrail_access_logs.arn", "aws_s3_bucket.cloudtrail_access_logs"]}, "sid": {"constant_value": "AllowS3ServerAccessLogDelivery"}}, {"actions": {"constant_value": ["s3:*"]}, "condition": [{"test": {"constant_value": "Bool"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:SecureTransport"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["aws_s3_bucket.cloudtrail_access_logs.arn", "aws_s3_bucket.cloudtrail_access_logs", "aws_s3_bucket.cloudtrail_access_logs.arn", "aws_s3_bucket.cloudtrail_access_logs"]}, "sid": {"constant_value": "DenyInsecureTransport"}}]}, "mode": "data", "name": "cloudtrail_access_logs_tls_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.cloudtrail_bucket", "expressions": {"statement": [{"actions": {"constant_value": ["s3:*"]}, "condition": [{"test": {"constant_value": "Bool"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:SecureTransport"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["aws_s3_bucket.cloudtrail.arn", "aws_s3_bucket.cloudtrail", "aws_s3_bucket.cloudtrail.arn", "aws_s3_bucket.cloudtrail"]}, "sid": {"constant_value": "DenyInsecureTransport"}}, {"actions": {"constant_value": ["s3:GetBucketAcl"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["local.cloudtrail_arn"]}, "variable": {"constant_value": "aws:SourceArn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["cloudtrail.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"references": ["aws_s3_bucket.cloudtrail.arn", "aws_s3_bucket.cloudtrail"]}, "sid": {"constant_value": "AWSCloudTrailAclCheck"}}, {"actions": {"constant_value": ["s3:PutObject"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["local.cloudtrail_arn"]}, "variable": {"constant_value": "aws:SourceArn"}}, {"test": {"constant_value": "StringEquals"}, "values": {"constant_value": ["bucket-owner-full-control"]}, "variable": {"constant_value": "s3:x-amz-acl"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["cloudtrail.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"references": ["aws_s3_bucket.cloudtrail.arn", "aws_s3_bucket.cloudtrail", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "sid": {"constant_value": "AWSCloudTrailWrite"}}, {"actions": {"constant_value": ["s3:GetObject", "s3:GetObjectVersion", "s3:GetObjectAttributes", "s3:GetObjectVersionAttributes", "s3:GetObjectTagging", "s3:GetObjectVersionTagging", "s3:RestoreObject", "s3:ListBucket", "s3:ListBucketVersions", "s3:ListBucketMultipartUploads", "s3:ListMultipartUploadParts", "s3:PutObject", "s3:PutObjectTagging", "s3:DeleteObject", "s3:DeleteObjectVersion", "s3:DeleteObjectTagging", "s3:AbortMultipartUpload", "s3:PutObjectVersionTagging", "s3:DeleteObjectVersionTagging"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.operator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}, {"test": {"constant_value": "BoolIfExists"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:PrincipalIsAWSService"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"references": ["aws_s3_bucket.cloudtrail.arn", "aws_s3_bucket.cloudtrail", "aws_s3_bucket.cloudtrail.arn", "aws_s3_bucket.cloudtrail"]}, "sid": {"constant_value": "DenyObjectDataPlaneToNonProjectPrincipals"}}, {"actions": {"constant_value": ["s3:DeleteBucket", "s3:PutBucketPolicy", "s3:DeleteBucketPolicy", "s3:PutBucketVersioning", "s3:PutEncryptionConfiguration", "s3:PutLifecycleConfiguration", "s3:PutBucketLogging", "s3:PutBucketPublicAccessBlock", "s3:PutBucketOwnershipControls", "s3:PutBucketAcl", "s3:PutBucketTagging", "s3:PutReplicationConfiguration", "s3:PutInventoryConfiguration", "s3:PutBucketNotification", "s3:PutBucketObjectLockConfiguration", "s3:PutBucketRequestPayment", "s3:PutBucketWebsite", "s3:PutBucketCORS", "s3:PutAccelerateConfiguration", "s3:PutIntelligentTieringConfiguration", "s3:PutAnalyticsConfiguration", "s3:PutMetricsConfiguration"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.administrator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"references": ["aws_s3_bucket.cloudtrail.arn", "aws_s3_bucket.cloudtrail"]}, "sid": {"constant_value": "DenyBucketAdministrationToNonOperators"}}]}, "mode": "data", "name": "cloudtrail_bucket", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.cloudtrail_cloudwatch_logs_assume", "count_expression": {"references": ["var.enable_cloudtrail_cloudwatch_logs"]}, "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["cloudtrail.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "cloudtrail_cloudwatch_logs_assume", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.cloudtrail_cloudwatch_logs_delivery", "count_expression": {"references": ["var.enable_cloudtrail_cloudwatch_logs"]}, "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.cloudtrail[0].arn", "aws_cloudwatch_log_group.cloudtrail[0]", "aws_cloudwatch_log_group.cloudtrail"]}}]}, "mode": "data", "name": "cloudtrail_cloudwatch_logs_delivery", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.cloudtrail_cmk", "expressions": {"statement": [{"actions": {"constant_value": ["kms:*"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "type": {"constant_value": "AWS"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "EnableIAMUserPermissions"}}, {"actions": {"constant_value": ["kms:GenerateDataKey*"]}, "condition": [{"test": {"constant_value": "StringLike"}, "values": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "kms:EncryptionContext:aws:cloudtrail:arn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["cloudtrail.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "AllowCloudTrailToEncryptLogs"}}, {"actions": {"constant_value": ["kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["cloudtrail.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "AllowCloudTrailToDescribeKey"}}, {"actions": {"constant_value": ["kms:Decrypt", "kms:ReEncryptFrom"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "kms:CallerAccount"}}, {"test": {"constant_value": "StringLike"}, "values": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "kms:EncryptionContext:aws:cloudtrail:arn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "AllowPrincipalsInAccountToDecryptLogFiles"}}, {"actions": {"constant_value": ["kms:Decrypt", "kms:Encrypt", "kms:GenerateDataKey*", "kms:ReEncrypt*", "kms:CreateGrant"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.operator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}, {"test": {"constant_value": "Bool"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:PrincipalIsAWSService"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "DenyKeyUseToNonProjectPrincipals"}}, {"actions": {"constant_value": ["kms:PutKeyPolicy", "kms:ScheduleKeyDeletion", "kms:DisableKey", "kms:RevokeGrant", "kms:DisableKeyRotation", "kms:CreateAlias", "kms:UpdateAlias", "kms:DeleteAlias", "kms:TagResource", "kms:UntagResource", "kms:UpdateKeyDescription"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.administrator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "DenyKeyAdministrationToNonOperators"}}]}, "mode": "data", "name": "cloudtrail_cmk", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.cloudwatch_logs_cmk", "expressions": {"statement": [{"actions": {"constant_value": ["kms:*"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "type": {"constant_value": "AWS"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "EnableIAMUserPermissions"}}, {"actions": {"constant_value": ["kms:Encrypt", "kms:Decrypt", "kms:ReEncrypt*", "kms:GenerateDataKey*", "kms:Describe*"]}, "condition": [{"test": {"constant_value": "ArnLike"}, "values": {"references": ["data.aws_region.current.region", "data.aws_region.current", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "kms:EncryptionContext:aws:logs:arn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"references": ["data.aws_region.current.region", "data.aws_region.current"]}, "type": {"constant_value": "Service"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "AllowCloudWatchLogsUseOfTheKey"}}, {"actions": {"constant_value": ["kms:Decrypt", "kms:Encrypt", "kms:GenerateDataKey*", "kms:ReEncrypt*", "kms:CreateGrant"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.logs_key_user_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}, {"test": {"constant_value": "Bool"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:PrincipalIsAWSService"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "DenyKeyUseToNonProjectPrincipals"}}, {"actions": {"constant_value": ["kms:PutKeyPolicy", "kms:ScheduleKeyDeletion", "kms:DisableKey", "kms:RevokeGrant", "kms:DisableKeyRotation", "kms:CreateAlias", "kms:UpdateAlias", "kms:DeleteAlias", "kms:TagResource", "kms:UntagResource", "kms:UpdateKeyDescription"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.administrator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "DenyKeyAdministrationToNonOperators"}}]}, "mode": "data", "name": "cloudwatch_logs_cmk", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_region.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_region"}], "variables": {"administrator_principal_arns": {"description": "IAM role or user ARNs, or the account root, admitted to administration of both CMKs and of the CloudTrail bucket. Every other principal is denied it."}, "caller_principal_arn": {"description": "Role or user ARN of the principal running this plan. The key and bucket policies refuse to plan unless it is a listed administrator other than the account root, so no apply can lock its own caller out."}, "cloudtrail_s3_log_retention_days": {"default": 365, "description": "Lifecycle expiration, in days, for CloudTrail delivered log objects in the trail S3 destination bucket."}, "data_classification": {"default": "confidential", "description": "Value for the `data-classification` tag on resources in this module."}, "enable_cloudtrail_cloudwatch_logs": {"default": false, "description": "Whether the trail also delivers to a CloudWatch Logs log group (via\n`cloud_watch_logs_group_arn`/`cloud_watch_logs_role_arn`), in addition to its S3 destination.\nDefaults to false. The CMK this module creates already grants `logs..amazonaws.com` the\nactions CloudWatch Logs needs.\n"}, "eval_metric_namespace": {"default": "CrmAgentEval/Eval", "description": "CloudWatch custom metric namespace reserved for eval-run metrics. No code\nunder `src/` publishes a CloudWatch metric; eval metrics are written to the\n`matrix.json`/`.md`/`.csv` report files instead.\n"}, "log_retention_days": {"default": 365, "description": "CloudWatch Logs retention, in days, for the CloudTrail CloudWatch Logs integration log group this module creates."}, "logs_key_user_principal_arns": {"description": "IAM role or user ARNs admitted to key use on the CloudWatch Logs CMK: every execution role whose Lambda environment the key encrypts, plus the operators. Every other non-service principal is denied key use."}, "name_prefix": {"default": "", "description": "Prefix applied to resource names, e.g. project or environment scoping."}, "operator_principal_arns": {"description": "IAM role or user ARNs of the operators: the only non-service principals admitted to CloudTrail-key use and to the CloudTrail bucket's data plane."}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-resource override or addition."}}}, "source": "./modules/observability"}, "vpc": {"expressions": {"flow_log_enabled": {"references": ["var.vpc_flow_log_enabled"]}, "flow_log_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "gateway_endpoint_service_names": {"constant_value": ["s3", "dynamodb"]}, "interface_endpoint_service_names": {"references": ["local.vpc_interface_endpoint_services"]}, "name_prefix": {"references": ["local.name_prefix"]}, "nat_gateway_enabled": {"references": ["var.vpc_nat_gateway_enabled"]}, "nat_public_subnet_id": {"references": ["var.vpc_nat_public_subnet_id"]}, "private_route_table_ids": {"references": ["var.vpc_private_route_table_ids"]}, "private_subnet_ids": {"references": ["var.vpc_private_subnet_ids"]}, "region": {"references": ["var.aws_region"]}, "runtime_route_table_ids": {"references": ["var.vpc_runtime_route_table_ids"]}, "runtime_subnet_ids": {"references": ["var.vpc_runtime_subnet_ids"]}, "tags": {"references": ["var.data_classification"]}, "vpc_cidr_block": {"references": ["var.vpc_cidr_block"]}, "vpc_id": {"references": ["var.vpc_id"]}}, "module": {"outputs": {"bedrock_agentcore_vpc_endpoint_id": {"description": "The `bedrock-agentcore` interface endpoint's id, for the runtime resource policies' `aws:SourceVpce`\ncondition: the Deny keyed on it denies every caller not arriving through this endpoint. Read from the\nendpoint map by key. Fails at plan time if `bedrock-agentcore` is absent from the interface list.\n", "expression": {"references": ["aws_vpc_endpoint.interface[\"bedrock-agentcore\"].id", "aws_vpc_endpoint.interface[\"bedrock-agentcore\"]", "aws_vpc_endpoint.interface"]}}, "endpoint_security_group_id": {"description": "The interface-endpoint security group's id.", "expression": {"references": ["aws_security_group.endpoints.id", "aws_security_group.endpoints"]}}, "execute_api_network_interface_ids": {"description": "The `execute-api` endpoint's ENI ids, for the private-origin ALB's target group.\n\n`modules/api_origin` indexes this list positionally under `count = length(var.private_subnet_ids)`,\nso it holds exactly one entry per private subnet; the precondition below asserts the length.\n", "expression": {"references": ["aws_vpc_endpoint.interface[\"execute-api\"].network_interface_ids", "aws_vpc_endpoint.interface[\"execute-api\"]", "aws_vpc_endpoint.interface"]}}, "execute_api_security_group_id": {"description": "The security group on the `execute-api` endpoint's ENIs, and the ALB's single egress destination.\nEvery interface endpoint in this module shares it; its ingress is 443 from the Lambda group, plus\nthe ALB's 443 ingress rule, which the root composition attaches.\n", "expression": {"references": ["aws_security_group.endpoints.id", "aws_security_group.endpoints"]}}, "execute_api_vpc_endpoint_id": {"description": "The `execute-api` interface endpoint's id, for the private REST API's\n`endpoint_configuration.vpc_endpoint_ids` and its resource-policy allowlist. Read from the endpoint\nmap by key. Fails at plan time if `execute-api` is absent from the endpoint list.\n", "expression": {"references": ["aws_vpc_endpoint.interface[\"execute-api\"].id", "aws_vpc_endpoint.interface[\"execute-api\"]", "aws_vpc_endpoint.interface"]}}, "flow_log_group_name": {"description": "The VPC flow-log group name, or null when flow logs are disabled. Read by the access-log delivery smoke check as its source-side target.", "expression": {"references": ["var.flow_log_enabled", "aws_cloudwatch_log_group.flow_logs[0].name", "aws_cloudwatch_log_group.flow_logs[0]", "aws_cloudwatch_log_group.flow_logs"]}}, "gateway_endpoint_service_names": {"description": "Fully-qualified service names of the gateway endpoints created.", "expression": {"references": ["aws_vpc_endpoint.gateway"]}}, "interface_endpoint_service_names": {"description": "Fully-qualified service names of the interface endpoints created, for a Layer 4 check asserting the deployed set.", "expression": {"references": ["aws_vpc_endpoint.interface"]}}, "lambda_security_group_ids": {"description": "The single Lambda security group, for the `security_group_ids` half of every Lambda `vpc_config`. No ingress.", "expression": {"references": ["aws_security_group.lambda.id", "aws_security_group.lambda"]}}, "lambda_subnet_ids": {"description": "Private subnet ids, for the `subnet_ids` half of every Lambda `vpc_config`. Returns `var.private_subnet_ids` alone, sorted; a precondition in `nat.tf` asserts `var.nat_public_subnet_id` is absent from it.", "expression": {"references": ["var.private_subnet_ids"]}}, "nat_gateway_public_ip": {"description": "The NAT gateway Elastic IP, or null when NAT is disabled. A Layer 4 check asserts the relay egress leaves by this address.", "expression": {"references": ["var.nat_gateway_enabled", "aws_eip.nat[0].public_ip", "aws_eip.nat[0]", "aws_eip.nat"]}}, "runtime_security_group_id": {"description": "The dedicated AgentCore Runtime security group's id, for the Runtime's VPC-mode\n`network_mode_config.security_groups`. No ingress; egress only to the endpoint group and the gateway\nprefix lists. Distinct from `lambda_security_group_ids`.\n", "expression": {"references": ["aws_security_group.agent_runtime.id", "aws_security_group.agent_runtime"]}}, "runtime_subnet_ids": {"description": "The Runtime VPC-mode subnet ids, for the Runtime `network_mode_config.subnets`. Returns `var.runtime_subnet_ids` sorted. Empty when the Runtime is not in VPC mode.", "expression": {"references": ["var.runtime_subnet_ids"]}}, "states_vpc_endpoint_id": {"description": "The `states` interface endpoint's id, for the root's endpoint policy scoping it to the eval sweep.\nRead from the endpoint map by key. Fails at plan time if `states` is absent from the\ninterface list.\n", "expression": {"references": ["aws_vpc_endpoint.interface[\"states\"].id", "aws_vpc_endpoint.interface[\"states\"]", "aws_vpc_endpoint.interface"]}}, "vpc_cidr_block": {"description": "The VPC's IPv4 CIDR.", "expression": {"references": ["var.vpc_cidr_block"]}}, "vpc_id": {"description": "The VPC's id.", "expression": {"references": ["var.vpc_id"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.flow_logs", "count_expression": {"references": ["var.flow_log_enabled"]}, "expressions": {"kms_key_id": {"references": ["var.flow_log_kms_key_arn"]}, "name": {"references": ["var.name_prefix"]}, "retention_in_days": {"references": ["var.flow_log_retention_days"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "flow_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_eip.nat", "count_expression": {"references": ["var.nat_gateway_enabled"]}, "expressions": {"domain": {"constant_value": "vpc"}, "tags": {"references": ["var.tags", "var.name_prefix"]}}, "mode": "managed", "name": "nat", "provider_config_key": "aws", "schema_version": 0, "type": "aws_eip"}, {"address": "aws_flow_log.this", "count_expression": {"references": ["var.flow_log_enabled"]}, "depends_on": ["aws_iam_role_policy.flow_logs"], "expressions": {"iam_role_arn": {"references": ["aws_iam_role.flow_logs[0].arn", "aws_iam_role.flow_logs[0]", "aws_iam_role.flow_logs"]}, "log_destination": {"references": ["aws_cloudwatch_log_group.flow_logs[0].arn", "aws_cloudwatch_log_group.flow_logs[0]", "aws_cloudwatch_log_group.flow_logs"]}, "log_destination_type": {"constant_value": "cloud-watch-logs"}, "max_aggregation_interval": {"constant_value": 60}, "tags": {"references": ["var.tags", "var.name_prefix"]}, "traffic_type": {"constant_value": "ALL"}, "vpc_id": {"references": ["var.vpc_id"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 1, "type": "aws_flow_log"}, {"address": "aws_iam_role.flow_logs", "count_expression": {"references": ["var.flow_log_enabled"]}, "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.flow_logs_assume_role[0].json", "data.aws_iam_policy_document.flow_logs_assume_role[0]", "data.aws_iam_policy_document.flow_logs_assume_role"]}, "name": {"references": ["var.name_prefix"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "flow_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.flow_logs", "count_expression": {"references": ["var.flow_log_enabled"]}, "expressions": {"name": {"references": ["var.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.flow_logs_delivery[0].json", "data.aws_iam_policy_document.flow_logs_delivery[0]", "data.aws_iam_policy_document.flow_logs_delivery"]}, "role": {"references": ["aws_iam_role.flow_logs[0].id", "aws_iam_role.flow_logs[0]", "aws_iam_role.flow_logs"]}}, "mode": "managed", "name": "flow_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_nat_gateway.this", "count_expression": {"references": ["var.nat_gateway_enabled"]}, "expressions": {"allocation_id": {"references": ["aws_eip.nat[0].id", "aws_eip.nat[0]", "aws_eip.nat"]}, "subnet_id": {"references": ["var.nat_public_subnet_id"]}, "tags": {"references": ["var.tags", "var.name_prefix"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_nat_gateway"}, {"address": "aws_route.private_nat", "expressions": {"destination_cidr_block": {"constant_value": "0.0.0.0/0"}, "nat_gateway_id": {"references": ["aws_nat_gateway.this[0].id", "aws_nat_gateway.this[0]", "aws_nat_gateway.this"]}, "route_table_id": {"references": ["each.value"]}}, "for_each_expression": {"references": ["var.nat_gateway_enabled", "var.private_route_table_ids"]}, "mode": "managed", "name": "private_nat", "provider_config_key": "aws", "schema_version": 0, "type": "aws_route"}, {"address": "aws_security_group.agent_runtime", "expressions": {"description": {"constant_value": "AgentCore Runtime ENIs: no ingress, egress only to the VPC endpoint group and gateway prefix lists on 443."}, "name": {"references": ["var.name_prefix"]}, "tags": {"references": ["var.tags", "var.name_prefix"]}, "vpc_id": {"references": ["var.vpc_id"]}}, "mode": "managed", "name": "agent_runtime", "provider_config_key": "aws", "schema_version": 1, "type": "aws_security_group"}, {"address": "aws_security_group.endpoints", "expressions": {"description": {"constant_value": "Interface VPC endpoint ENIs: ingress 443 from the Lambda group only, no egress."}, "name": {"references": ["var.name_prefix"]}, "tags": {"references": ["var.tags", "var.name_prefix"]}, "vpc_id": {"references": ["var.vpc_id"]}}, "mode": "managed", "name": "endpoints", "provider_config_key": "aws", "schema_version": 1, "type": "aws_security_group"}, {"address": "aws_security_group.lambda", "expressions": {"description": {"constant_value": "Lambda ENIs: no ingress, egress only to the VPC endpoint group on 443."}, "name": {"references": ["var.name_prefix"]}, "tags": {"references": ["var.tags", "var.name_prefix"]}, "vpc_id": {"references": ["var.vpc_id"]}}, "mode": "managed", "name": "lambda", "provider_config_key": "aws", "schema_version": 1, "type": "aws_security_group"}, {"address": "aws_vpc_endpoint.gateway", "expressions": {"route_table_ids": {"references": ["var.private_route_table_ids", "var.runtime_route_table_ids"]}, "service_name": {"references": ["var.region", "each.key"]}, "tags": {"references": ["var.tags", "var.name_prefix", "each.key"]}, "vpc_endpoint_type": {"constant_value": "Gateway"}, "vpc_id": {"references": ["var.vpc_id"]}}, "for_each_expression": {"references": ["var.gateway_endpoint_service_names"]}, "mode": "managed", "name": "gateway", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_endpoint"}, {"address": "aws_vpc_endpoint.interface", "expressions": {"private_dns_enabled": {"references": ["var.private_dns_disabled_services", "each.key"]}, "security_group_ids": {"references": ["aws_security_group.endpoints.id", "aws_security_group.endpoints"]}, "service_name": {"references": ["var.region", "each.key"]}, "subnet_ids": {"references": ["var.private_subnet_ids"]}, "tags": {"references": ["var.tags", "var.name_prefix", "each.key"]}, "vpc_endpoint_type": {"constant_value": "Interface"}, "vpc_id": {"references": ["var.vpc_id"]}}, "for_each_expression": {"references": ["var.interface_endpoint_service_names"]}, "mode": "managed", "name": "interface", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_endpoint"}, {"address": "aws_vpc_security_group_egress_rule.agent_runtime_to_endpoints", "expressions": {"description": {"constant_value": "HTTPS to the interface VPC endpoints. Reaches bedrock-runtime, ecr.api, ecr.dkr, lambda and logs cross-AZ via private DNS."}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "referenced_security_group_id": {"references": ["aws_security_group.endpoints.id", "aws_security_group.endpoints"]}, "security_group_id": {"references": ["aws_security_group.agent_runtime.id", "aws_security_group.agent_runtime"]}, "to_port": {"constant_value": 443}}, "mode": "managed", "name": "agent_runtime_to_endpoints", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_egress_rule"}, {"address": "aws_vpc_security_group_egress_rule.agent_runtime_to_gateway_endpoints", "expressions": {"description": {"references": ["each.key"]}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "prefix_list_id": {"references": ["aws_vpc_endpoint.gateway", "each.key"]}, "security_group_id": {"references": ["aws_security_group.agent_runtime.id", "aws_security_group.agent_runtime"]}, "to_port": {"constant_value": 443}}, "for_each_expression": {"references": ["var.gateway_endpoint_service_names"]}, "mode": "managed", "name": "agent_runtime_to_gateway_endpoints", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_egress_rule"}, {"address": "aws_vpc_security_group_egress_rule.lambda_https_via_nat", "count_expression": {"references": ["var.nat_gateway_enabled"]}, "expressions": {"cidr_ipv4": {"constant_value": "0.0.0.0/0"}, "description": {"constant_value": "HTTPS egress via the NAT gateway for the relay Cognito JWKS fetch."}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "security_group_id": {"references": ["aws_security_group.lambda.id", "aws_security_group.lambda"]}, "to_port": {"constant_value": 443}}, "mode": "managed", "name": "lambda_https_via_nat", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_egress_rule"}, {"address": "aws_vpc_security_group_egress_rule.lambda_to_endpoints", "expressions": {"description": {"constant_value": "HTTPS to the interface VPC endpoints. The only in-VPC egress any Lambda has."}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "referenced_security_group_id": {"references": ["aws_security_group.endpoints.id", "aws_security_group.endpoints"]}, "security_group_id": {"references": ["aws_security_group.lambda.id", "aws_security_group.lambda"]}, "to_port": {"constant_value": 443}}, "mode": "managed", "name": "lambda_to_endpoints", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_egress_rule"}, {"address": "aws_vpc_security_group_egress_rule.lambda_to_gateway_endpoints", "expressions": {"description": {"references": ["each.key"]}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "prefix_list_id": {"references": ["aws_vpc_endpoint.gateway", "each.key"]}, "security_group_id": {"references": ["aws_security_group.lambda.id", "aws_security_group.lambda"]}, "to_port": {"constant_value": 443}}, "for_each_expression": {"references": ["var.gateway_endpoint_service_names"]}, "mode": "managed", "name": "lambda_to_gateway_endpoints", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_egress_rule"}, {"address": "aws_vpc_security_group_ingress_rule.endpoints_from_agent_runtime", "expressions": {"description": {"constant_value": "HTTPS from the Runtime ENIs. The second SG source on the endpoint group, alongside the Lambda group and the root module ALB rule."}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "referenced_security_group_id": {"references": ["aws_security_group.agent_runtime.id", "aws_security_group.agent_runtime"]}, "security_group_id": {"references": ["aws_security_group.endpoints.id", "aws_security_group.endpoints"]}, "to_port": {"constant_value": 443}}, "mode": "managed", "name": "endpoints_from_agent_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_ingress_rule"}, {"address": "aws_vpc_security_group_ingress_rule.endpoints_from_lambda", "expressions": {"description": {"constant_value": "HTTPS from the Lambda ENIs. One of two ingresses on the endpoint group: the root adds the private-origin ALB for health checks."}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "referenced_security_group_id": {"references": ["aws_security_group.lambda.id", "aws_security_group.lambda"]}, "security_group_id": {"references": ["aws_security_group.endpoints.id", "aws_security_group.endpoints"]}, "to_port": {"constant_value": 443}}, "mode": "managed", "name": "endpoints_from_lambda", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_ingress_rule"}, {"address": "data.aws_iam_policy_document.flow_logs_assume_role", "count_expression": {"references": ["var.flow_log_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["vpc-flow-logs.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "flow_logs_assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.flow_logs_delivery", "count_expression": {"references": ["var.flow_log_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents", "logs:DescribeLogStreams"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.flow_logs[0].arn", "aws_cloudwatch_log_group.flow_logs[0]", "aws_cloudwatch_log_group.flow_logs"]}, "sid": {"constant_value": "DeliverFlowLogsToOwnGroup"}}]}, "mode": "data", "name": "flow_logs_delivery", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"flow_log_enabled": {"default": true, "description": "Whether to deliver VPC flow logs to CloudWatch Logs. A plain `bool` input, so the flow-log `count`\nis known at plan time.\n"}, "flow_log_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the flow-log group."}, "flow_log_retention_days": {"default": 365, "description": "CloudWatch Logs retention, in days, for the flow-log group."}, "gateway_endpoint_service_names": {"default": ["s3", "dynamodb"], "description": "Short service names for the gateway VPC endpoints (route-table entries, not ENIs); only `s3` and `dynamodb` support this form."}, "interface_endpoint_service_names": {"description": "Short service names for the interface (AWS PrivateLink) VPC endpoints this workload needs, e.g.\n`[\"kms\", \"logs\"]`. Each is expanded to `com.amazonaws..`. A Lambda call to an AWS\nservice with no endpoint here presents as a connection timeout, not as an authorization error.\n"}, "name_prefix": {"description": "Prefix for every resource name and `Name` tag this module creates."}, "nat_gateway_enabled": {"description": "Whether to create the egress-only internet path: an EIP and NAT gateway in the adopted IGW-routed\nsubnet, the default route it adds to the adopted private route tables, and a 443-only egress rule on\nthe Lambda group. The NAT gateway admits no inbound connection, and the private subnets are never\nassociated with the public route table (see `nat.tf`).\n\nNo default; plan refuses until a value is set. With `false` the relay cannot fetch the Cognito JWKS\n(the user pool has a domain, so the `cognito-idp` interface endpoint cannot serve it) and every agent\nturn fails authentication. `true` creates a NAT gateway, billed hourly and per GB.\n"}, "nat_public_subnet_id": {"default": null, "description": "Id of an existing IGW-routed subnet in the adopted VPC for the NAT gateway to land in. Required when\n`nat_gateway_enabled` is true; ignored otherwise. No default.\n\nMust not appear in `private_subnet_ids`; a precondition on `aws_nat_gateway.this` in `nat.tf`\nasserts that at plan time.\n"}, "private_dns_disabled_services": {"default": ["execute-api"], "description": "Interface-endpoint services whose private DNS is off. Defaults to `[\"execute-api\"]`: private DNS on\nan `execute-api` endpoint would resolve `*.execute-api..amazonaws.com` to this endpoint for\nevery workload in the adopted VPC. CloudFront routes to the VPC origin by load balancer ARN and uses\nthe hostname only as the `Host` header.\n"}, "private_route_table_ids": {"description": "Route table ids the adopted private subnets use. No default.\n\nMust not be the VPC's main route table, nor a table serving subnets outside `private_subnet_ids`;\npreconditions refuse both at plan time.\n\nTwo consumers: the NAT default route in `nat.tf`, and the gateway endpoints' `route_table_ids` in\n`endpoints.tf`. Every table named here receives a `0.0.0.0/0` route to this stack's NAT gateway;\n`scripts/teardown.sh` removes exactly that route.\n"}, "private_subnet_ids": {"description": "Ids of the existing private subnets in the adopted VPC to place Lambda ENIs in. No default.\n\nThese are the subnets whose route tables receive the NAT default route. They must be private; the\nmodule cannot detect a public subnet from its id.\n"}, "region": {"description": "Region the endpoint service names are built for."}, "runtime_route_table_ids": {"default": [], "description": "Route table ids of the Runtime subnets, associated with the S3/DynamoDB gateway endpoints so ECR\nimage-layer pulls have an S3 path. Separate from `private_route_table_ids`: these tables get no NAT\ndefault route, so the Runtime has no internet path. Empty when the Runtime is not in VPC mode.\n"}, "runtime_subnet_ids": {"default": [], "description": "Subnet ids for the AgentCore Runtime's VPC-mode ENIs, separate from `private_subnet_ids` (which\nfeeds every interface endpoint's `subnet_ids` and the `execute-api` positional-length contract). The\nRuntime reaches the interface endpoints through private DNS, so it needs no local endpoint ENI.\n\nEmpty when the Runtime is not in VPC mode. When non-empty, the subnets must be in AgentCore-supported\nAZs for the region (`infra/regions.json`) and must not include `nat_public_subnet_id`;\n`preflight_adopted_vpc.sh` asserts the AZs and the precondition below asserts the disjointness.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already carries the mandatory tags; this adds or overrides per-resource."}, "vpc_cidr_block": {"description": "The adopted VPC's IPv4 CIDR, used only for the `vpc_cidr_block` output that Layer 4 checks read."}, "vpc_id": {"description": "Id of the existing VPC to adopt. This module creates no VPC.\n\nNo default; set it through the gitignored tfvars. `terraform.tfvars.example` carries a placeholder.\n"}}}, "source": "./modules/vpc"}}, "outputs": {"agent_relay_function_name": {"description": "The relay Lambda's function name, for the relay smoke check's `get-function-configuration` env-var assertions.", "expression": {"references": ["module.agent_relay.function_name", "module.agent_relay"]}}, "agent_relay_function_url": {"description": "The relay Function URL, scheme included. The relay smoke check asserts an unauthenticated call to this hostname, not through the distribution, is denied.", "expression": {"references": ["module.agent_relay.function_url", "module.agent_relay"]}}, "agent_relay_log_group_name": {"description": "The relay Lambda CloudWatch log group name, taken from `aws_cloudwatch_log_group.this.name`. Read by the relay-IAM smoke check to simulate `logs:CreateLogStream`/`logs:PutLogEvents` against the deployed group.", "expression": {"references": ["module.agent_relay.log_group_name", "module.agent_relay"]}}, "agent_relay_role_arn": {"description": "The relay Lambda execution role ARN. Read by `scripts/smoke/iam_roles.py` to simulate the relay rows against the deployed role.", "expression": {"references": ["module.agent_relay.role_arn", "module.agent_relay"]}}, "agentcore_gateway_mcp_url": {"description": "MCP endpoint of Gateway #1: `agentcore_gateway_url` with the `/mcp` path, which the deployed `gatewayUrl` omits.", "expression": {"references": ["module.agentcore.gateway_url", "module.agentcore"]}}, "agentcore_gateway_url": {"description": "AgentCore Gateway invocation URL.", "expression": {"references": ["module.agentcore.gateway_url", "module.agentcore"]}}, "agentcore_runtime_arn": {"description": "Deployed AgentCore Runtime ARN.", "expression": {"references": ["module.agentcore.agent_runtime_arn", "module.agentcore"]}}, "agentcore_runtime_log_group_name": {"description": "CloudWatch Logs group name for the AgentCore Runtime's default endpoint stdout.", "expression": {"references": ["module.agentcore.agent_runtime_log_group_name", "module.agentcore"]}}, "agentcore_runtime_role_arn": {"description": "Execution role ARN of the AgentCore Runtime, the positive-control principal for the relay-IAM smoke check deny rows.", "expression": {"references": ["aws_iam_role.agentcore_runtime.arn", "aws_iam_role.agentcore_runtime"]}}, "api_endpoint": {"description": "The private REST API invoke hostname. Not a public endpoint: it is reachable only through the `execute-api` VPC endpoint, and CloudFront uses it only as a `Host` header. Use `api_id` to identify the API.", "expression": {"references": ["module.api.private_origin_domain_name", "module.api"]}}, "api_id": {"description": "The REST API's id, read by `scripts/smoke/api_routes.py` to identify the API.", "expression": {"references": ["module.api.api_id", "module.api"]}}, "api_origin_alb_arn": {"description": "Internal ALB fronting the private REST API. The CloudFront VPC origin references it by this ARN and performs no DNS lookup.", "expression": {"references": ["module.api_origin.alb_arn", "module.api_origin"]}}, "api_origin_alb_security_group_id": {"description": "The ALB security group, the source of `aws_vpc_security_group_ingress_rule.endpoints_from_api_origin_alb`. A T3 check asserts the endpoint group admits this group.", "expression": {"references": ["module.api_origin.alb_security_group_id", "module.api_origin"]}}, "api_origin_listener_protocol": {"description": "The listener protocol deployed on the ALB. A check asserts the `http-only` listener against the resource.", "expression": {"references": ["module.api_origin.listener_protocol", "module.api_origin"]}}, "api_origin_target_group_arn": {"description": "Target group holding the `execute-api` endpoint ENI IPs. A T3 check reads `describe-target-health` here.", "expression": {"references": ["module.api_origin.target_group_arn", "module.api_origin"]}}, "api_origin_vpc_origin_id": {"description": "Id of the CloudFront VPC origin, which `module.frontend_cdn` consumes as `api_origin_vpc_origin_id` for the `/api/*` origin `vpc_origin_config`. A T3 check asserts the deployed distribution routes `/api/*` through this origin.", "expression": {"references": ["module.api_origin.vpc_origin_id", "module.api_origin"]}}, "api_stage_invoke_url": {"description": "Full invoke URL for the deployed API stage.", "expression": {"references": ["module.api.stage_invoke_url", "module.api"]}}, "cloudfront_distribution_id": {"description": "CloudFront distribution id, used to invalidate cached assets after a frontend publish.", "expression": {"references": ["module.frontend_cdn.distribution_id", "module.frontend_cdn"]}}, "cloudfront_domain_name": {"description": "CloudFront distribution domain name serving the frontend build.", "expression": {"references": ["module.frontend_cdn.distribution_domain_name", "module.frontend_cdn"]}}, "cloudtrail_access_logs_bucket_name": {"description": "Destination bucket for the CloudTrail delivery bucket S3 server access logs. Its log source is `cloudtrail_s3_bucket_name`, a different bucket.", "expression": {"references": ["module.observability.cloudtrail_access_logs_bucket_name", "module.observability"]}}, "cloudtrail_s3_bucket_name": {"description": "The CloudTrail log-file delivery bucket, whose access logs land in `cloudtrail_access_logs_bucket_name`. Read by the delivery smoke check as the source side of its target assertion.", "expression": {"references": ["module.observability.cloudtrail_s3_bucket_name", "module.observability"]}}, "cognito_domain": {"description": "Cognito prefix domain (no custom ACM certificate). Combine with `var.aws_region` as `https://.auth..amazoncognito.com` to reach the `/oauth2/token` endpoint the MCP `client_credentials` flow uses; see `docs/mcp-client-guide.md`.", "expression": {"references": ["module.cognito.domain", "module.cognito"]}}, "cognito_gateway_scope": {"description": "The `gateway/invoke` resource-server scope identifier, re-exported from `module.cognito.gateway_scope_identifier`. Read by `scripts/smoke/gateway_tools.py`.", "expression": {"references": ["module.cognito.gateway_scope_identifier", "module.cognito"]}}, "cognito_mcp_client_id": {"description": "App client id for MCP clients (confidential client).", "expression": {"references": ["module.cognito.mcp_client_id", "module.cognito"]}}, "cognito_mcp_client_secret": {"description": "App client secret for the MCP client, empty after the first secret rotation (`scripts/rotate_mcp_client_secret.py`). Sensitive; never write it to a tracked file. Any copy kept elsewhere, for example in Secrets Manager, is made out of band; nothing in this stack stores one.", "expression": {"references": ["module.cognito.mcp_client_secret", "module.cognito"]}, "sensitive": true}, "cognito_mcp_oauth_client_id": {"description": "App client id for interactive MCP OAuth clients (public client, authorization code, loopback callbacks); accepted by Gateway #2 only.", "expression": {"references": ["module.cognito.mcp_oauth_client_id", "module.cognito"]}}, "cognito_spa_client_id": {"description": "App client id for the SPA (public client).", "expression": {"references": ["module.cognito.spa_client_id", "module.cognito"]}}, "cognito_token_endpoint": {"description": "Fully-formed Cognito `/oauth2/token` endpoint URL for the MCP app client's `client_credentials` grant.", "expression": {"references": ["module.cognito.domain", "module.cognito", "var.aws_region"]}}, "cognito_user_pool_id": {"description": "Cognito user pool id.", "expression": {"references": ["module.cognito.user_pool_id", "module.cognito"]}}, "crm_operator_principal_arns": {"description": "The operator principals admitted by the DynamoDB table and CMK policies. Read by the Layer 4 `dynamodb_principal_deny` smoke check to assert the deployed policies' allowlists.", "expression": {"references": ["var.crm_operator_principal_arns"]}}, "dynamodb_table_names": {"description": "Map of logical table name to physical DynamoDB table name, for the 11 tables.", "expression": {"references": ["module.dynamodb.table_names", "module.dynamodb"]}}, "eval_artifacts_bucket_arn": {"description": "The eval-artefacts bucket ARN, for a smoke check composing its own policy or simulation against it.", "expression": {"references": ["module.eval_artifacts.bucket_arn", "module.eval_artifacts"]}}, "eval_artifacts_bucket_name": {"description": "The eval-artefacts bucket name, which embeds the account id. Read by `sweep_control` (as EVAL_ARTIFACTS_BUCKET) and by the presigned-URL smoke check.", "expression": {"references": ["module.eval_artifacts.bucket_name", "module.eval_artifacts"]}}, "eval_artifacts_prefix": {"description": "The single key prefix artefacts are written under, and the only prefix the `sweep_control` artifacts grant covers. Read by `sweep_control` as EVAL_ARTIFACTS_PREFIX.", "expression": {"references": ["module.eval_artifacts.artifact_prefix", "module.eval_artifacts"]}}, "eval_state_machine_arn": {"description": "ARN of the eval_sweep Step Functions state machine, started by eval_trigger.", "expression": {"references": ["aws_sfn_state_machine.eval_sweep.arn", "aws_sfn_state_machine.eval_sweep"]}}, "eval_trigger_function_name": {"description": "The `eval_trigger` Lambda's function name. Read by the smoke checks: `admin_authz` derives the Lambda name prefix from it, `eval_sfn` and `chat_path_iam` read its configuration, and `resource_protection` checks its log group.", "expression": {"references": ["module.lambda_action_eval_trigger.function_name", "module.lambda_action_eval_trigger"]}}, "frontend_cdn_logs_bucket_name": {"description": "Destination bucket for the CloudFront origin bucket and eval-artefacts bucket S3 server access logs, and for CloudFront standard access logs. Log sources: `frontend_origin_bucket_name`, `eval_artifacts_bucket_name`, and the distribution.", "expression": {"references": ["module.frontend_cdn.logs_bucket_name", "module.frontend_cdn"]}}, "frontend_origin_bucket_name": {"description": "Private S3 bucket holding the frontend static build \u2014 the `aws s3 sync` target of the deploy script's publish step.", "expression": {"references": ["module.frontend_cdn.origin_bucket_name", "module.frontend_cdn"]}}, "mcp_chat_gateway_url": {"description": "MCP endpoint URL of Gateway #2, which exposes only `chat_with_supervisor`.", "expression": {"references": ["module.mcp_chat_gateway.gateway_url", "module.mcp_chat_gateway"]}}, "vpc_flow_log_group_name": {"description": "The VPC flow-log group name, or null when flow logs are disabled. Blocked egress appears here as REJECT records.", "expression": {"references": ["module.vpc.flow_log_group_name", "module.vpc"]}}, "vpc_id": {"description": "Id of the adopted VPC the stack deploys into. Read by the Layer 4 VPC smoke check.", "expression": {"references": ["module.vpc.vpc_id", "module.vpc"]}}, "vpc_interface_endpoint_service_names": {"description": "Fully-qualified service names of the interface endpoints created: the AWS services the workload can reach privately. Read by checks that assert a dependency is reachable.", "expression": {"references": ["module.vpc.interface_endpoint_service_names", "module.vpc"]}}, "vpc_lambda_security_group_ids": {"description": "The Lambda ENI security group. Read by Layer 4 to assert it has no ingress rule and no egress destination outside this VPC's endpoints.", "expression": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}}, "vpc_lambda_subnet_ids": {"description": "The private subnet ids every Lambda's `vpc_config` places ENIs in. Read by the Layer 4 VPC smoke check to assert each subnet's route table carries no route to a gateway.", "expression": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}}, "resources": [{"address": "aws_bedrockagentcore_resource_policy.agent_runtime_endpoint_relay_only", "expressions": {"policy": {"references": ["data.aws_iam_policy_document.agent_runtime_endpoint_relay_only.json", "data.aws_iam_policy_document.agent_runtime_endpoint_relay_only"]}, "resource_arn": {"references": ["local.agent_runtime_endpoint_arn"]}}, "mode": "managed", "name": "agent_runtime_endpoint_relay_only", "provider_config_key": "aws", "schema_version": 0, "type": "aws_bedrockagentcore_resource_policy"}, {"address": "aws_bedrockagentcore_resource_policy.agent_runtime_relay_only", "expressions": {"policy": {"references": ["data.aws_iam_policy_document.agent_runtime_relay_only.json", "data.aws_iam_policy_document.agent_runtime_relay_only"]}, "resource_arn": {"references": ["module.agentcore.agent_runtime_arn", "module.agentcore"]}}, "mode": "managed", "name": "agent_runtime_relay_only", "provider_config_key": "aws", "schema_version": 0, "type": "aws_bedrockagentcore_resource_policy"}, {"address": "aws_cloudwatch_log_group.eval_sweep", "expressions": {"kms_key_id": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "name": {"references": ["local.eval_sweep_state_machine_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "eval_sweep", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_role.agentcore_gateway", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.agentcore_assume_role.json", "data.aws_iam_policy_document.agentcore_assume_role"]}, "name": {"constant_value": "crm-agent-eval-gateway-role"}}, "mode": "managed", "name": "agentcore_gateway", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role.agentcore_runtime", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.agentcore_assume_role.json", "data.aws_iam_policy_document.agentcore_assume_role"]}, "name": {"constant_value": "crm-agent-eval-runtime-role"}}, "mode": "managed", "name": "agentcore_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role.eval_sweep", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.eval_sweep_assume_role.json", "data.aws_iam_policy_document.eval_sweep_assume_role"]}, "name": {"references": ["local.eval_sweep_state_machine_name"]}, "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "eval_sweep", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.agentcore_gateway", "expressions": {"name": {"constant_value": "crm-agent-eval-gateway-permissions"}, "policy": {"references": ["data.aws_iam_policy_document.agentcore_gateway_permissions.json", "data.aws_iam_policy_document.agentcore_gateway_permissions"]}, "role": {"references": ["aws_iam_role.agentcore_gateway.id", "aws_iam_role.agentcore_gateway"]}}, "mode": "managed", "name": "agentcore_gateway", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.agentcore_runtime", "expressions": {"name": {"constant_value": "crm-agent-eval-runtime-permissions"}, "policy": {"references": ["data.aws_iam_policy_document.agentcore_runtime_permissions.json", "data.aws_iam_policy_document.agentcore_runtime_permissions"]}, "role": {"references": ["aws_iam_role.agentcore_runtime.id", "aws_iam_role.agentcore_runtime"]}}, "mode": "managed", "name": "agentcore_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.agentcore_runtime_logs", "expressions": {"name": {"constant_value": "crm-agent-eval-runtime-logs"}, "policy": {"references": ["data.aws_iam_policy_document.agentcore_runtime_logs.json", "data.aws_iam_policy_document.agentcore_runtime_logs"]}, "role": {"references": ["aws_iam_role.agentcore_runtime.id", "aws_iam_role.agentcore_runtime"]}}, "mode": "managed", "name": "agentcore_runtime_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.chat_target_invoke_runtime", "expressions": {"name": {"references": ["local.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.chat_target_invoke_runtime.json", "data.aws_iam_policy_document.chat_target_invoke_runtime"]}, "role": {"references": ["module.lambda_action_chat_target.role_name", "module.lambda_action_chat_target"]}}, "mode": "managed", "name": "chat_target_invoke_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.eval_sweep", "expressions": {"name": {"references": ["local.eval_sweep_state_machine_name"]}, "policy": {"references": ["data.aws_iam_policy_document.eval_sweep_permissions.json", "data.aws_iam_policy_document.eval_sweep_permissions"]}, "role": {"references": ["aws_iam_role.eval_sweep.name", "aws_iam_role.eval_sweep"]}}, "mode": "managed", "name": "eval_sweep", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.eval_trigger_artifacts", "expressions": {"name": {"references": ["local.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.eval_trigger_artifacts.json", "data.aws_iam_policy_document.eval_trigger_artifacts"]}, "role": {"references": ["module.lambda_action_eval_trigger.role_name", "module.lambda_action_eval_trigger"]}}, "mode": "managed", "name": "eval_trigger_artifacts", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.eval_trigger_states", "expressions": {"name": {"references": ["local.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.eval_trigger_states.json", "data.aws_iam_policy_document.eval_trigger_states"]}, "role": {"references": ["module.lambda_action_eval_trigger.role_name", "module.lambda_action_eval_trigger"]}}, "mode": "managed", "name": "eval_trigger_states", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.sweep_control_artifacts", "expressions": {"name": {"references": ["local.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.sweep_control_artifacts.json", "data.aws_iam_policy_document.sweep_control_artifacts"]}, "role": {"references": ["module.lambda_action_sweep_control.role_name", "module.lambda_action_sweep_control"]}}, "mode": "managed", "name": "sweep_control_artifacts", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.sweep_task_invoke_runtime", "expressions": {"name": {"references": ["local.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.sweep_task_invoke_runtime.json", "data.aws_iam_policy_document.sweep_task_invoke_runtime"]}, "role": {"references": ["module.lambda_action_sweep_task.role_name", "module.lambda_action_sweep_task"]}}, "mode": "managed", "name": "sweep_task_invoke_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_kms_alias.eval_artifacts", "expressions": {"name": {"references": ["local.name_prefix"]}, "target_key_id": {"references": ["aws_kms_key.eval_artifacts.key_id", "aws_kms_key.eval_artifacts"]}}, "mode": "managed", "name": "eval_artifacts", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_alias"}, {"address": "aws_kms_key.eval_artifacts", "expressions": {"deletion_window_in_days": {"constant_value": 7}, "description": {"references": ["local.name_prefix"]}, "enable_key_rotation": {"constant_value": true}, "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "eval_artifacts", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key"}, {"address": "aws_kms_key_policy.eval_artifacts", "expressions": {"bypass_policy_lockout_safety_check": {"constant_value": false}, "key_id": {"references": ["aws_kms_key.eval_artifacts.id", "aws_kms_key.eval_artifacts"]}, "policy": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current", "local.eval_artifacts_principal_arns", "var.crm_operator_principal_arns", "var.crm_operator_principal_arns", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}}, "mode": "managed", "name": "eval_artifacts", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key_policy"}, {"address": "aws_s3_object.agent_source", "expressions": {"bucket": {"references": ["module.eval_artifacts.bucket_name", "module.eval_artifacts"]}, "key": {"constant_value": "agent-source/agent.zip"}, "kms_key_id": {"references": ["aws_kms_key.eval_artifacts.arn", "aws_kms_key.eval_artifacts"]}, "source": {"references": ["var.lambda_build_dir"]}, "source_hash": {"references": ["var.lambda_build_dir"]}, "tags": {"constant_value": {"data-classification": "internal"}}}, "mode": "managed", "name": "agent_source", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_object"}, {"address": "aws_sfn_state_machine.eval_sweep", "depends_on": ["aws_iam_role_policy.eval_sweep"], "expressions": {"definition": {"references": ["path.module", "module.lambda_action_sweep_control.function_arn", "module.lambda_action_sweep_control", "module.lambda_action_sweep_task.function_arn", "module.lambda_action_sweep_task"]}, "logging_configuration": [{"include_execution_data": {"constant_value": false}, "level": {"constant_value": "ALL"}, "log_destination": {"references": ["aws_cloudwatch_log_group.eval_sweep.arn", "aws_cloudwatch_log_group.eval_sweep"]}}], "name": {"references": ["local.eval_sweep_state_machine_name"]}, "role_arn": {"references": ["aws_iam_role.eval_sweep.arn", "aws_iam_role.eval_sweep"]}, "tags": {"references": ["var.data_classification"]}, "tracing_configuration": [{"enabled": {"constant_value": true}}], "type": {"constant_value": "STANDARD"}}, "mode": "managed", "name": "eval_sweep", "provider_config_key": "aws", "schema_version": 0, "type": "aws_sfn_state_machine"}, {"address": "aws_ssm_parameter.relay_cognito_audience", "expressions": {"name": {"references": ["local.relay_cognito_audience_parameter_name"]}, "tags": {"constant_value": {"data-classification": "internal"}}, "type": {"constant_value": "String"}, "value": {"references": ["module.cognito.spa_client_id", "module.cognito"]}}, "mode": "managed", "name": "relay_cognito_audience", "provider_config_key": "aws", "schema_version": 0, "type": "aws_ssm_parameter"}, {"address": "aws_vpc_endpoint_policy.states", "expressions": {"policy": {"references": ["data.aws_iam_policy_document.states_endpoint.json", "data.aws_iam_policy_document.states_endpoint"]}, "vpc_endpoint_id": {"references": ["module.vpc.states_vpc_endpoint_id", "module.vpc"]}}, "mode": "managed", "name": "states", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_endpoint_policy"}, {"address": "aws_vpc_security_group_ingress_rule.endpoints_from_api_origin_alb", "expressions": {"description": {"constant_value": "HTTPS from the private-origin ALB. The only ingress any endpoint has besides the Lambda group."}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "referenced_security_group_id": {"references": ["module.api_origin.alb_security_group_id", "module.api_origin"]}, "security_group_id": {"references": ["module.vpc.execute_api_security_group_id", "module.vpc"]}, "to_port": {"constant_value": 443}}, "mode": "managed", "name": "endpoints_from_api_origin_alb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_ingress_rule"}, {"address": "terraform_data.agent_only_tools_guard", "mode": "managed", "name": "agent_only_tools_guard", "provider_config_key": "terraform", "schema_version": 0, "type": "terraform_data"}, {"address": "terraform_data.chat_scope_agreement", "mode": "managed", "name": "chat_scope_agreement", "provider_config_key": "terraform", "schema_version": 0, "type": "terraform_data"}, {"address": "terraform_data.reserved_concurrency_headroom_guard", "mode": "managed", "name": "reserved_concurrency_headroom_guard", "provider_config_key": "terraform", "schema_version": 0, "type": "terraform_data"}, {"address": "data.aws_caller_identity.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_caller_identity"}, {"address": "data.aws_iam_policy_document.agent_runtime_endpoint_relay_only", "expressions": {"statement": [{"actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"references": ["local.runtime_invoker_role_arns"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["local.agent_runtime_endpoint_arn"]}, "sid": {"constant_value": "OnlyTheInvokerRolesMayInvokeThisEndpoint"}}, {"actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime", "bedrock-agentcore:InvokeAgentRuntimeForUser", "bedrock-agentcore:InvokeAgentRuntimeCommand", "bedrock-agentcore:InvokeAgentRuntimeCommandShell", "bedrock-agentcore:InvokeAgentRuntimeWithWebSocketStream", "bedrock-agentcore:InvokeAgentRuntimeWithWebSocketStreamForUser", "bedrock-agentcore:StopRuntimeSession", "bedrock-agentcore:GetAgentCard"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["local.runtime_invoker_role_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["local.agent_runtime_endpoint_arn"]}, "sid": {"constant_value": "DenyRuntimeDataPlaneToAnyOtherPrincipal"}}]}, "mode": "data", "name": "agent_runtime_endpoint_relay_only", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.agent_runtime_relay_only", "expressions": {"statement": [{"actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"references": ["local.runtime_invoker_role_arns"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["module.agentcore.agent_runtime_arn", "module.agentcore"]}, "sid": {"constant_value": "OnlyTheInvokerRolesMayInvokeThisRuntime"}}, {"actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime", "bedrock-agentcore:InvokeAgentRuntimeForUser", "bedrock-agentcore:InvokeAgentRuntimeCommand", "bedrock-agentcore:InvokeAgentRuntimeCommandShell", "bedrock-agentcore:InvokeAgentRuntimeWithWebSocketStream", "bedrock-agentcore:InvokeAgentRuntimeWithWebSocketStreamForUser", "bedrock-agentcore:StopRuntimeSession", "bedrock-agentcore:GetAgentCard"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["local.runtime_invoker_role_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["module.agentcore.agent_runtime_arn", "module.agentcore"]}, "sid": {"constant_value": "DenyRuntimeDataPlaneToAnyOtherPrincipal"}}]}, "mode": "data", "name": "agent_runtime_relay_only", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.agentcore_assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["bedrock-agentcore.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "agentcore_assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.agentcore_gateway_permissions", "expressions": {"statement": [{"actions": {"constant_value": ["lambda:InvokeFunction"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.lambda_action"]}, "sid": {"constant_value": "InvokeActionLambdas"}}, {"actions": {"constant_value": ["lambda:InvokeFunction"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.lambda_action_interceptor.function_arn", "module.lambda_action_interceptor"]}, "sid": {"constant_value": "InvokeInterceptor"}}]}, "mode": "data", "name": "agentcore_gateway_permissions", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.agentcore_runtime_logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents", "logs:DescribeLogStreams"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.agentcore.agent_runtime_log_group_arn", "module.agentcore", "module.agentcore.agent_runtime_log_group_arn", "module.agentcore"]}, "sid": {"constant_value": "CloudWatchLogsAccess"}}]}, "mode": "data", "name": "agentcore_runtime_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.agentcore_runtime_permissions", "expressions": {"statement": [{"actions": {"constant_value": ["lambda:InvokeFunction"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.lambda_action", "local.runtime_uninvocable_tools"]}, "sid": {"constant_value": "InvokeActionLambdas"}}, {"actions": {"constant_value": ["bedrock:InvokeModel", "bedrock:InvokeModelWithResponseStream"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["local.bedrock_inference_profiles", "var.aws_region", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current", "var.aws_region", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "sid": {"constant_value": "BedrockInference"}}, {"actions": {"constant_value": ["bedrock:InvokeModel", "bedrock:InvokeModelWithResponseStream"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["local.bedrock_inference_profiles", "var.aws_region", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "bedrock:InferenceProfileArn"}}], "effect": {"constant_value": "Allow"}, "resources": {"references": ["local.bedrock_foundation_models", "local.bedrock_foundation_models"]}, "sid": {"constant_value": "BedrockInferenceFoundationModels"}}, {"actions": {"constant_value": ["ecr:BatchGetImage", "ecr:GetDownloadUrlForLayer"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.aws_region", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current", "local.agent_ecr_repository_name"]}, "sid": {"constant_value": "EcrImageAccess"}}, {"actions": {"constant_value": ["ecr:GetAuthorizationToken"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "EcrTokenAccess"}}]}, "mode": "data", "name": "agentcore_runtime_permissions", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.chat_target_invoke_runtime", "expressions": {"statement": [{"actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.agentcore.agent_runtime_arn", "module.agentcore", "local.agent_runtime_endpoint_arn"]}, "sid": {"constant_value": "InvokeTheRuntimeDefaultEndpoint"}}, {"effect": {"constant_value": "Deny"}, "not_actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime"]}, "resources": {"references": ["module.agentcore.agent_runtime_arn", "module.agentcore", "local.agent_runtime_endpoint_arn"]}, "sid": {"constant_value": "DenyEverythingButInvokeOnThisRuntime"}}]}, "mode": "data", "name": "chat_target_invoke_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.eval_sweep_assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "aws:SourceAccount"}}, {"test": {"constant_value": "ArnEquals"}, "values": {"references": ["local.eval_sweep_state_machine_arn"]}, "variable": {"constant_value": "aws:SourceArn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["states.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "eval_sweep_assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.eval_sweep_permissions", "expressions": {"statement": [{"actions": {"constant_value": ["lambda:InvokeFunction"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.lambda_action_sweep_control.function_arn", "module.lambda_action_sweep_control", "module.lambda_action_sweep_control.function_arn", "module.lambda_action_sweep_control", "module.lambda_action_sweep_task.function_arn", "module.lambda_action_sweep_task", "module.lambda_action_sweep_task.function_arn", "module.lambda_action_sweep_task"]}, "sid": {"constant_value": "InvokeSweepLambdas"}}, {"actions": {"references": ["local.sfn_vended_log_delivery_actions"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "SfnVendedLogDelivery"}}, {"actions": {"references": ["local.sfn_xray_tracing_actions"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "SfnXRayTracing"}}]}, "mode": "data", "name": "eval_sweep_permissions", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.eval_trigger_artifacts", "expressions": {"statement": [{"actions": {"constant_value": ["s3:GetObject"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.eval_artifacts.bucket_arn", "module.eval_artifacts", "module.eval_artifacts.artifact_prefix", "module.eval_artifacts"]}, "sid": {"constant_value": "ReadArtifactPrefix"}}, {"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["var.aws_region"]}, "variable": {"constant_value": "kms:ViaService"}}], "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_kms_key.eval_artifacts.arn", "aws_kms_key.eval_artifacts"]}, "sid": {"constant_value": "DecryptArtifactsViaS3"}}]}, "mode": "data", "name": "eval_trigger_artifacts", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.eval_trigger_states", "expressions": {"statement": [{"actions": {"constant_value": ["states:StartExecution"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["local.eval_sweep_state_machine_arn"]}, "sid": {"constant_value": "StartTheEvalSweep"}}, {"actions": {"constant_value": ["states:DescribeExecution"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["local.eval_sweep_execution_arn_pattern"]}, "sid": {"constant_value": "DescribeEvalSweepExecutions"}}]}, "mode": "data", "name": "eval_trigger_states", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.states_endpoint", "expressions": {"statement": [{"actions": {"constant_value": ["states:StartExecution"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "aws:PrincipalAccount"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"references": ["local.eval_sweep_state_machine_arn"]}, "sid": {"constant_value": "StartTheEvalSweep"}}, {"actions": {"constant_value": ["states:DescribeExecution"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "aws:PrincipalAccount"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"references": ["local.eval_sweep_execution_arn_pattern"]}, "sid": {"constant_value": "DescribeEvalSweepExecutions"}}]}, "mode": "data", "name": "states_endpoint", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.sweep_control_artifacts", "expressions": {"statement": [{"actions": {"constant_value": ["s3:PutObject", "s3:GetObject"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.eval_artifacts.bucket_arn", "module.eval_artifacts", "module.eval_artifacts.artifact_prefix", "module.eval_artifacts"]}, "sid": {"constant_value": "WriteAndReadArtifactPrefix"}}, {"actions": {"constant_value": ["kms:GenerateDataKey", "kms:Decrypt"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_kms_key.eval_artifacts.arn", "aws_kms_key.eval_artifacts"]}, "sid": {"constant_value": "UseArtifactsBucketCmk"}}]}, "mode": "data", "name": "sweep_control_artifacts", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.sweep_task_invoke_runtime", "expressions": {"statement": [{"actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.agentcore.agent_runtime_arn", "module.agentcore", "local.agent_runtime_endpoint_arn"]}, "sid": {"constant_value": "InvokeAgentRuntimeEvalTurn"}}]}, "mode": "data", "name": "sweep_task_invoke_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_session_context.current", "expressions": {"arn": {"references": ["data.aws_caller_identity.current.arn", "data.aws_caller_identity.current"]}}, "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_session_context"}, {"address": "data.aws_network_interface.execute_api", "count_expression": {"references": ["var.vpc_private_subnet_ids"]}, "expressions": {"id": {"references": ["module.vpc.execute_api_network_interface_ids", "module.vpc", "count.index"]}}, "mode": "data", "name": "execute_api", "provider_config_key": "aws", "schema_version": 0, "type": "aws_network_interface"}], "variables": {"api_origin_ingress_security_group_ids": {"description": "Security group ids permitted to reach the internal ALB's listener port (the `/api/*` private origin\npath). Passed to `modules/api_origin`, whose validation refuses anything that is not an `sg-` id.\nNo default; set it in the gitignored `terraform.tfvars`.\n\nThe value is the CloudFront service-managed group `CloudFront-VPCOrigins-Service-SG`, which AWS\ncreates in the adopted VPC when `aws_cloudfront_vpc_origin` is first applied. The first deployment\nof this path is therefore two-phase: apply, read the group id, set this variable, apply again. See\nthe `api_origin` variables and the runbook.\n"}, "aws_profile": {"default": "default", "description": "Named AWS CLI profile to use for all provider operations."}, "aws_region": {"default": "us-east-1", "description": "AWS region to deploy into: a US commercial region listed in `infra/regions.json`."}, "cost_center": {"default": "crm-agent-eval", "description": "Value for the mandatory `cost-center` tag applied to every resource."}, "crm_operator_principal_arns": {"description": "IAM role or user ARNs of the operators who deploy, seed and smoke-test this stack. Admitted to the\nDynamoDB tables' data plane and to table and CMK administration; every principal outside these and\nthe project's Lambda roles is denied. No default; set it in the gitignored\n`terraform.tfvars`. A plan whose caller is not listed fails at a precondition.\n"}, "data_classification": {"default": "confidential", "description": "Default value for the mandatory `data-classification` tag. Individual modules may override this per resource where a more specific classification applies."}, "environment": {"default": "dev", "description": "Value for the mandatory `environment` tag applied to every resource."}, "lambda_build_dir": {"default": "build/lambda", "description": "Directory holding the pre-built archives this composition reads, resolved\nrelative to `infra/`: one Lambda zip per `local.tool_names` entry, plus\n`identity_interceptor.zip`, `pre_token_generation.zip`, `eval_trigger.zip`\n(shared by the eval trigger, capabilities, user-settings and sweep functions),\n`chat_target.zip` (the chat Gateway's target) and `relay.zip` \u2014 and\n`agent-source.zip`, the CodeBuild source for the AgentCore container image. `scripts/package_lambdas.sh` and `scripts/package_relay.sh`\npopulate the default location, `infra/build/lambda`.\n"}, "owner": {"default": "crm-agent-eval-team", "description": "Value for the mandatory `owner` tag applied to every resource."}, "runtime_source_vpce_deny_enabled": {"default": false, "description": "Stage 2: whether the runtime resource policies carry the inbound Deny. When true, both policies deny\n`InvokeAgentRuntime` from every principal not arriving through the bedrock-agentcore VPC endpoint\n(with `aws:ViaAWSService = false` exempting internal service calls).\n\nDefaults to false. Enable it only once the relay's calls are shown to carry `aws:SourceVpce`;\notherwise every chat turn is denied. Set `-var runtime_source_vpce_deny_enabled=true` (or in a\ngitignored `*.auto.tfvars`) as a separate apply after stage 1 is verified.\n"}, "runtime_source_vpce_report_only_enabled": {"default": true, "description": "Stage 1: whether the runtime resource policies carry the report-only `aws:SourceVpce` Allow for any\nprincipal arriving through the bedrock-agentcore VPC endpoint. It grants nothing the relay-role\nAllow does not already cover for the relay; it shows, before the Deny, that traffic through this\nstack's endpoint is admitted by the SourceVpce condition.\n"}, "service": {"default": "crm-agent-eval", "description": "Value for the mandatory `service` tag applied to every resource."}, "vpc_cidr_block": {"default": "10.20.0.0/20", "description": "The adopted VPC's IPv4 CIDR, published as an output for Layer 4 checks. Nothing is sized from it.\nIt must match the adopted VPC.\n"}, "vpc_flow_log_enabled": {"default": true, "description": "Whether to deliver VPC flow logs to CloudWatch Logs."}, "vpc_id": {"description": "Id of the existing VPC this deployment adopts. The stack creates no VPC; it creates only the NAT\ngateway path, the route that path adds to the adopted private route tables, two security groups,\nand the VPC endpoints.\n\nNo default. Set it in the gitignored `terraform.tfvars`; `terraform.tfvars.example` shows the shape\nwith a placeholder.\n"}, "vpc_nat_gateway_enabled": {"description": "Whether to create the egress-only internet path the relay's Cognito JWKS fetch requires.\n\nNo default; `terraform plan` refuses until a value is set. `false` leaves the relay unable to\nauthenticate any request (the user pool has a domain, so the `cognito-idp` interface endpoint cannot\nserve it). `true` creates a NAT gateway, billed hourly and per GB.\n\nSet it on the command line (`-var vpc_nat_gateway_enabled=true`) or in a gitignored `*.auto.tfvars`.\nThe NAT gateway is egress-only: it admits no inbound connection (see `infra/modules/vpc/nat.tf`).\n"}, "vpc_nat_public_subnet_id": {"default": null, "description": "Id of an existing IGW-routed subnet in the adopted VPC for the NAT gateway to land in. Required when\n`vpc_nat_gateway_enabled` is true; the plan fails otherwise. No default.\n\nMust not also appear in `vpc_private_subnet_ids`; the module asserts that at plan time.\n"}, "vpc_private_route_table_ids": {"description": "Route table ids the adopted private subnets use. No default.\n\nMust not be the VPC's main route table; a precondition refuses it at plan time.\n\nEvery table named here receives a `0.0.0.0/0` route to this stack's NAT gateway and the S3/DynamoDB\ngateway-endpoint associations.\n"}, "vpc_private_subnet_ids": {"description": "Ids of the existing private subnets in the adopted VPC that every Lambda's ENIs are placed in. No\ndefault; set it in the gitignored `terraform.tfvars`.\n\nThe AZ set is whatever these subnets are; it is not derived from the region.\n"}, "vpc_runtime_route_table_ids": {"default": [], "description": "Route table ids of the `vpc_runtime_subnet_ids` subnets, associated with the S3/DynamoDB gateway\nendpoints so ECR image-layer pulls have an S3 path. They receive no NAT default route (that stays\non `vpc_private_route_table_ids`), so the Runtime has no internet path. Defaults to empty.\n"}, "vpc_runtime_subnet_ids": {"default": [], "description": "Ids of the private subnets for the AgentCore Runtime's VPC-mode ENIs, separate from\n`vpc_private_subnet_ids` (see the vpc module's `runtime_subnet_ids`).\n\nEvery subnet must be in an AgentCore-supported AZ for the region (`infra/regions.json`) and must\nnot be `vpc_nat_public_subnet_id`; `scripts/preflight_adopted_vpc.sh` and a module precondition\nassert both. The Runtime runs in VPC mode, so an empty list fails the plan.\n"}}}}, "format_version": "1.2", "variables": {"api_origin_ingress_security_group_ids": {"value": ["sg-cloudfrontvpcoriginplaceholder"]}, "aws_profile": {"value": "example-deployer"}, "aws_region": {"value": "us-east-1"}, "cost_center": {"value": "crm-agent-eval"}, "crm_operator_principal_arns": {"value": ["arn:aws:iam::123456789012:role/example-deployer"]}, "data_classification": {"value": "confidential"}, "environment": {"value": "dev"}, "lambda_build_dir": {"value": "build/lambda"}, "owner": {"value": "crm-agent-eval-team"}, "runtime_source_vpce_deny_enabled": {"value": false}, "runtime_source_vpce_report_only_enabled": {"value": true}, "service": {"value": "crm-agent-eval"}, "vpc_cidr_block": {"value": "10.20.0.0/20"}, "vpc_flow_log_enabled": {"value": true}, "vpc_id": {"value": "vpc-adoptedplaceholder"}, "vpc_nat_gateway_enabled": {"value": true}, "vpc_nat_public_subnet_id": {"value": "subnet-natpublicplaceholder"}, "vpc_private_route_table_ids": {"value": ["rtb-privateoneplaceholder", "rtb-privatetwoplaceholder"]}, "vpc_private_subnet_ids": {"value": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}, "vpc_runtime_route_table_ids": {"value": ["rtb-runtimeplaceholder"]}, "vpc_runtime_subnet_ids": {"value": ["subnet-runtimeoneplaceholder", "subnet-runtimetwoplaceholder"]}}} +{"_fixture_provenance": {"captured_at": "2026-11-07", "captured_infra_digest": "5f302c501f468a6b43adaf82d48ca175f4da80b99134ccbfac01e64085889960", "currency": "Captured from a tree whose tracked infra/**/*.tf digest is captured_infra_digest. plan_freshness passes while plan_fixtures.infra_digest of the working tree equals it. The adopted network (VPC, subnets, route tables, the CloudFront VPC-origin security group) is created outside Terraform and adopted by the gitignored tfvars, so its ids are scrubbed to placeholders.", "derived_from": "native capture; no earlier fixture content", "how": "terraform show -json of a create-everything plan captured against EMPTY LOCAL STATE in a scratch copy of infra/ (providers and build/ symlinked, backend block removed so state is local), no deploy. Plan: 649 to add, 0 to change, 0 to destroy; 131 data reads. Scrubbed by scripts/scrub_plan_capture.py: account id -> 123456789012, IAM unique ids -> AIDA-example-caller-user-id, caller role and session -> example-deployer/example-session, operator principals -> example-operator-, aws_profile -> example-deployer, adopted-network ids -> non-hex placeholder tokens.", "variables_at_capture": "runtime_source_vpce_deny_enabled = false; runtime_source_vpce_report_only_enabled = true; vpc_flow_log_enabled = true; vpc_nat_gateway_enabled = true; adopted-network variables and crm_operator_principal_arns from the gitignored infra/terraform.tfvars. NONE has a tracked default that supplies a real id."}, "configuration": {"provider_config": {"aws": {"expressions": {"default_tags": [{"tags": {"references": ["var.service", "var.environment", "var.owner", "var.cost_center", "var.data_classification"]}}], "profile": {"references": ["var.aws_profile"]}, "region": {"references": ["var.aws_region"]}}, "full_name": "registry.terraform.io/hashicorp/aws", "name": "aws", "version_constraint": "6.71.0"}, "module.agentcore:null": {"full_name": "registry.terraform.io/hashicorp/null", "module_address": "module.agentcore", "name": "null"}, "terraform": {"full_name": "terraform.io/builtin/terraform", "name": "terraform"}}, "root_module": {"module_calls": {"agent_relay": {"expressions": {"agent_runtime_arn": {"references": ["module.agentcore.agent_runtime_arn", "module.agentcore"]}, "agent_runtime_qualifier": {"references": ["local.relay_runtime_qualifier"]}, "cognito_audience_parameter_arn": {"references": ["var.aws_region", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current", "local.relay_cognito_audience_parameter_name"]}, "cognito_audience_parameter_name": {"references": ["local.relay_cognito_audience_parameter_name"]}, "cognito_issuer": {"references": ["var.aws_region", "module.cognito.user_pool_id", "module.cognito"]}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "filename": {"references": ["var.lambda_build_dir"]}, "function_name": {"references": ["local.name_prefix"]}, "log_retention_days": {"constant_value": 365}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"agent_relay\"]", "local.reserved_concurrency"]}, "source_code_hash": {"references": ["var.lambda_build_dir"]}, "tags": {"references": ["var.data_classification"]}, "timeout_seconds": {"constant_value": 660}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"environment_variable_names": {"description": "Names of every environment variable this module sets on the relay. Lets a contract test assert the config surface in both directions \u2014 nothing the relay reads is unset, nothing set is unread.", "expression": {"references": ["local.environment_variables"]}}, "function_arn": {"description": "The relay function's ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The relay function's name. Consumed by `modules/frontend_cdn` to attach the CloudFront-scoped `lambda:InvokeFunctionUrl` permission.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "function_url": {"description": "The Function URL, scheme and trailing slash included, as Lambda returns it.", "expression": {"references": ["aws_lambda_function_url.this.function_url", "aws_lambda_function_url.this"]}}, "function_url_domain": {"description": "Host portion of the Function URL, for use as a CloudFront custom-origin `domain_name` (which rejects a scheme or a path).", "expression": {"references": ["aws_lambda_function_url.this.function_url", "aws_lambda_function_url.this"]}}, "log_group_name": {"description": "The relay's CloudWatch log group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "The relay execution role's ARN. Consumed by the Layer 4 `simulate-principal-policy` check.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "The relay execution role's name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"references": ["var.log_retention_days"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.invoke_runtime", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.invoke_runtime.json", "data.aws_iam_policy_document.invoke_runtime"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "invoke_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.read_audience_parameter", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.read_audience_parameter.json", "data.aws_iam_policy_document.read_audience_parameter"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "read_audience_parameter", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"environment": [{"variables": {"references": ["local.environment_variables"]}}], "filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_function_url.this", "expressions": {"authorization_type": {"constant_value": "AWS_IAM"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "invoke_mode": {"constant_value": "RESPONSE_STREAM"}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function_url"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.invoke_runtime", "expressions": {"statement": [{"actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.agent_runtime_arn", "local.agent_runtime_endpoints_arn"]}, "sid": {"constant_value": "InvokeOneRuntimeAndItsEndpoints"}}, {"effect": {"constant_value": "Deny"}, "not_actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime"]}, "resources": {"references": ["var.agent_runtime_arn", "local.agent_runtime_endpoints_arn"]}, "sid": {"constant_value": "DenyEverythingButTheOnePermittedInvokeOnThisRuntime"}}, {"actions": {"constant_value": ["bedrock-agentcore:*"]}, "effect": {"constant_value": "Deny"}, "resources": {"references": ["local.agentcore_harness_arn"]}, "sid": {"constant_value": "DenyEveryHarness"}}]}, "mode": "data", "name": "invoke_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.read_audience_parameter", "expressions": {"statement": [{"actions": {"constant_value": ["ssm:GetParameter"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.cognito_audience_parameter_arn"]}, "sid": {"constant_value": "ReadRelayParameters"}}]}, "mode": "data", "name": "read_audience_parameter", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"agent_runtime_arn": {"description": "ARN of the one AgentCore Runtime this relay may invoke\n(`module.agentcore.agent_runtime_arn`). The execution role is granted\n`bedrock-agentcore:InvokeAgentRuntime` on this ARN and its endpoint sub-resources and on nothing\nelse \u2014 no wildcard, no second runtime.\n"}, "agent_runtime_qualifier": {"default": "DEFAULT", "description": "Runtime endpoint qualifier the relay invokes, passed to the relay as `AGENT_RUNTIME_QUALIFIER`\n(`src/relay/src/runtime.ts`). The execution role's `InvokeAgentRuntime` grant covers the endpoint\nthis value names.\n"}, "cognito_audience_parameter_arn": {"description": "ARN of that same parameter, for the execution role's `ssm:GetParameter` grant. The caller constructs\nit from region, account and name, not from `aws_ssm_parameter.\u2026arn`, to avoid a module cycle.\n"}, "cognito_audience_parameter_name": {"description": "Name of the SSM parameter holding the SPA app-client id the relay requires. The relay reads it at\ncold start and rejects any token issued to a different client.\n"}, "cognito_issuer": {"description": "Cognito user-pool issuer URL (`https://cognito-idp..amazonaws.com/`). The relay derives its JWKS URL from this and rejects any token whose `iss` differs."}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables and its log group."}, "filename": {"description": "Path to the relay deployment package built by `scripts/package_relay.sh`."}, "function_name": {"description": "Unique Lambda function name. Also names this module's IAM role and log group."}, "handler": {"default": "index.handler", "description": "Lambda handler entry point inside the relay zip."}, "log_retention_days": {"default": 365, "description": "Explicit CloudWatch Logs retention for the relay's log group."}, "memory_size_mb": {"default": 512, "description": "Lambda memory allocation in MB, sizing the Node runtime and the JWKS cache."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for the relay. Must be greater than zero; 0 makes the function permanently\nuninvokable.\n\nOne chat turn holds one invocation for up to `timeout_seconds`. The caller keeps the sum of every\nreserved concurrency in the deployment below the account pool minus unreserved headroom.\n\nNo default; the caller states a value.\n"}, "runtime": {"default": "nodejs24.x", "description": "Lambda runtime identifier. Must be a Node.js runtime, which supports response streaming."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the relay package, forcing redeploy on code change."}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already carries the mandatory tags; this adds or overrides per-resource."}, "timeout_seconds": {"default": 660, "description": "Lambda invocation timeout in seconds. Must exceed the 600s chat turn wall clock."}, "vpc_security_group_ids": {"description": "Security groups for the relay's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress; the relay is invoked through the Lambda control plane (a signed Function URL invoke).\n"}, "vpc_subnet_ids": {"description": "Private subnet ids the relay's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default; at least two subnets.\n\nThe relay's outbound calls (`bedrock-agentcore:InvokeAgentRuntime`, `ssm:GetParameter` and the\nCognito JWKS fetch) leave through these subnets, via the VPC endpoints and the NAT gateway. A missing\npath presents as a hung turn, not as an authorization error.\n"}}}, "source": "./modules/agent_relay"}, "agentcore": {"depends_on": ["aws_s3_object.agent_source", "aws_iam_role_policy.agentcore_runtime"], "expressions": {"agent_runtime_environment_variables": {"references": ["module.cognito.user_pool_id", "module.cognito", "module.api.stage_invoke_url", "module.api", "local.name_prefix", "local.name_prefix"]}, "agent_runtime_name": {"constant_value": "crm_agent_eval_runtime"}, "agent_runtime_role_arn": {"references": ["aws_iam_role.agentcore_runtime.arn", "aws_iam_role.agentcore_runtime"]}, "aws_profile": {"references": ["var.aws_profile"]}, "aws_region": {"references": ["var.aws_region"]}, "buildspec": {"references": ["local.agent_buildspec"]}, "cognito_allowed_audiences": {"references": ["module.cognito.allowed_client_ids", "module.cognito"]}, "cognito_allowed_client_ids": {"references": ["module.cognito.allowed_client_ids", "module.cognito"]}, "cognito_allowed_scopes": {"references": ["module.cognito.gateway_scope_identifier", "module.cognito"]}, "cognito_discovery_url": {"references": ["var.aws_region", "module.cognito.user_pool_id", "module.cognito"]}, "cognito_required_custom_claims": {"constant_value": []}, "data_classification": {"references": ["var.data_classification"]}, "ecr_repository_name": {"references": ["local.agent_ecr_repository_name"]}, "gateway_name": {"constant_value": "crm-agent-eval-gateway"}, "gateway_role_arn": {"references": ["aws_iam_role.agentcore_gateway.arn", "aws_iam_role.agentcore_gateway"]}, "identity_interceptor_lambda_arn": {"references": ["module.lambda_action_interceptor.function_arn", "module.lambda_action_interceptor"]}, "identity_interceptor_lambda_function_name": {"references": ["module.lambda_action_interceptor.function_name", "module.lambda_action_interceptor"]}, "image_retention_count": {"constant_value": 10}, "image_tag": {"references": ["local.agent_image_tag"]}, "kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "log_retention_days": {"constant_value": 365}, "name_prefix": {"references": ["local.name_prefix"]}, "runtime_network_mode": {"constant_value": "VPC"}, "runtime_security_group_ids": {"references": ["module.vpc.runtime_security_group_id", "module.vpc"]}, "runtime_subnet_ids": {"references": ["module.vpc.runtime_subnet_ids", "module.vpc"]}, "source_bucket_arn": {"references": ["module.eval_artifacts.bucket_arn", "module.eval_artifacts"]}, "source_content_hash": {"references": ["var.lambda_build_dir"]}, "source_key": {"references": ["aws_s3_object.agent_source.key", "aws_s3_object.agent_source"]}, "source_kms_key_arn": {"references": ["aws_kms_key.eval_artifacts.arn", "aws_kms_key.eval_artifacts"]}, "tool_lambda_arns": {"references": ["module.lambda_action"]}, "tool_schemas": {"references": ["local.tool_names", "local.tools", "local.tool_schema_properties"]}}, "module": {"outputs": {"agent_runtime_arn": {"description": "The deployed AgentCore Runtime ARN.", "expression": {"references": ["aws_bedrockagentcore_agent_runtime.this.agent_runtime_arn", "aws_bedrockagentcore_agent_runtime.this"]}}, "agent_runtime_id": {"description": "The deployed AgentCore Runtime id.", "expression": {"references": ["aws_bedrockagentcore_agent_runtime.this.agent_runtime_id", "aws_bedrockagentcore_agent_runtime.this"]}}, "agent_runtime_log_group_arn": {"description": "CloudWatch Logs group ARN for the AgentCore Runtime's default endpoint stdout, for scoping the execution role's logs:* grant.", "expression": {"references": ["aws_cloudwatch_log_group.runtime.arn", "aws_cloudwatch_log_group.runtime"]}}, "agent_runtime_log_group_name": {"description": "CloudWatch Logs group name for the AgentCore Runtime's default endpoint stdout.", "expression": {"references": ["aws_cloudwatch_log_group.runtime.name", "aws_cloudwatch_log_group.runtime"]}}, "codebuild_role_arn": {"description": "ARN of the CodeBuild image-build project's service role, which reads the agent-source object and uses its CMK. The root admits it to the eval-artefacts bucket and key policies.", "expression": {"references": ["aws_iam_role.codebuild.arn", "aws_iam_role.codebuild"]}}, "ecr_repository_arn": {"description": "ARN of the ECR repository the agent container image is pushed to. The root composition scopes the\nAgentCore Runtime execution role's `ecr:BatchGetImage`/`ecr:GetDownloadUrlForLayer` grant to this\nARN.\n", "expression": {"references": ["aws_ecr_repository.agent.arn", "aws_ecr_repository.agent"]}}, "ecr_repository_url": {"description": "The ECR repository URL the agent container image is pushed to.", "expression": {"references": ["aws_ecr_repository.agent.repository_url", "aws_ecr_repository.agent"]}}, "gateway_arn": {"description": "The deployed Gateway ARN.", "expression": {"references": ["aws_bedrockagentcore_gateway.this.gateway_arn", "aws_bedrockagentcore_gateway.this"]}}, "gateway_id": {"description": "The deployed Gateway id.", "expression": {"references": ["aws_bedrockagentcore_gateway.this.gateway_id", "aws_bedrockagentcore_gateway.this"]}}, "gateway_target_ids": {"description": "Map of tool_name -> that tool's gateway target id, one entry per entry in var.tool_lambda_arns.", "expression": {"references": ["aws_bedrockagentcore_gateway_target.tool"]}}, "gateway_url": {"description": "The deployed Gateway's invocation URL.", "expression": {"references": ["aws_bedrockagentcore_gateway.this.gateway_url", "aws_bedrockagentcore_gateway.this"]}}}, "resources": [{"address": "aws_bedrockagentcore_agent_runtime.this", "depends_on": ["null_resource.image_build"], "expressions": {"agent_runtime_artifact": [{"container_configuration": [{"container_uri": {"references": ["aws_ecr_repository.agent.repository_url", "aws_ecr_repository.agent", "var.image_tag"]}}]}], "agent_runtime_name": {"references": ["var.agent_runtime_name"]}, "environment_variables": {"references": ["var.agent_runtime_environment_variables"]}, "network_configuration": [{"network_mode": {"references": ["var.runtime_network_mode"]}}], "platform_version": {"references": ["var.platform_version"]}, "region": {"references": ["var.aws_region"]}, "role_arn": {"references": ["var.agent_runtime_role_arn"]}, "tags": {"references": ["var.tags"]}, "timeouts": {"create": {"constant_value": "30m"}, "update": {"constant_value": "30m"}}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_bedrockagentcore_agent_runtime"}, {"address": "aws_bedrockagentcore_gateway.this", "expressions": {"authorizer_configuration": [{"custom_jwt_authorizer": [{"allowed_audience": {"constant_value": null}, "allowed_clients": {"references": ["var.cognito_allowed_client_ids"]}, "allowed_scopes": {"references": ["var.cognito_allowed_scopes"]}, "discovery_url": {"references": ["var.cognito_discovery_url"]}}]}], "authorizer_type": {"constant_value": "CUSTOM_JWT"}, "interceptor_configuration": [{"input_configuration": [{"pass_request_headers": {"constant_value": true}}], "interception_points": {"constant_value": ["REQUEST"]}, "interceptor": [{"lambda": [{"arn": {"references": ["var.identity_interceptor_lambda_arn"]}}]}]}], "name": {"references": ["var.gateway_name"]}, "region": {"references": ["var.aws_region"]}, "role_arn": {"references": ["var.gateway_role_arn"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_bedrockagentcore_gateway"}, {"address": "aws_bedrockagentcore_gateway_target.tool", "expressions": {"credential_provider_configuration": [{"gateway_iam_role": [{}]}], "description": {"references": ["each.key"]}, "gateway_identifier": {"references": ["aws_bedrockagentcore_gateway.this.gateway_id", "aws_bedrockagentcore_gateway.this"]}, "name": {"references": ["each.key"]}, "target_configuration": [{"mcp": [{"lambda": [{"lambda_arn": {"references": ["each.value"]}, "tool_schema": [{"inline_payload": [{"description": {"references": ["var.tool_schemas", "each.key"]}, "input_schema": [{"type": {"constant_value": "object"}}], "name": {"references": ["each.key"]}}]}]}]}]}]}, "for_each_expression": {"references": ["var.tool_lambda_arns"]}, "mode": "managed", "name": "tool", "provider_config_key": "aws", "schema_version": 0, "type": "aws_bedrockagentcore_gateway_target"}, {"address": "aws_cloudwatch_log_group.codebuild", "expressions": {"kms_key_id": {"references": ["var.kms_key_arn"]}, "name": {"references": ["var.name_prefix"]}, "retention_in_days": {"references": ["var.log_retention_days"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "codebuild", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_cloudwatch_log_group.runtime", "expressions": {"kms_key_id": {"references": ["var.kms_key_arn"]}, "name": {"references": ["aws_bedrockagentcore_agent_runtime.this.agent_runtime_id", "aws_bedrockagentcore_agent_runtime.this"]}, "retention_in_days": {"references": ["var.log_retention_days"]}, "tags": {"references": ["var.tags", "var.data_classification"]}}, "mode": "managed", "name": "runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_codebuild_project.agent_image", "expressions": {"artifacts": [{"type": {"constant_value": "NO_ARTIFACTS"}}], "build_timeout": {"constant_value": 30}, "description": {"constant_value": "Builds and pushes the AgentCore Runtime container image."}, "encryption_key": {"references": ["var.source_kms_key_arn"]}, "environment": [{"compute_type": {"constant_value": "BUILD_GENERAL1_SMALL"}, "environment_variable": [{"name": {"constant_value": "ECR_REPOSITORY_URI"}, "value": {"references": ["aws_ecr_repository.agent.repository_url", "aws_ecr_repository.agent"]}}, {"name": {"constant_value": "AWS_DEFAULT_REGION"}, "value": {"references": ["var.aws_region"]}}], "image": {"constant_value": "aws/codebuild/amazonlinux2-aarch64-standard:3.0"}, "image_pull_credentials_type": {"constant_value": "CODEBUILD"}, "privileged_mode": {"constant_value": true}, "type": {"constant_value": "ARM_CONTAINER"}}], "logs_config": [{"cloudwatch_logs": [{"group_name": {"references": ["aws_cloudwatch_log_group.codebuild.name", "aws_cloudwatch_log_group.codebuild"]}}]}], "name": {"references": ["var.name_prefix"]}, "service_role": {"references": ["aws_iam_role.codebuild.arn", "aws_iam_role.codebuild"]}, "source": [{"buildspec": {"references": ["var.buildspec"]}, "location": {"references": ["var.source_bucket_arn", "var.source_bucket_arn", "var.source_key"]}, "type": {"constant_value": "S3"}}], "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "agent_image", "provider_config_key": "aws", "schema_version": 0, "type": "aws_codebuild_project"}, {"address": "aws_ecr_lifecycle_policy.agent", "expressions": {"policy": {"references": ["var.image_retention_count", "var.image_retention_count"]}, "repository": {"references": ["aws_ecr_repository.agent.name", "aws_ecr_repository.agent"]}}, "mode": "managed", "name": "agent", "provider_config_key": "aws", "schema_version": 0, "type": "aws_ecr_lifecycle_policy"}, {"address": "aws_ecr_repository.agent", "expressions": {"encryption_configuration": [{"encryption_type": {"constant_value": "KMS"}, "kms_key": {"references": ["var.kms_key_arn"]}}], "force_delete": {"constant_value": true}, "image_scanning_configuration": [{"scan_on_push": {"constant_value": true}}], "image_tag_mutability": {"constant_value": "IMMUTABLE"}, "name": {"references": ["var.ecr_repository_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "agent", "provider_config_key": "aws", "schema_version": 0, "type": "aws_ecr_repository"}, {"address": "aws_iam_role.codebuild", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.codebuild_assume_role.json", "data.aws_iam_policy_document.codebuild_assume_role"]}, "name": {"references": ["var.name_prefix"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "codebuild", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.codebuild", "expressions": {"name": {"references": ["var.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.codebuild_permissions.json", "data.aws_iam_policy_document.codebuild_permissions"]}, "role": {"references": ["aws_iam_role.codebuild.id", "aws_iam_role.codebuild"]}}, "mode": "managed", "name": "codebuild", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_lambda_permission.gateway_invoke_interceptor", "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["var.identity_interceptor_lambda_function_name"]}, "principal": {"constant_value": "bedrock-agentcore.amazonaws.com"}, "source_arn": {"references": ["aws_bedrockagentcore_gateway.this.gateway_arn", "aws_bedrockagentcore_gateway.this"]}, "statement_id": {"constant_value": "AllowGatewayInvokeIdentityInterceptor"}}, "mode": "managed", "name": "gateway_invoke_interceptor", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "null_resource.image_build", "depends_on": ["aws_codebuild_project.agent_image"], "expressions": {"triggers": {"references": ["var.source_content_hash", "aws_codebuild_project.agent_image.name", "aws_codebuild_project.agent_image"]}}, "mode": "managed", "name": "image_build", "provider_config_key": "module.agentcore:null", "provisioners": [{"expressions": {"command": {"references": ["var.image_tag", "aws_ecr_repository.agent.name", "aws_ecr_repository.agent", "var.aws_profile", "var.aws_region", "aws_ecr_repository.agent.name", "aws_ecr_repository.agent", "aws_codebuild_project.agent_image.name", "aws_codebuild_project.agent_image", "var.aws_profile", "var.aws_region", "var.aws_profile", "var.aws_region", "aws_codebuild_project.agent_image.name", "aws_codebuild_project.agent_image", "var.aws_profile", "var.aws_region"]}}, "type": "local-exec"}], "schema_version": 0, "type": "null_resource"}, {"address": "data.aws_iam_policy_document.codebuild_assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["codebuild.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "codebuild_assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.codebuild_permissions", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.codebuild.arn", "aws_cloudwatch_log_group.codebuild"]}, "sid": {"constant_value": "Logs"}}, {"actions": {"constant_value": ["ecr:GetAuthorizationToken"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "EcrAuth"}}, {"actions": {"constant_value": ["ecr:BatchCheckLayerAvailability", "ecr:GetDownloadUrlForLayer", "ecr:BatchGetImage", "ecr:PutImage", "ecr:InitiateLayerUpload", "ecr:UploadLayerPart", "ecr:CompleteLayerUpload"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_ecr_repository.agent.arn", "aws_ecr_repository.agent"]}, "sid": {"constant_value": "EcrPush"}}, {"actions": {"constant_value": ["s3:GetObject", "s3:GetObjectVersion"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.source_bucket_arn", "var.source_key"]}, "sid": {"constant_value": "SourceObject"}}, {"actions": {"constant_value": ["kms:Decrypt", "kms:Encrypt", "kms:GenerateDataKey*", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.source_kms_key_arn"]}, "sid": {"constant_value": "ProjectKms"}}]}, "mode": "data", "name": "codebuild_permissions", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"agent_runtime_environment_variables": {"default": {}, "description": "Plaintext environment variables for the runtime. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "agent_runtime_name": {"default": "crm_agent_eval_runtime", "description": "Name for the AgentCore Runtime resource. Must satisfy the CreateAgentRuntime pattern [a-zA-Z][a-zA-Z0-9_]{0,47} -- no hyphens."}, "agent_runtime_role_arn": {"description": "Execution role ARN the AgentCore Runtime assumes to run the agent container."}, "aws_profile": {"default": "default", "description": "Named AWS CLI profile used by the in-apply CodeBuild trigger's `local-exec` provisioner."}, "aws_region": {"default": "us-east-1", "description": "AWS region for the AgentCore resources and the in-apply build trigger."}, "buildspec": {"description": "Inline buildspec for the CodeBuild project (Docker build + ECR push steps)."}, "cognito_allowed_audiences": {"description": "Accepted `aud` claim values for the CUSTOM_JWT authorizer."}, "cognito_allowed_client_ids": {"description": "App client ids accepted as valid callers by the CUSTOM_JWT authorizer."}, "cognito_allowed_scopes": {"default": [], "description": "Scopes required to be present on an inbound access token, enforced by the Gateway CUSTOM_JWT authorizer."}, "cognito_discovery_url": {"description": "Cognito user pool OIDC discovery URL, ending in /.well-known/openid-configuration."}, "cognito_required_custom_claims": {"default": [], "description": "Custom claims the Gateway CUSTOM_JWT authorizer requires on an inbound token, each matched by\nequality against one fixed `required_value` (for example a fixed `token_use` claim). Presence-only\nchecks are not expressible here; the interceptor's `decode_identity` rejects a token without the\nidentity claims. Defaults to empty.\n"}, "data_classification": {"description": "Value for the mandatory `data-classification` tag, applied per-resource (mirrors every sibling module's convention)."}, "ecr_repository_name": {"default": "crm-agent-eval-agent", "description": "Name of the ECR repository holding the agent container image."}, "gateway_name": {"default": "crm-agent-eval-gateway", "description": "Name for the AgentCore Gateway resource."}, "gateway_role_arn": {"description": "Execution role ARN the Gateway assumes, including to invoke each target Lambda via credential_provider_configuration.gateway_iam_role."}, "identity_interceptor_lambda_arn": {"description": "Invoke ARN of the identity_interceptor Lambda (src/gateway/identity_interceptor.py), attached as the Gateway's REQUEST interceptor."}, "identity_interceptor_lambda_function_name": {"description": "Function name of the identity_interceptor Lambda, used to grant this Gateway invoke permission in the function resource policy."}, "image_retention_count": {"default": 10, "description": "Number of most-recent tagged images retained by the ECR lifecycle policy."}, "image_tag": {"default": "latest", "description": "Tag applied to the image the agent_runtime resource consumes (e.g. a short content-hash-derived tag the caller mints alongside source_content_hash)."}, "kms_key_arn": {"description": "KMS customer-managed key ARN encrypting the ECR repository and the module's CloudWatch Logs log groups (runtime and CodeBuild) at rest."}, "log_retention_days": {"default": 365, "description": "Explicit CloudWatch Logs retention for the CodeBuild project's log group."}, "name_prefix": {"default": "crm-agent-eval", "description": "Prefix applied to the CodeBuild project, its IAM role, and its log group names."}, "platform_version": {"default": "V2", "description": "AgentCore Runtime `platformVersion`: \"V1\" or \"V2\". V2 restores each instance from a\nprepared snapshot; creates and updates take minutes. Switching either way is an in-place update.\nRollback: set \"V1\" and apply (docs/runbook.md).\n"}, "runtime_network_mode": {"default": "PUBLIC", "description": "AgentCore Runtime `networkMode`: \"PUBLIC\" or \"VPC\". VPC mode places the microVM's ENIs in the\nadopted VPC's Runtime subnets on a dedicated no-ingress security group; it governs egress only.\nDefaults to \"PUBLIC\"; the root composition sets \"VPC\" and wires the subnet and security-group\nvariables.\n"}, "runtime_security_group_ids": {"default": [], "description": "Security group ids for the Runtime's VPC-mode ENIs. Required (at least one) when\nruntime_network_mode is \"VPC\"; ignored under \"PUBLIC\". Must be the dedicated Runtime security group\n(no ingress, egress only to the endpoint security group and the gateway prefix lists), not the\nLambda security group.\n"}, "runtime_subnet_ids": {"default": [], "description": "Subnet ids for the Runtime's VPC-mode ENIs. Required (at least one) when runtime_network_mode is\n\"VPC\"; ignored under \"PUBLIC\". Set through the gitignored tfvars.\n\nEvery subnet must be in an AgentCore-supported AZ for the region (`infra/regions.json`);\n`scripts/preflight_adopted_vpc.sh` asserts that at deploy time.\n"}, "source_bucket_arn": {"description": "S3 bucket ARN holding the zipped agent source CodeBuild reads from as its `source`."}, "source_content_hash": {"description": "Content hash of the agent source tree, used as this module's `null_resource.image_build` trigger\nvalue. The image build re-runs when this value changes between applies.\n"}, "source_key": {"description": "S3 object key, within source_bucket_arn, of the zipped agent source archive."}, "source_kms_key_arn": {"description": "ARN of the customer-managed KMS key encrypting `source_bucket_arn`'s objects at rest, also used as\nthe CodeBuild project's `encryption_key`. The CodeBuild role is granted `kms:Decrypt`,\n`kms:Encrypt`, `kms:GenerateDataKey*` and `kms:DescribeKey` on exactly this key. The key's own\npolicy must also admit `aws_iam_role.codebuild` (or a broader principal it belongs to).\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-resource override or addition."}, "tool_lambda_arns": {"description": "Map of tool_name -> that tool's action Lambda ARN (`module.lambda_action[tool_name].function_arn`),\none entry per tool in `crm.toolspec.definitions.ALL_TOOLS`. Each entry produces exactly one gateway\ntarget. Its keys are a superset of the `api` module's tool routes: `get_page_context` is reachable\nby the agents and the Gateway but has no HTTP route (`local.agent_only_tools` in `infra/main.tf`).\nThat the key set equals `ALL_TOOLS` is `scripts/check_toolspec_parity.py`'s check on\n`local.tools`, which this map is built from.\n"}, "tool_schemas": {"description": "Map of tool_name -> that tool's flattened MCP tool schema, for the required\n`target_configuration.mcp.lambda.tool_schema` block of each `aws_bedrockagentcore_gateway_target`.\nCarries exactly the keys of `tool_lambda_arns`; the gateway target resource's precondition fails\nthe plan otherwise.\n\nThe root composition derives each entry's `description` and `properties` from\n`crm.toolspec.definitions.ALL_TOOLS[tool_name]` (`.description` and the top-level keys of\n`.input_schema[\"properties\"]`).\n\nOnly top-level scalar properties, and arrays of scalars, are expressible; a property whose type is\n`object`, or an array of objects, needs this variable's shape extended.\n"}}}, "source": "./modules/agentcore"}, "api": {"expressions": {"access_log_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "api_name": {"constant_value": "crm-agent-eval-api"}, "cognito_user_pool_arn": {"references": ["module.cognito.user_pool_arn", "module.cognito"]}, "extra_routes": {"references": ["module.lambda_action_eval_trigger.invoke_arn", "module.lambda_action_eval_trigger", "module.lambda_action_eval_trigger.function_name", "module.lambda_action_eval_trigger", "module.lambda_action_capabilities.invoke_arn", "module.lambda_action_capabilities", "module.lambda_action_capabilities.function_name", "module.lambda_action_capabilities", "module.lambda_action_user_settings.invoke_arn", "module.lambda_action_user_settings", "module.lambda_action_user_settings.function_name", "module.lambda_action_user_settings"]}, "log_retention_days": {"constant_value": 365}, "stage_name": {"constant_value": "prod"}, "tool_lambda_function_names": {"references": ["local.routed_tool_names", "module.lambda_action"]}, "tool_lambda_invoke_arns": {"references": ["local.routed_tool_names", "module.lambda_action"]}, "vpc_endpoint_ids": {"references": ["module.vpc.execute_api_vpc_endpoint_id", "module.vpc"]}}, "module": {"outputs": {"access_log_group_name": {"description": "CloudWatch Logs group name receiving API Gateway access logs.", "expression": {"references": ["aws_cloudwatch_log_group.access_logs.name", "aws_cloudwatch_log_group.access_logs"]}}, "api_id": {"description": "Private REST API id.", "expression": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}}, "authorizer_id": {"description": "Cognito authorizer id \u2014 every method in this module references this one authorizer; exposed for the Layer 3 gate's authorizer-coverage assertion.", "expression": {"references": ["aws_api_gateway_authorizer.cognito.id", "aws_api_gateway_authorizer.cognito"]}}, "execution_arn": {"description": "API execution ARN, for Lambda resource-policy `source_arn` patterns outside this module if needed.", "expression": {"references": ["aws_api_gateway_rest_api.this.execution_arn", "aws_api_gateway_rest_api.this"]}}, "private_origin_domain_name": {"description": "Hostname for the CloudFront `/api/*` origin's `domain_name` (`-.execute-api..amazonaws.com`). Sent as the Host header to the private API; requires no custom domain and no `x-apigw-api-id`. Uses the first entry of `vpc_endpoint_ids`.", "expression": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this", "var.vpc_endpoint_ids[0]", "var.vpc_endpoint_ids", "data.aws_region.current.region", "data.aws_region.current"]}}, "route_tool_names": {"description": "Sorted list of the tool names this module generated routes for, derived from `var.tool_lambda_invoke_arns`'s keys \u2014 for the Layer 3 gate to diff against `crm.toolspec.definitions.ALL_TOOLS`.", "expression": {"references": ["local.tool_names"]}}, "stage_invoke_url": {"description": "Full invoke URL for the deployed stage. For this private API it is reachable only from inside the VPC through a named interface endpoint; it is not a publicly callable URL.", "expression": {"references": ["aws_api_gateway_stage.this.invoke_url", "aws_api_gateway_stage.this"]}}, "stage_name": {"description": "Deployed stage name. Every route is served beneath it (`//`), so a path-prefixed CloudFront behaviour in front of this API rewrites onto the stage path.", "expression": {"references": ["aws_api_gateway_stage.this.stage_name", "aws_api_gateway_stage.this"]}}, "vpc_endpoint_ids": {"description": "The `execute-api` interface endpoint ids this API is associated with and whose `aws:sourceVpce` its resource policy allows.", "expression": {"references": ["var.vpc_endpoint_ids"]}}}, "resources": [{"address": "aws_api_gateway_authorizer.cognito", "expressions": {"identity_source": {"constant_value": "method.request.header.Authorization"}, "name": {"constant_value": "cognito-user-pools"}, "provider_arns": {"references": ["var.cognito_user_pool_arn"]}, "rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}, "type": {"constant_value": "COGNITO_USER_POOLS"}}, "mode": "managed", "name": "cognito", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_authorizer"}, {"address": "aws_api_gateway_deployment.this", "depends_on": ["aws_api_gateway_method.tool", "aws_api_gateway_integration.tool", "aws_api_gateway_request_validator.body_and_params", "aws_api_gateway_model.json_object"], "expressions": {"rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}, "triggers": {"references": ["local.deployment_trigger"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_deployment"}, {"address": "aws_api_gateway_integration.tool", "expressions": {"http_method": {"references": ["aws_api_gateway_method.tool", "each.key"]}, "integration_http_method": {"constant_value": "POST"}, "resource_id": {"references": ["aws_api_gateway_resource.tool", "each.key"]}, "rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}, "type": {"constant_value": "AWS_PROXY"}, "uri": {"references": ["each.value"]}}, "for_each_expression": {"references": ["local.route_invoke_arns"]}, "mode": "managed", "name": "tool", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_integration"}, {"address": "aws_api_gateway_method.tool", "expressions": {"authorization": {"constant_value": "COGNITO_USER_POOLS"}, "authorizer_id": {"references": ["aws_api_gateway_authorizer.cognito.id", "aws_api_gateway_authorizer.cognito"]}, "http_method": {"references": ["local.route_methods", "each.key"]}, "request_models": {"references": ["local.route_methods", "each.key", "aws_api_gateway_model.json_object.name", "aws_api_gateway_model.json_object"]}, "request_validator_id": {"references": ["aws_api_gateway_request_validator.body_and_params.id", "aws_api_gateway_request_validator.body_and_params"]}, "resource_id": {"references": ["aws_api_gateway_resource.tool", "each.key"]}, "rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}}, "for_each_expression": {"references": ["local.route_invoke_arns"]}, "mode": "managed", "name": "tool", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_method"}, {"address": "aws_api_gateway_method_settings.this", "expressions": {"method_path": {"constant_value": "*/*"}, "rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}, "settings": [{"throttling_burst_limit": {"references": ["var.throttle_burst_limit"]}, "throttling_rate_limit": {"references": ["var.throttle_rate_limit"]}}], "stage_name": {"references": ["aws_api_gateway_stage.this.stage_name", "aws_api_gateway_stage.this"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_method_settings"}, {"address": "aws_api_gateway_model.json_object", "expressions": {"content_type": {"constant_value": "application/json"}, "name": {"constant_value": "JsonObject"}, "rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}, "schema": {}}, "mode": "managed", "name": "json_object", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_model"}, {"address": "aws_api_gateway_request_validator.body_and_params", "expressions": {"name": {"constant_value": "body-and-params"}, "rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}, "validate_request_body": {"constant_value": true}, "validate_request_parameters": {"constant_value": true}}, "mode": "managed", "name": "body_and_params", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_request_validator"}, {"address": "aws_api_gateway_resource.tool", "expressions": {"parent_id": {"references": ["aws_api_gateway_rest_api.this.root_resource_id", "aws_api_gateway_rest_api.this"]}, "path_part": {"references": ["each.key"]}, "rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}}, "for_each_expression": {"references": ["local.route_invoke_arns"]}, "mode": "managed", "name": "tool", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_resource"}, {"address": "aws_api_gateway_rest_api.this", "expressions": {"endpoint_configuration": [{"types": {"constant_value": ["PRIVATE"]}, "vpc_endpoint_ids": {"references": ["var.vpc_endpoint_ids"]}}], "name": {"references": ["var.api_name"]}, "policy": {"references": ["data.aws_iam_policy_document.resource_policy.json", "data.aws_iam_policy_document.resource_policy"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_rest_api"}, {"address": "aws_api_gateway_stage.this", "expressions": {"access_log_settings": [{"destination_arn": {"references": ["aws_cloudwatch_log_group.access_logs.arn", "aws_cloudwatch_log_group.access_logs"]}, "format": {}}], "deployment_id": {"references": ["aws_api_gateway_deployment.this.id", "aws_api_gateway_deployment.this"]}, "rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}, "stage_name": {"references": ["var.stage_name"]}, "tags": {"references": ["var.tags"]}, "xray_tracing_enabled": {"constant_value": true}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_stage"}, {"address": "aws_cloudwatch_log_group.access_logs", "expressions": {"kms_key_id": {"references": ["var.access_log_kms_key_arn"]}, "name": {"references": ["var.api_name"]}, "retention_in_days": {"references": ["var.log_retention_days"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "access_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_lambda_permission.apigw_invoke", "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["each.value"]}, "principal": {"constant_value": "apigateway.amazonaws.com"}, "source_arn": {"references": ["aws_api_gateway_rest_api.this.execution_arn", "aws_api_gateway_rest_api.this", "local.route_methods", "each.key", "each.key"]}, "statement_id": {"references": ["each.key"]}}, "for_each_expression": {"references": ["local.route_function_names"]}, "mode": "managed", "name": "apigw_invoke", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.resource_policy", "expressions": {"statement": [{"actions": {"constant_value": ["execute-api:Invoke"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"constant_value": ["execute-api:/*"]}, "sid": {"constant_value": "AllowInvokeFromNamedVpcEndpointsOnly"}}, {"actions": {"constant_value": ["execute-api:Invoke"]}, "condition": [{"test": {"constant_value": "StringNotEquals"}, "values": {"references": ["var.vpc_endpoint_ids"]}, "variable": {"constant_value": "aws:sourceVpce"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"constant_value": ["execute-api:/*"]}, "sid": {"constant_value": "DenyInvokeFromAnyOtherVpcEndpoint"}}]}, "mode": "data", "name": "resource_policy", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_region.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_region"}], "variables": {"access_log_kms_key_arn": {"description": "KMS customer-managed key ARN encrypting the API Gateway access log group at rest."}, "api_name": {"default": "crm-agent-eval-api", "description": "Name for the REST API."}, "cognito_user_pool_arn": {"description": "ARN of the Cognito user pool whose tokens the authorizer accepts (the `cognito` module user pool ARN output). A COGNITO_USER_POOLS authorizer validates that the token was issued by this pool; it does not validate the app-client audience."}, "extra_routes": {"default": {}, "description": "Routes that are not toolspec tools, and so are absent from `tool_lambda_invoke_arns`. Merged with\nthe tool map into the single local that generates every integration, route and permission, so\nthese carry the Cognito authorizer on the same terms as the tool routes.\n\nThe permitted keys are the allowlist validated below (`eval_trigger`, `capabilities`, `user_settings`).\n\n`method` is the HTTP method the client calls and defaults to `POST`; `capabilities` is a browser\n`GET` (`frontend/src/components/tuning/capabilityMatrix.ts`). The Lambda integration method is\nalways `POST` for `AWS_PROXY`, whatever the client method.\n"}, "log_retention_days": {"default": 365, "description": "Explicit CloudWatch Logs retention for the API Gateway access log group."}, "stage_name": {"default": "prod", "description": "API Gateway stage name."}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-resource override or addition."}, "throttle_burst_limit": {"default": 50, "description": "Per-route burst limit (concurrent requests) enforced at the default-route throttle setting."}, "throttle_rate_limit": {"default": 25, "description": "Per-route steady-state rate limit (requests/second) enforced at the default-route throttle setting."}, "tool_lambda_function_names": {"description": "Map of tool_name -> that tool's action Lambda function name\n(`module.lambda_action[tool_name].function_name`), used to grant API Gateway\n`lambda:InvokeFunction` per function. Carries exactly the key set of `tool_lambda_invoke_arns`;\nthe REST API resource's precondition fails the plan otherwise.\n"}, "tool_lambda_invoke_arns": {"description": "Map of tool_name -> that tool's action Lambda invoke ARN (`module.lambda_action[tool_name].invoke_arn`),\none entry per routed tool in `crm.toolspec.definitions.ALL_TOOLS`. Every route, integration and\nauthorizer attachment is generated from this map (see `main.tf`). Must not be empty.\n"}, "vpc_endpoint_ids": {"description": "The `execute-api` interface VPC endpoint ids this private API is reachable through. Sets `endpoint_configuration.vpc_endpoint_ids` and is the allowlist in the API resource policy."}}}, "source": "./modules/api"}, "api_origin": {"expressions": {"access_logs_bucket": {"references": ["module.frontend_cdn.logs_bucket_name", "module.frontend_cdn"]}, "access_logs_prefix": {"references": ["local.alb_access_log_prefix"]}, "alb_ingress_security_group_ids": {"references": ["var.api_origin_ingress_security_group_ids"]}, "execute_api_security_group_id": {"references": ["module.vpc.execute_api_security_group_id", "module.vpc"]}, "execute_api_target_ips": {"references": ["data.aws_network_interface.execute_api"]}, "name_prefix": {"references": ["local.name_prefix"]}, "private_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}, "tags": {"references": ["var.data_classification"]}, "vpc_id": {"references": ["module.vpc.vpc_id", "module.vpc"]}}, "module": {"outputs": {"alb_arn": {"description": "Internal ALB ARN. The VPC origin references the ALB by this ARN, which is how CloudFront routes without resolving the origin's domain name.", "expression": {"references": ["aws_lb.this.arn", "aws_lb.this"]}}, "alb_dns_name": {"description": "Internal ALB DNS name, for diagnostics only. It is not the CloudFront origin `domain_name`, which is `module.api.private_origin_domain_name`: API Gateway routes the private API on that Host header.", "expression": {"references": ["aws_lb.this.dns_name", "aws_lb.this"]}}, "alb_security_group_id": {"description": "The ALB's security group id, for asserting its ingress source and single scoped egress.", "expression": {"references": ["aws_security_group.alb.id", "aws_security_group.alb"]}}, "listener_protocol": {"description": "The listener protocol configured on the ALB, for a check asserting the deployed `HTTP` listener.", "expression": {"references": ["aws_lb_listener.this.protocol", "aws_lb_listener.this"]}}, "target_group_arn": {"description": "Target group holding the execute-api endpoint ENI IPs, for the T3 check to assert target health from.", "expression": {"references": ["aws_lb_target_group.execute_api.arn", "aws_lb_target_group.execute_api"]}}, "vpc_origin_id": {"description": "Id of the CloudFront VPC origin. Goes into the distribution origin's `vpc_origin_config.vpc_origin_id` for the `/api/*` behaviour.", "expression": {"references": ["aws_cloudfront_vpc_origin.this.id", "aws_cloudfront_vpc_origin.this"]}}}, "resources": [{"address": "aws_cloudfront_vpc_origin.this", "expressions": {"tags": {"references": ["var.tags"]}, "vpc_origin_endpoint_config": [{"arn": {"references": ["aws_lb.this.arn", "aws_lb.this"]}, "http_port": {"references": ["var.listener_port"]}, "https_port": {"constant_value": 443}, "name": {"references": ["var.name_prefix"]}, "origin_protocol_policy": {"references": ["var.origin_protocol_policy"]}, "origin_ssl_protocols": [{"items": {"constant_value": ["TLSv1.2"]}, "quantity": {"constant_value": 1}}]}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_vpc_origin"}, {"address": "aws_lb.this", "expressions": {"access_logs": [{"bucket": {"references": ["var.access_logs_bucket"]}, "enabled": {"constant_value": true}, "prefix": {"references": ["var.access_logs_prefix"]}}], "drop_invalid_header_fields": {"constant_value": true}, "enable_deletion_protection": {"constant_value": true}, "internal": {"constant_value": true}, "load_balancer_type": {"constant_value": "application"}, "name": {"references": ["var.name_prefix"]}, "security_groups": {"references": ["aws_security_group.alb.id", "aws_security_group.alb"]}, "subnets": {"references": ["var.private_subnet_ids"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lb"}, {"address": "aws_lb_listener.this", "expressions": {"default_action": [{"target_group_arn": {"references": ["aws_lb_target_group.execute_api.arn", "aws_lb_target_group.execute_api"]}, "type": {"constant_value": "forward"}}], "load_balancer_arn": {"references": ["aws_lb.this.arn", "aws_lb.this"]}, "port": {"references": ["var.listener_port"]}, "protocol": {"references": ["var.listener_protocol"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lb_listener"}, {"address": "aws_lb_target_group.execute_api", "expressions": {"health_check": [{"healthy_threshold": {"constant_value": 2}, "interval": {"constant_value": 30}, "matcher": {"constant_value": "200,403"}, "path": {"constant_value": "/"}, "protocol": {"constant_value": "HTTPS"}, "timeout": {"constant_value": 5}, "unhealthy_threshold": {"constant_value": 2}}], "name": {"references": ["var.name_prefix"]}, "port": {"constant_value": 443}, "protocol": {"constant_value": "HTTPS"}, "tags": {"references": ["var.tags"]}, "target_type": {"constant_value": "ip"}, "vpc_id": {"references": ["var.vpc_id"]}}, "mode": "managed", "name": "execute_api", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lb_target_group"}, {"address": "aws_lb_target_group_attachment.execute_api", "count_expression": {"references": ["var.private_subnet_ids"]}, "expressions": {"port": {"constant_value": 443}, "target_group_arn": {"references": ["aws_lb_target_group.execute_api.arn", "aws_lb_target_group.execute_api"]}, "target_id": {"references": ["var.execute_api_target_ips", "count.index"]}}, "mode": "managed", "name": "execute_api", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lb_target_group_attachment"}, {"address": "aws_security_group.alb", "expressions": {"description": {"constant_value": "Internal ALB fronting the private REST API for the CloudFront /api/* VPC origin"}, "name": {"references": ["var.name_prefix"]}, "tags": {"references": ["var.tags", "var.name_prefix"]}, "vpc_id": {"references": ["var.vpc_id"]}}, "mode": "managed", "name": "alb", "provider_config_key": "aws", "schema_version": 1, "type": "aws_security_group"}, {"address": "aws_vpc_security_group_egress_rule.alb_to_endpoint", "expressions": {"description": {"constant_value": "internal ALB to execute-api interface endpoint (443, TLS)"}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "referenced_security_group_id": {"references": ["var.execute_api_security_group_id"]}, "security_group_id": {"references": ["aws_security_group.alb.id", "aws_security_group.alb"]}, "to_port": {"constant_value": 443}}, "mode": "managed", "name": "alb_to_endpoint", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_egress_rule"}, {"address": "aws_vpc_security_group_ingress_rule.alb_from_cloudfront", "expressions": {"description": {"references": ["var.listener_port"]}, "from_port": {"references": ["var.listener_port"]}, "ip_protocol": {"constant_value": "tcp"}, "referenced_security_group_id": {"references": ["each.value"]}, "security_group_id": {"references": ["aws_security_group.alb.id", "aws_security_group.alb"]}, "to_port": {"references": ["var.listener_port"]}}, "for_each_expression": {"references": ["var.alb_ingress_security_group_ids"]}, "mode": "managed", "name": "alb_from_cloudfront", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_ingress_rule"}], "variables": {"access_logs_bucket": {"description": "S3 bucket receiving ALB access logs. Required."}, "access_logs_prefix": {"description": "Key prefix the ALB writes access logs under. No default; it must equal the prefix in the destination bucket policy grant (`//AWSLogs//*`). The root passes one local to both sides."}, "alb_ingress_security_group_ids": {"description": "Security group ids permitted to reach the ALB listener port: the security group the deployed CloudFront VPC origin presents. No default; see the first-deployment steps in `docs/runbook.md`."}, "execute_api_security_group_id": {"description": "Security group id of the `execute-api` interface endpoint, the ALB single egress destination on 443."}, "execute_api_target_ips": {"description": "Private IPv4 addresses of the `execute-api` interface endpoint's ENIs, one per entry in `private_subnet_ids`, resolved in the root. Registered as the target group's IP targets."}, "listener_port": {"default": 80, "description": "ALB listener port. 80 with the `http-only` origin protocol policy; 443 only if an origin certificate exists, which requires a domain the owner controls."}, "listener_protocol": {"default": "HTTP", "description": "ALB listener protocol. `HTTP` on the CloudFront->ALB hop: an accepted deviation from encryption-in-transit on that hop only. The ALB->endpoint hop is HTTPS regardless."}, "name_prefix": {"description": "Resource name prefix, from the root's `local.name_prefix`."}, "origin_protocol_policy": {"default": "http-only", "description": "How CloudFront connects to the VPC origin. Defaults to `http-only`; `match-viewer` is rejected by validation, since the viewer is always HTTPS and this stack has no origin certificate."}, "private_subnet_ids": {"description": "Private subnet ids for the ALB. Also fixes the plan-time count of endpoint ENIs, since the interface endpoint places one ENI per subnet (see the `count` note in main.tf)."}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-resource override or addition."}, "vpc_id": {"description": "Id of the adopted VPC the ALB and target group live in (`modules/vpc`'s vpc id output)."}}}, "source": "./modules/api_origin"}, "cognito": {"expressions": {"mcp_client_generate_secret": {"constant_value": true}, "pre_token_generation_lambda_arn": {"references": ["module.lambda_action_pre_token_generation.function_arn", "module.lambda_action_pre_token_generation"]}, "pre_token_generation_lambda_function_name": {"references": ["module.lambda_action_pre_token_generation.function_name", "module.lambda_action_pre_token_generation"]}, "spa_callback_urls": {"references": ["module.frontend_cdn.distribution_domain_name", "module.frontend_cdn"]}, "spa_logout_urls": {"references": ["module.frontend_cdn.distribution_domain_name", "module.frontend_cdn"]}, "user_pool_name": {"constant_value": "crm-agent-eval"}}, "module": {"outputs": {"admin_group_name": {"description": "Name of the Cognito group whose members are admin.", "expression": {"references": ["aws_cognito_user_group.admin.name", "aws_cognito_user_group.admin"]}}, "allowed_client_ids": {"description": "The SPA and MCP app client ids, for Gateway #1's authorizer and interceptor `COGNITO_ALLOWED_CLIENT_IDS`. Excludes the MCP OAuth client.", "expression": {"references": ["aws_cognito_user_pool_client.spa.id", "aws_cognito_user_pool_client.spa", "aws_cognito_user_pool_client.mcp.id", "aws_cognito_user_pool_client.mcp"]}}, "chat_gateway_allowed_client_ids": {"description": "`allowed_client_ids` plus the MCP OAuth client: Gateway #2's authorizer `allowed_clients` and its interceptor's `COGNITO_ALLOWED_CLIENT_IDS`.", "expression": {"references": ["aws_cognito_user_pool_client.spa.id", "aws_cognito_user_pool_client.spa", "aws_cognito_user_pool_client.mcp.id", "aws_cognito_user_pool_client.mcp", "aws_cognito_user_pool_client.mcp_oauth.id", "aws_cognito_user_pool_client.mcp_oauth"]}}, "chat_scope_identifier": {"description": "Gateway #2's own `supervisor/chat` scope: its `CUSTOM_JWT` `allowedScopes`, the pre-token trigger's and interceptor's `CHAT_SCOPE`. Distinct from `gateway_scope_identifier`.", "expression": {"references": ["aws_cognito_resource_server.supervisor.scope_identifiers[0]", "aws_cognito_resource_server.supervisor.scope_identifiers", "aws_cognito_resource_server.supervisor"]}}, "domain": {"description": "Cognito user pool prefix domain (no custom ACM certificate). The base for the `/oauth2/token` token endpoint the MCP `client_credentials` flow mints against.", "expression": {"references": ["aws_cognito_user_pool_domain.this.domain", "aws_cognito_user_pool_domain.this"]}}, "gateway_scope_identifier": {"description": "Fully-qualified `/` custom scope\n(`aws_cognito_resource_server.gateway.scope_identifiers[0]`) that the MCP app client's\n`client_credentials` token carries, and the value the AgentCore Gateway's `CUSTOM_JWT` authorizer\nallows (`allowedScopes`). The root composition consumes this output for both.\n", "expression": {"references": ["aws_cognito_resource_server.gateway.scope_identifiers[0]", "aws_cognito_resource_server.gateway.scope_identifiers", "aws_cognito_resource_server.gateway"]}}, "mcp_client_id": {"description": "App client id for MCP clients (confidential client).", "expression": {"references": ["aws_cognito_user_pool_client.mcp.id", "aws_cognito_user_pool_client.mcp"]}}, "mcp_client_secret": {"description": "App client secret for the MCP client. Sensitive; held in Terraform state and the gitignored results/tf-outputs.json, never in a tracked file. This stack creates no Secrets Manager entry for it.", "expression": {"references": ["aws_cognito_user_pool_client.mcp.client_secret", "aws_cognito_user_pool_client.mcp"]}, "sensitive": true}, "mcp_oauth_client_id": {"description": "App client id for interactive MCP OAuth clients (public client, no secret; Gateway #2 only).", "expression": {"references": ["aws_cognito_user_pool_client.mcp_oauth.id", "aws_cognito_user_pool_client.mcp_oauth"]}}, "spa_client_id": {"description": "App client id for the SPA (public client, no secret).", "expression": {"references": ["aws_cognito_user_pool_client.spa.id", "aws_cognito_user_pool_client.spa"]}}, "user_pool_arn": {"description": "Cognito user pool ARN.", "expression": {"references": ["aws_cognito_user_pool.this.arn", "aws_cognito_user_pool.this"]}}, "user_pool_endpoint": {"description": "Cognito user pool endpoint, used to derive the OIDC discovery and JWKS URLs.", "expression": {"references": ["aws_cognito_user_pool.this.endpoint", "aws_cognito_user_pool.this"]}}, "user_pool_id": {"description": "Cognito user pool id.", "expression": {"references": ["aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}}}, "resources": [{"address": "aws_cognito_resource_server.gateway", "expressions": {"identifier": {"constant_value": "gateway"}, "name": {"constant_value": "AgentCore Gateway"}, "scope": [{"scope_description": {"constant_value": "Invoke the AgentCore Gateway MCP surface machine-to-machine."}, "scope_name": {"constant_value": "invoke"}}], "user_pool_id": {"references": ["aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}}, "mode": "managed", "name": "gateway", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cognito_resource_server"}, {"address": "aws_cognito_resource_server.supervisor", "expressions": {"identifier": {"constant_value": "supervisor"}, "name": {"constant_value": "AgentCore chat Gateway"}, "scope": [{"scope_description": {"constant_value": "Call chat_with_supervisor on the MCP chat Gateway."}, "scope_name": {"constant_value": "chat"}}], "user_pool_id": {"references": ["aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}}, "mode": "managed", "name": "supervisor", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cognito_resource_server"}, {"address": "aws_cognito_user_group.admin", "expressions": {"description": {"constant_value": "CRM eval administrators: live sweeps, cancel and unlock."}, "name": {"constant_value": "admin"}, "user_pool_id": {"references": ["aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}}, "mode": "managed", "name": "admin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cognito_user_group"}, {"address": "aws_cognito_user_pool.this", "expressions": {"account_recovery_setting": [{"recovery_mechanism": [{"name": {"constant_value": "verified_email"}, "priority": {"constant_value": 1}}]}], "admin_create_user_config": [{"allow_admin_create_user_only": {"constant_value": true}}], "auto_verified_attributes": {"constant_value": ["email"]}, "lambda_config": [{"pre_token_generation_config": [{"lambda_arn": {"references": ["var.pre_token_generation_lambda_arn"]}, "lambda_version": {"constant_value": "V2_0"}}]}], "mfa_configuration": {"references": ["var.mfa_configuration"]}, "name": {"references": ["var.user_pool_name"]}, "password_policy": [{"minimum_length": {"constant_value": 14}, "require_lowercase": {"constant_value": true}, "require_numbers": {"constant_value": true}, "require_symbols": {"constant_value": true}, "require_uppercase": {"constant_value": true}, "temporary_password_validity_days": {"constant_value": 7}}], "schema": [{"attribute_data_type": {"constant_value": "String"}, "mutable": {"constant_value": true}, "name": {"constant_value": "rep_id"}, "string_attribute_constraints": [{"max_length": {"constant_value": "128"}, "min_length": {"constant_value": "1"}}]}, {"attribute_data_type": {"constant_value": "String"}, "mutable": {"constant_value": true}, "name": {"constant_value": "book"}, "string_attribute_constraints": [{"max_length": {"constant_value": "2048"}, "min_length": {"constant_value": "0"}}]}, {"attribute_data_type": {"constant_value": "String"}, "mutable": {"constant_value": true}, "name": {"constant_value": "full_visibility"}, "string_attribute_constraints": [{"max_length": {"constant_value": "8"}, "min_length": {"constant_value": "1"}}]}, {"attribute_data_type": {"constant_value": "String"}, "mutable": {"constant_value": true}, "name": {"constant_value": "tenant"}, "string_attribute_constraints": [{"max_length": {"constant_value": "128"}, "min_length": {"constant_value": "1"}}]}], "software_token_mfa_configuration": [{"enabled": {"constant_value": true}}], "user_pool_tier": {"constant_value": "ESSENTIALS"}, "username_attributes": {"constant_value": ["email"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cognito_user_pool"}, {"address": "aws_cognito_user_pool_client.mcp", "expressions": {"access_token_validity": {"constant_value": 5}, "allowed_oauth_flows": {"constant_value": ["client_credentials"]}, "allowed_oauth_flows_user_pool_client": {"constant_value": true}, "allowed_oauth_scopes": {"references": ["aws_cognito_resource_server.gateway.scope_identifiers[0]", "aws_cognito_resource_server.gateway.scope_identifiers", "aws_cognito_resource_server.gateway", "aws_cognito_resource_server.supervisor.scope_identifiers[0]", "aws_cognito_resource_server.supervisor.scope_identifiers", "aws_cognito_resource_server.supervisor"]}, "enable_token_revocation": {"constant_value": true}, "explicit_auth_flows": {"constant_value": ["ALLOW_REFRESH_TOKEN_AUTH"]}, "generate_secret": {"references": ["var.mcp_client_generate_secret"]}, "name": {"constant_value": "crm-agent-eval-mcp"}, "prevent_user_existence_errors": {"constant_value": "ENABLED"}, "read_attributes": {"references": ["local.writable_profile_attributes", "local.scope_bearing_attributes"]}, "supported_identity_providers": {"constant_value": ["COGNITO"]}, "token_validity_units": [{"access_token": {"constant_value": "minutes"}}], "user_pool_id": {"references": ["aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}, "write_attributes": {"references": ["local.writable_profile_attributes"]}}, "mode": "managed", "name": "mcp", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cognito_user_pool_client"}, {"address": "aws_cognito_user_pool_client.mcp_oauth", "expressions": {"access_token_validity": {"constant_value": 1}, "allowed_oauth_flows": {"constant_value": ["code"]}, "allowed_oauth_flows_user_pool_client": {"constant_value": true}, "allowed_oauth_scopes": {"references": ["aws_cognito_resource_server.supervisor.scope_identifiers[0]", "aws_cognito_resource_server.supervisor.scope_identifiers", "aws_cognito_resource_server.supervisor"]}, "callback_urls": {"constant_value": ["http://localhost:6274/oauth/callback", "http://localhost:6274/oauth/callback/debug", "http://localhost:33418/callback"]}, "enable_token_revocation": {"constant_value": true}, "explicit_auth_flows": {"constant_value": ["ALLOW_REFRESH_TOKEN_AUTH"]}, "generate_secret": {"constant_value": false}, "id_token_validity": {"constant_value": 1}, "name": {"constant_value": "crm-agent-eval-mcp-oauth"}, "prevent_user_existence_errors": {"constant_value": "ENABLED"}, "read_attributes": {"references": ["local.writable_profile_attributes", "local.scope_bearing_attributes"]}, "refresh_token_validity": {"constant_value": 30}, "supported_identity_providers": {"constant_value": ["COGNITO"]}, "token_validity_units": [{"access_token": {"constant_value": "hours"}, "id_token": {"constant_value": "hours"}, "refresh_token": {"constant_value": "days"}}], "user_pool_id": {"references": ["aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}, "write_attributes": {"references": ["local.writable_profile_attributes"]}}, "mode": "managed", "name": "mcp_oauth", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cognito_user_pool_client"}, {"address": "aws_cognito_user_pool_client.spa", "expressions": {"access_token_validity": {"constant_value": 1}, "allowed_oauth_flows": {"constant_value": ["code"]}, "allowed_oauth_flows_user_pool_client": {"constant_value": true}, "allowed_oauth_scopes": {"constant_value": ["openid", "email", "profile"]}, "callback_urls": {"references": ["var.spa_callback_urls"]}, "enable_token_revocation": {"constant_value": true}, "explicit_auth_flows": {"constant_value": ["ALLOW_USER_SRP_AUTH", "ALLOW_REFRESH_TOKEN_AUTH", "ALLOW_ADMIN_USER_PASSWORD_AUTH"]}, "generate_secret": {"constant_value": false}, "id_token_validity": {"constant_value": 1}, "logout_urls": {"references": ["var.spa_logout_urls"]}, "name": {"constant_value": "crm-agent-eval-spa"}, "prevent_user_existence_errors": {"constant_value": "ENABLED"}, "read_attributes": {"references": ["local.writable_profile_attributes", "local.scope_bearing_attributes"]}, "refresh_token_validity": {"constant_value": 30}, "supported_identity_providers": {"constant_value": ["COGNITO"]}, "token_validity_units": [{"access_token": {"constant_value": "hours"}, "id_token": {"constant_value": "hours"}, "refresh_token": {"constant_value": "days"}}], "user_pool_id": {"references": ["aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}, "write_attributes": {"references": ["local.writable_profile_attributes"]}}, "mode": "managed", "name": "spa", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cognito_user_pool_client"}, {"address": "aws_cognito_user_pool_domain.this", "expressions": {"domain": {"references": ["var.user_pool_name", "aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}, "user_pool_id": {"references": ["aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cognito_user_pool_domain"}, {"address": "aws_lambda_permission.pre_token_generation", "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["var.pre_token_generation_lambda_function_name"]}, "principal": {"constant_value": "cognito-idp.amazonaws.com"}, "source_arn": {"references": ["aws_cognito_user_pool.this.arn", "aws_cognito_user_pool.this"]}, "statement_id": {"constant_value": "AllowCognitoInvokePreTokenGeneration"}}, "mode": "managed", "name": "pre_token_generation", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}], "variables": {"mcp_client_generate_secret": {"default": true, "description": "Whether the MCP app client is confidential (generates a client secret) and uses\n`client_credentials`. Defaults to true: the MCP client is a machine-to-machine caller. The stack\ncreates no Secrets Manager entry for the secret; see docs/mcp-client-guide.md.\n"}, "mfa_configuration": {"default": "OPTIONAL", "description": "Pool-level MFA enforcement. Defaults to `OPTIONAL`; the SPA does not implement TOTP enrollment, so\n`ON` makes interactive sign-in through the deployed frontend impossible. TOTP stays enabled either\nway, so a user who enrolls is still challenged.\n\n`OFF` is rejected by validation. Set `ON` once the frontend can complete\n`MFA_SETUP`/`SOFTWARE_TOKEN_MFA`.\n"}, "pre_token_generation_lambda_arn": {"description": "ARN of the pre-token-generation Lambda (V2 event) that stamps `custom:rep_id`,\n`custom:book`, `custom:full_visibility`, and `custom:tenant` into the access\ntoken. Created by the root composition and passed in.\n"}, "pre_token_generation_lambda_function_name": {"description": "Name of the pre-token-generation Lambda, used to scope the\n`aws_lambda_permission` that lets Cognito invoke it. Must be the function\nbehind `pre_token_generation_lambda_arn`.\n"}, "spa_callback_urls": {"description": "Allowed OAuth callback URLs for the SPA app client."}, "spa_logout_urls": {"description": "Allowed OAuth sign-out redirect URLs for the SPA app client."}, "user_pool_name": {"default": "crm-agent-eval", "description": "Name for the Cognito user pool."}}}, "source": "./modules/cognito"}, "dynamodb": {"expressions": {"account_id": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "administrator_principal_arns": {"references": ["var.crm_operator_principal_arns", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "caller_principal_arn": {"references": ["data.aws_iam_session_context.current.issuer_arn", "data.aws_iam_session_context.current"]}, "data_classification": {"references": ["var.data_classification"]}, "data_plane_principal_arns": {"references": ["local.dynamodb_data_plane_role_arns", "var.crm_operator_principal_arns"]}, "name_prefix": {"references": ["local.name_prefix"]}}, "module": {"outputs": {"gsi_arns": {"description": "Map of logical table name to a map of GSI name to that index's full ARN\n(`/index/`). Consumed by `infra/main.tf`'s per-tool\n`dynamodb_grants[].index_arns`: every `dynamodb:Query` in this schema targets a named GSI (see\n`crm.store.store.query_gsi`), so the grant names the index ARN.\n", "expression": {"references": ["local.tables"]}}, "kms_key_arn": {"description": "ARN of the customer-managed KMS key encrypting all eleven tables.", "expression": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}, "kms_key_id": {"description": "Key ID of the customer-managed KMS key encrypting all eleven tables.", "expression": {"references": ["aws_kms_key.dynamodb.key_id", "aws_kms_key.dynamodb"]}}, "table_arns": {"description": "Map of logical table name to table ARN.", "expression": {"references": ["local.tables"]}}, "table_names": {"description": "Map of logical table name to physical DynamoDB table name.", "expression": {"references": ["local.tables"]}}, "table_stream_arns": {"description": "Map of logical table name to stream ARN (null where streams are disabled).", "expression": {"references": ["local.tables"]}}}, "resources": [{"address": "aws_dynamodb_resource_policy.tables", "expressions": {"policy": {"references": ["local.table_policy_arns", "each.key", "local.table_policy_arns", "each.key", "var.data_plane_principal_arns", "local.table_policy_arns", "each.key", "local.table_policy_arns", "each.key", "var.administrator_principal_arns"]}, "resource_arn": {"references": ["each.value.arn", "each.value"]}}, "for_each_expression": {"references": ["local.tables"]}, "mode": "managed", "name": "tables", "provider_config_key": "aws", "schema_version": 0, "type": "aws_dynamodb_resource_policy"}, {"address": "aws_dynamodb_table.accounts", "expressions": {"attribute": [{"name": {"constant_value": "account_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_owner_rep_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "created_at"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "name_lower"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant_owner_rep_id"}, "name": {"constant_value": "gsi_owner"}, "non_key_attributes": {"constant_value": ["account_id", "owner_rep_id", "name", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["account_id", "name", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "name_lower"}}], "hash_key": {"constant_value": "account_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "accounts", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.activities", "expressions": {"attribute": [{"name": {"constant_value": "activity_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_opportunity_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "occurred_at"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_account_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "created_at"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant_opportunity_id"}, "name": {"constant_value": "gsi_opportunity"}, "non_key_attributes": {"constant_value": ["activity_id", "opportunity_id", "kind", "subject", "body", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "occurred_at"}}, {"hash_key": {"constant_value": "tenant_account_id"}, "name": {"constant_value": "gsi_account"}, "non_key_attributes": {"constant_value": ["activity_id", "account_id", "opportunity_id", "kind", "subject", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "occurred_at"}}, {"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["activity_id", "opportunity_id", "kind", "subject", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}], "hash_key": {"constant_value": "activity_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "activities", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.audit_records", "expressions": {"attribute": [{"name": {"constant_value": "audit_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_target_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "created_at"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_actor_rep_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant_target_id"}, "name": {"constant_value": "gsi_target"}, "non_key_attributes": {"constant_value": ["audit_id", "target_table", "target_id", "actor_rep_id", "reversed_at", "account_id", "status", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant_actor_rep_id"}, "name": {"constant_value": "gsi_actor"}, "non_key_attributes": {"constant_value": ["audit_id", "actor_rep_id", "target_table", "target_id", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["audit_id", "account_id", "target_id", "target_table", "status", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}], "hash_key": {"constant_value": "audit_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "audit_records", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.contacts", "expressions": {"attribute": [{"name": {"constant_value": "contact_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_account_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "created_at"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "name_lower"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant_account_id"}, "name": {"constant_value": "gsi_account"}, "non_key_attributes": {"constant_value": ["contact_id", "account_id", "name", "status", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["contact_id", "account_id", "name", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "name_lower"}}], "hash_key": {"constant_value": "contact_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "contacts", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.eval_results", "expressions": {"attribute": [{"name": {"constant_value": "run_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "result_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "run_id_task_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "arm"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "run_id_task_id"}, "name": {"constant_value": "gsi_task"}, "non_key_attributes": {"constant_value": ["tenant", "run_id", "result_id", "arm"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "arm"}}], "hash_key": {"constant_value": "run_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "range_key": {"constant_value": "result_id"}, "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "eval_results", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.eval_runs", "expressions": {"attribute": [{"name": {"constant_value": "run_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "status"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "started_at"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "status"}, "name": {"constant_value": "gsi_status"}, "non_key_attributes": {"constant_value": ["tenant", "run_id", "status"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "started_at"}}], "hash_key": {"constant_value": "run_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "eval_runs", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.notes", "expressions": {"attribute": [{"name": {"constant_value": "note_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_opportunity_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "created_at"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant_opportunity_id"}, "name": {"constant_value": "gsi_opportunity"}, "non_key_attributes": {"constant_value": ["note_id", "opportunity_id", "body", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["note_id", "opportunity_id", "body", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}], "hash_key": {"constant_value": "note_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "notes", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.opportunities", "expressions": {"attribute": [{"name": {"constant_value": "opportunity_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_account_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "created_at"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_owner_rep_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "stage_close_date"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_stage"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "close_date"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "name_lower"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant_account_id"}, "name": {"constant_value": "gsi_account"}, "non_key_attributes": {"constant_value": ["opportunity_id", "account_id", "name", "name_lower", "owner_rep_id", "stage", "close_date", "value", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant_owner_rep_id"}, "name": {"constant_value": "gsi_owner_stage"}, "non_key_attributes": {"constant_value": ["opportunity_id", "account_id", "name", "name_lower", "owner_rep_id", "stage", "close_date", "value", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "stage_close_date"}}, {"hash_key": {"constant_value": "tenant_stage"}, "name": {"constant_value": "gsi_stage"}, "non_key_attributes": {"constant_value": ["opportunity_id", "account_id", "name", "name_lower", "owner_rep_id", "stage", "close_date", "value", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "close_date"}}, {"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["opportunity_id", "account_id", "name", "owner_rep_id", "stage", "close_date", "value", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "name_lower"}}], "hash_key": {"constant_value": "opportunity_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "opportunities", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.proposals", "expressions": {"attribute": [{"name": {"constant_value": "proposal_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_status"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "created_at"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_actor_rep_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_target_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant_status"}, "name": {"constant_value": "gsi_status"}, "non_key_attributes": {"constant_value": ["proposal_id", "status", "target_table", "target_id", "actor_rep_id", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant_actor_rep_id"}, "name": {"constant_value": "gsi_actor"}, "non_key_attributes": {"constant_value": ["proposal_id", "actor_rep_id", "status", "target_table", "target_id", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant_target_id"}, "name": {"constant_value": "gsi_target"}, "non_key_attributes": {"constant_value": ["proposal_id", "target_table", "target_id", "status", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["proposal_id", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}], "hash_key": {"constant_value": "proposal_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "proposals", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.reps", "expressions": {"attribute": [{"name": {"constant_value": "rep_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["rep_id", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "rep_id"}}], "hash_key": {"constant_value": "rep_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "reps", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.usage_records", "expressions": {"attribute": [{"name": {"constant_value": "usage_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_correlation_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "created_at"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_run_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant_correlation_id"}, "name": {"constant_value": "gsi_correlation"}, "non_key_attributes": {"constant_value": ["usage_id", "correlation_id", "run_id", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant_run_id"}, "name": {"constant_value": "gsi_run"}, "non_key_attributes": {"constant_value": ["usage_id", "run_id", "correlation_id", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["usage_id", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}], "hash_key": {"constant_value": "usage_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "usage_records", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_kms_alias.dynamodb", "expressions": {"name": {"references": ["var.name_prefix"]}, "target_key_id": {"references": ["aws_kms_key.dynamodb.key_id", "aws_kms_key.dynamodb"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_alias"}, {"address": "aws_kms_key.dynamodb", "expressions": {"deletion_window_in_days": {"constant_value": 30}, "description": {"constant_value": "CMK for CRM DynamoDB table encryption at rest"}, "enable_key_rotation": {"constant_value": true}, "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key"}, {"address": "aws_kms_key_policy.dynamodb", "expressions": {"bypass_policy_lockout_safety_check": {"constant_value": false}, "key_id": {"references": ["aws_kms_key.dynamodb.id", "aws_kms_key.dynamodb"]}, "policy": {"references": ["var.account_id", "var.data_plane_principal_arns", "var.administrator_principal_arns"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key_policy"}, {"address": "data.aws_partition.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_partition"}, {"address": "data.aws_region.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_region"}], "variables": {"account_id": {"description": "Account id of the account-root statement in the CMK key policy."}, "administrator_principal_arns": {"description": "IAM role or user ARNs, or the account root, admitted to table and CMK administration. Every other principal is denied by the table and key policies."}, "caller_principal_arn": {"description": "Role or user ARN of the principal running this plan. The table and key policies refuse to plan unless it is a listed administrator other than the account root, so no apply can lock its own caller out."}, "data_classification": {"default": "confidential", "description": "Value for the `data-classification` tag on resources in this module."}, "data_plane_principal_arns": {"description": "IAM role or user ARNs admitted to the tables' data plane and to the CMK's key use. Every other principal is denied by the table and key policies."}, "name_prefix": {"default": "", "description": "Prefix applied to table and alias names, e.g. tenant or environment scoping."}}}, "source": "./modules/dynamodb"}, "eni_function_code_deny": {"expressions": {"name_prefix": {"references": ["local.name_prefix"]}}, "module": {"outputs": {"policy_arn": {"description": "ARN of the ENI function-code Deny policy, passed to every `lambda_action` and `agent_relay` instantiation.", "expression": {"references": ["aws_iam_policy.this.arn", "aws_iam_policy.this"]}}}, "resources": [{"address": "aws_iam_policy.this", "expressions": {"description": {"constant_value": "Denies the Hyperplane ENI actions to Lambda function code; Lambda's own ENI management is unaffected."}, "name": {"references": ["var.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.this.json", "data.aws_iam_policy_document.this"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "data.aws_iam_policy_document.this", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:DetachNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "condition": [{"test": {"constant_value": "Null"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "lambda:SourceFunctionArn"}}], "effect": {"constant_value": "Deny"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "DenyEniActionsToFunctionCode"}}]}, "mode": "data", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"name_prefix": {"description": "Deployment name prefix, from the root composition's `local.name_prefix`. Part of the policy name."}}}, "source": "./modules/eni_function_code_deny"}, "eval_artifacts": {"expressions": {"access_log_bucket_id": {"references": ["module.frontend_cdn.logs_bucket_name", "module.frontend_cdn"]}, "account_id": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "administrator_principal_arns": {"references": ["var.crm_operator_principal_arns", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "caller_principal_arn": {"references": ["data.aws_iam_session_context.current.issuer_arn", "data.aws_iam_session_context.current"]}, "data_classification": {"references": ["var.data_classification"]}, "data_plane_principal_arns": {"references": ["local.eval_artifacts_principal_arns", "var.crm_operator_principal_arns"]}, "kms_key_arn": {"references": ["aws_kms_key.eval_artifacts.arn", "aws_kms_key.eval_artifacts"]}, "name_prefix": {"references": ["local.name_prefix"]}, "writer_role_name": {"constant_value": null}}, "module": {"outputs": {"artifact_prefix": {"description": "The single key prefix artefacts are written under, and the only prefix the writer grant covers.", "expression": {"references": ["var.artifact_prefix"]}}, "bucket_arn": {"description": "ARN of the eval-artefacts bucket, for a consumer composing its own policy against it.", "expression": {"references": ["aws_s3_bucket.this.arn", "aws_s3_bucket.this"]}}, "bucket_name": {"description": "Name of the eval-artefacts bucket, which embeds the account id. Read by application code and the smoke suite.", "expression": {"references": ["aws_s3_bucket.this.id", "aws_s3_bucket.this"]}}}, "resources": [{"address": "aws_iam_role_policy.writer", "count_expression": {"references": ["var.writer_role_name"]}, "expressions": {"name": {"references": ["var.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.writer.json", "data.aws_iam_policy_document.writer"]}, "role": {"references": ["var.writer_role_name"]}}, "mode": "managed", "name": "writer", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_s3_bucket.this", "expressions": {"bucket": {"references": ["local.bucket_name"]}, "force_destroy": {"constant_value": true}, "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket"}, {"address": "aws_s3_bucket_lifecycle_configuration.this", "expressions": {"bucket": {"references": ["aws_s3_bucket.this.id", "aws_s3_bucket.this"]}, "rule": [{"abort_incomplete_multipart_upload": [{"days_after_initiation": {"constant_value": 7}}], "expiration": [{"days": {"references": ["var.artifact_retention_days"]}}], "filter": [{"prefix": {"references": ["var.artifact_prefix"]}}], "id": {"constant_value": "expire-artifacts"}, "noncurrent_version_expiration": [{"noncurrent_days": {"references": ["var.artifact_retention_days"]}}], "status": {"constant_value": "Enabled"}}, {"abort_incomplete_multipart_upload": [{"days_after_initiation": {"constant_value": 7}}], "filter": [{}], "id": {"constant_value": "expire-noncurrent-and-abort-uploads"}, "noncurrent_version_expiration": [{"noncurrent_days": {"references": ["var.artifact_retention_days"]}}], "status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 1, "type": "aws_s3_bucket_lifecycle_configuration"}, {"address": "aws_s3_bucket_logging.this", "expressions": {"bucket": {"references": ["aws_s3_bucket.this.id", "aws_s3_bucket.this"]}, "target_bucket": {"references": ["var.access_log_bucket_id"]}, "target_prefix": {"constant_value": "s3-access-logs/eval-artifacts/"}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_logging"}, {"address": "aws_s3_bucket_ownership_controls.this", "expressions": {"bucket": {"references": ["aws_s3_bucket.this.id", "aws_s3_bucket.this"]}, "rule": [{"object_ownership": {"constant_value": "BucketOwnerEnforced"}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_ownership_controls"}, {"address": "aws_s3_bucket_policy.this", "expressions": {"bucket": {"references": ["aws_s3_bucket.this.id", "aws_s3_bucket.this"]}, "policy": {"references": ["data.aws_iam_policy_document.bucket.json", "data.aws_iam_policy_document.bucket"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_policy"}, {"address": "aws_s3_bucket_public_access_block.this", "expressions": {"block_public_acls": {"constant_value": true}, "block_public_policy": {"constant_value": true}, "bucket": {"references": ["aws_s3_bucket.this.id", "aws_s3_bucket.this"]}, "ignore_public_acls": {"constant_value": true}, "restrict_public_buckets": {"constant_value": true}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_public_access_block"}, {"address": "aws_s3_bucket_server_side_encryption_configuration.this", "expressions": {"bucket": {"references": ["aws_s3_bucket.this.id", "aws_s3_bucket.this"]}, "rule": [{"apply_server_side_encryption_by_default": [{"kms_master_key_id": {"references": ["var.kms_key_arn"]}, "sse_algorithm": {"constant_value": "aws:kms"}}], "bucket_key_enabled": {"constant_value": true}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_server_side_encryption_configuration"}, {"address": "aws_s3_bucket_versioning.this", "expressions": {"bucket": {"references": ["aws_s3_bucket.this.id", "aws_s3_bucket.this"]}, "versioning_configuration": [{"status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_versioning"}, {"address": "data.aws_iam_policy_document.bucket", "expressions": {"statement": [{"actions": {"constant_value": ["s3:*"]}, "condition": [{"test": {"constant_value": "Bool"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:SecureTransport"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["local.bucket_arn", "local.bucket_arn"]}, "sid": {"constant_value": "DenyInsecureTransport"}}, {"actions": {"constant_value": ["s3:PutObject"]}, "condition": [{"test": {"constant_value": "StringNotEquals"}, "values": {"constant_value": ["aws:kms"]}, "variable": {"constant_value": "s3:x-amz-server-side-encryption"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["local.bucket_arn"]}, "sid": {"constant_value": "DenyUnencryptedObjectUploads"}}, {"actions": {"constant_value": ["s3:GetObject", "s3:GetObjectVersion", "s3:GetObjectAttributes", "s3:GetObjectVersionAttributes", "s3:GetObjectTagging", "s3:GetObjectVersionTagging", "s3:RestoreObject", "s3:ListBucket", "s3:ListBucketVersions", "s3:ListBucketMultipartUploads", "s3:ListMultipartUploadParts", "s3:PutObject", "s3:PutObjectTagging", "s3:DeleteObject", "s3:DeleteObjectVersion", "s3:DeleteObjectTagging", "s3:AbortMultipartUpload", "s3:PutObjectVersionTagging", "s3:DeleteObjectVersionTagging"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.data_plane_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"references": ["local.bucket_arn", "local.bucket_arn"]}, "sid": {"constant_value": "DenyObjectDataPlaneToNonProjectPrincipals"}}, {"actions": {"constant_value": ["s3:DeleteBucket", "s3:PutBucketPolicy", "s3:DeleteBucketPolicy", "s3:PutBucketVersioning", "s3:PutEncryptionConfiguration", "s3:PutLifecycleConfiguration", "s3:PutBucketLogging", "s3:PutBucketPublicAccessBlock", "s3:PutBucketOwnershipControls", "s3:PutBucketAcl", "s3:PutBucketTagging", "s3:PutReplicationConfiguration", "s3:PutInventoryConfiguration", "s3:PutBucketNotification", "s3:PutBucketObjectLockConfiguration", "s3:PutBucketRequestPayment", "s3:PutBucketWebsite", "s3:PutBucketCORS", "s3:PutAccelerateConfiguration", "s3:PutIntelligentTieringConfiguration", "s3:PutAnalyticsConfiguration", "s3:PutMetricsConfiguration"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.administrator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"references": ["local.bucket_arn"]}, "sid": {"constant_value": "DenyBucketAdministrationToNonOperators"}}]}, "mode": "data", "name": "bucket", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.writer", "expressions": {"statement": [{"actions": {"constant_value": ["s3:PutObject", "s3:GetObject"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["local.bucket_arn", "var.artifact_prefix"]}, "sid": {"constant_value": "WriteAndReadArtifactPrefix"}}, {"actions": {"constant_value": ["kms:GenerateDataKey", "kms:Decrypt"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.kms_key_arn"]}, "sid": {"constant_value": "UseBucketCmk"}}]}, "mode": "data", "name": "writer", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_partition.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_partition"}], "variables": {"access_log_bucket_id": {"description": "Bucket id receiving this bucket S3 access logs. Must be a different bucket."}, "account_id": {"description": "AWS account id, part of the globally-unique bucket name. Passed in by the caller so the module plans offline."}, "administrator_principal_arns": {"description": "IAM role or user ARNs, or the account root, admitted to bucket administration. Every other principal is denied it by the bucket policy."}, "artifact_prefix": {"default": "sweeps", "description": "Single key prefix all artefacts are written under, and the only prefix the writer grant covers."}, "artifact_retention_days": {"default": 30, "description": "Lifecycle expiry in days, applied to current objects, noncurrent versions and incomplete multipart\nuploads alike. Artefacts are reproducible from a sweep with the same arguments and `dataset_seed`.\n"}, "caller_principal_arn": {"description": "Role or user ARN of the principal running this plan. The bucket policy refuses to plan unless it is a listed administrator other than the account root, so no apply can lock its own caller out."}, "data_classification": {"description": "Value of the mandatory `data-classification` tag."}, "data_plane_principal_arns": {"description": "IAM role or user ARNs admitted to the bucket's object reads, lists and writes. Every other principal is denied them by the bucket policy."}, "kms_key_arn": {"description": "Customer-managed key ARN encrypting this bucket's objects, and the key the writer grant covers.\nCreated by the caller; it must be a dedicated key (see README).\n"}, "name_prefix": {"description": "Deployment name prefix, from the root composition's `local.name_prefix`. Part of the bucket name alongside the account id."}, "writer_role_name": {"default": null, "description": "IAM role name the writer policy is attached to (the sweep worker's role). `null` (the default)\nattaches nothing. The grant's scope comes from the policy's own resources, not from this value.\n"}}}, "source": "./modules/eval_artifacts"}, "frontend_cdn": {"expressions": {"administrator_principal_arns": {"references": ["var.crm_operator_principal_arns", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "agent_relay_function_name": {"references": ["module.agent_relay.function_name", "module.agent_relay"]}, "agent_relay_function_url_domain": {"references": ["module.agent_relay.function_url_domain", "module.agent_relay"]}, "alb_access_log_prefix": {"references": ["local.alb_access_log_prefix"]}, "api_gateway_domain_name": {"references": ["module.api.private_origin_domain_name", "module.api"]}, "api_gateway_stage_name": {"references": ["module.api.stage_name", "module.api"]}, "api_origin_vpc_origin_id": {"references": ["module.api_origin.vpc_origin_id", "module.api_origin"]}, "caller_principal_arn": {"references": ["data.aws_iam_session_context.current.issuer_arn", "data.aws_iam_session_context.current"]}, "csp_connect_src_extra": {"references": ["local.spa_connect_src_extra"]}, "csp_script_hashes": {"references": ["local.spa_inline_script_hashes"]}, "data_classification": {"references": ["var.data_classification"]}, "log_retention_days": {"constant_value": 90}, "name_prefix": {"references": ["local.name_prefix"]}, "operator_principal_arns": {"references": ["var.crm_operator_principal_arns"]}, "origin_noncurrent_version_retention_days": {"constant_value": 30}}, "module": {"outputs": {"distribution_arn": {"description": "ARN of the CloudFront distribution, used by the origin bucket policy's `AWS:SourceArn` condition.", "expression": {"references": ["aws_cloudfront_distribution.frontend.arn", "aws_cloudfront_distribution.frontend"]}}, "distribution_domain_name": {"description": "CloudFront distribution domain name (e.g. `d111111abcdef8.cloudfront.net`).", "expression": {"references": ["aws_cloudfront_distribution.frontend.domain_name", "aws_cloudfront_distribution.frontend"]}}, "distribution_id": {"description": "ID of the CloudFront distribution.", "expression": {"references": ["aws_cloudfront_distribution.frontend.id", "aws_cloudfront_distribution.frontend"]}}, "kms_key_arn": {"description": "ARN of the customer-managed KMS key encrypting the origin bucket.", "expression": {"references": ["aws_kms_key.frontend.arn", "aws_kms_key.frontend"]}}, "logs_bucket_name": {"description": "Name of the S3 bucket receiving S3 access logs and CloudFront access logs.", "expression": {"references": ["aws_s3_bucket.logs.id", "aws_s3_bucket.logs"]}}, "origin_bucket_arn": {"description": "ARN of the private S3 origin bucket.", "expression": {"references": ["aws_s3_bucket.origin.arn", "aws_s3_bucket.origin"]}}, "origin_bucket_name": {"description": "Name of the private S3 bucket that holds the frontend static build.", "expression": {"references": ["aws_s3_bucket.origin.id", "aws_s3_bucket.origin"]}}}, "resources": [{"address": "aws_cloudfront_distribution.frontend", "expressions": {"comment": {"references": ["var.name_prefix"]}, "default_cache_behavior": [{"allowed_methods": {"constant_value": ["GET", "HEAD"]}, "cache_policy_id": {"references": ["data.aws_cloudfront_cache_policy.caching_optimized.id", "data.aws_cloudfront_cache_policy.caching_optimized"]}, "cached_methods": {"constant_value": ["GET", "HEAD"]}, "compress": {"constant_value": true}, "function_association": [{"event_type": {"constant_value": "viewer-request"}, "function_arn": {"references": ["aws_cloudfront_function.spa_history_fallback.arn", "aws_cloudfront_function.spa_history_fallback"]}}], "response_headers_policy_id": {"references": ["aws_cloudfront_response_headers_policy.security_headers.id", "aws_cloudfront_response_headers_policy.security_headers"]}, "target_origin_id": {"constant_value": "s3-frontend-origin"}, "viewer_protocol_policy": {"constant_value": "redirect-to-https"}}], "default_root_object": {"constant_value": "index.html"}, "enabled": {"constant_value": true}, "logging_config": [{"bucket": {"references": ["aws_s3_bucket.logs.bucket_domain_name", "aws_s3_bucket.logs"]}, "include_cookies": {"constant_value": false}, "prefix": {"constant_value": "cloudfront-access-logs/"}}], "ordered_cache_behavior": [{"allowed_methods": {"constant_value": ["GET", "HEAD", "OPTIONS", "PUT", "POST", "PATCH", "DELETE"]}, "cache_policy_id": {"references": ["data.aws_cloudfront_cache_policy.caching_disabled.id", "data.aws_cloudfront_cache_policy.caching_disabled"]}, "cached_methods": {"constant_value": ["GET", "HEAD"]}, "compress": {"constant_value": true}, "function_association": [{"event_type": {"constant_value": "viewer-request"}, "function_arn": {"references": ["aws_cloudfront_function.api_path_rewrite.arn", "aws_cloudfront_function.api_path_rewrite"]}}], "origin_request_policy_id": {"references": ["data.aws_cloudfront_origin_request_policy.all_viewer_except_host.id", "data.aws_cloudfront_origin_request_policy.all_viewer_except_host"]}, "path_pattern": {"constant_value": "/api/*"}, "response_headers_policy_id": {"references": ["aws_cloudfront_response_headers_policy.security_headers.id", "aws_cloudfront_response_headers_policy.security_headers"]}, "target_origin_id": {"constant_value": "api-gateway-origin"}, "viewer_protocol_policy": {"constant_value": "https-only"}}, {"allowed_methods": {"constant_value": ["GET", "HEAD", "OPTIONS", "PUT", "POST", "PATCH", "DELETE"]}, "cache_policy_id": {"references": ["data.aws_cloudfront_cache_policy.caching_disabled.id", "data.aws_cloudfront_cache_policy.caching_disabled"]}, "cached_methods": {"constant_value": ["GET", "HEAD"]}, "compress": {"constant_value": false}, "origin_request_policy_id": {"references": ["aws_cloudfront_origin_request_policy.agent_relay.id", "aws_cloudfront_origin_request_policy.agent_relay"]}, "path_pattern": {"constant_value": "/agent/*"}, "response_headers_policy_id": {"references": ["aws_cloudfront_response_headers_policy.security_headers.id", "aws_cloudfront_response_headers_policy.security_headers"]}, "target_origin_id": {"constant_value": "agent-relay-origin"}, "viewer_protocol_policy": {"constant_value": "https-only"}}], "origin": [{"domain_name": {"references": ["aws_s3_bucket.origin.bucket_regional_domain_name", "aws_s3_bucket.origin"]}, "origin_access_control_id": {"references": ["aws_cloudfront_origin_access_control.origin.id", "aws_cloudfront_origin_access_control.origin"]}, "origin_id": {"constant_value": "s3-frontend-origin"}}, {"domain_name": {"references": ["var.api_gateway_domain_name"]}, "origin_id": {"constant_value": "api-gateway-origin"}, "vpc_origin_config": [{"vpc_origin_id": {"references": ["var.api_origin_vpc_origin_id"]}}]}, {"custom_origin_config": [{"http_port": {"constant_value": 80}, "https_port": {"constant_value": 443}, "origin_protocol_policy": {"constant_value": "https-only"}, "origin_read_timeout": {"constant_value": 60}, "origin_ssl_protocols": {"constant_value": ["TLSv1.2"]}}], "domain_name": {"references": ["var.agent_relay_function_url_domain"]}, "origin_access_control_id": {"references": ["aws_cloudfront_origin_access_control.agent_relay.id", "aws_cloudfront_origin_access_control.agent_relay"]}, "origin_id": {"constant_value": "agent-relay-origin"}}], "price_class": {"constant_value": "PriceClass_100"}, "restrictions": [{"geo_restriction": [{"restriction_type": {"constant_value": "none"}}]}], "tags": {"references": ["var.data_classification"]}, "viewer_certificate": [{"cloudfront_default_certificate": {"constant_value": true}}]}, "mode": "managed", "name": "frontend", "provider_config_key": "aws", "schema_version": 1, "type": "aws_cloudfront_distribution"}, {"address": "aws_cloudfront_function.api_path_rewrite", "expressions": {"code": {"references": ["path.module", "var.api_gateway_stage_name"]}, "comment": {"constant_value": "Rewrite /api/* onto the REST API's stage path"}, "name": {"references": ["var.name_prefix"]}, "publish": {"constant_value": true}, "runtime": {"constant_value": "cloudfront-js-2.0"}}, "mode": "managed", "name": "api_path_rewrite", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_function"}, {"address": "aws_cloudfront_function.spa_history_fallback", "expressions": {"code": {"references": ["path.module"]}, "comment": {"constant_value": "Serve /index.html for SPA client-side routes"}, "name": {"references": ["var.name_prefix"]}, "publish": {"constant_value": true}, "runtime": {"constant_value": "cloudfront-js-2.0"}}, "mode": "managed", "name": "spa_history_fallback", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_function"}, {"address": "aws_cloudfront_origin_access_control.agent_relay", "expressions": {"description": {"constant_value": "SigV4-signs origin requests to the relay's AWS_IAM Function URL"}, "name": {"references": ["var.name_prefix"]}, "origin_access_control_origin_type": {"constant_value": "lambda"}, "signing_behavior": {"constant_value": "always"}, "signing_protocol": {"constant_value": "sigv4"}}, "mode": "managed", "name": "agent_relay", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_origin_access_control"}, {"address": "aws_cloudfront_origin_access_control.origin", "expressions": {"name": {"references": ["var.name_prefix"]}, "origin_access_control_origin_type": {"constant_value": "s3"}, "signing_behavior": {"constant_value": "always"}, "signing_protocol": {"constant_value": "sigv4"}}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_origin_access_control"}, {"address": "aws_cloudfront_origin_request_policy.agent_relay", "expressions": {"comment": {"constant_value": "Forward every viewer header except Host to the relay origin"}, "cookies_config": [{"cookie_behavior": {"constant_value": "all"}}], "headers_config": [{"header_behavior": {"constant_value": "allExcept"}, "headers": [{"items": {"constant_value": ["host"]}}]}], "name": {"references": ["var.name_prefix"]}, "query_strings_config": [{"query_string_behavior": {"constant_value": "all"}}]}, "mode": "managed", "name": "agent_relay", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_origin_request_policy"}, {"address": "aws_cloudfront_response_headers_policy.security_headers", "expressions": {"comment": {"constant_value": "Security headers and an enforced Content-Security-Policy for the CRM frontend"}, "name": {"references": ["var.name_prefix"]}, "security_headers_config": [{"content_security_policy": [{"content_security_policy": {"references": ["local.content_security_policy"]}, "override": {"constant_value": true}}], "content_type_options": [{"override": {"constant_value": true}}], "frame_options": [{"frame_option": {"constant_value": "DENY"}, "override": {"constant_value": true}}], "referrer_policy": [{"override": {"constant_value": true}, "referrer_policy": {"constant_value": "strict-origin-when-cross-origin"}}], "strict_transport_security": [{"access_control_max_age_sec": {"constant_value": 31536000}, "include_subdomains": {"constant_value": false}, "override": {"constant_value": true}, "preload": {"constant_value": false}}], "xss_protection": [{"mode_block": {"constant_value": true}, "override": {"constant_value": true}, "protection": {"constant_value": true}}]}]}, "mode": "managed", "name": "security_headers", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_response_headers_policy"}, {"address": "aws_kms_alias.frontend", "expressions": {"name": {"references": ["var.name_prefix"]}, "target_key_id": {"references": ["aws_kms_key.frontend.key_id", "aws_kms_key.frontend"]}}, "mode": "managed", "name": "frontend", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_alias"}, {"address": "aws_kms_key.frontend", "expressions": {"deletion_window_in_days": {"constant_value": 30}, "description": {"constant_value": "CMK for CRM frontend CDN origin bucket encryption at rest"}, "enable_key_rotation": {"constant_value": true}, "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "frontend", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key"}, {"address": "aws_kms_key_policy.frontend", "expressions": {"bypass_policy_lockout_safety_check": {"constant_value": false}, "key_id": {"references": ["aws_kms_key.frontend.id", "aws_kms_key.frontend"]}, "policy": {"references": ["data.aws_iam_policy_document.frontend_kms.json", "data.aws_iam_policy_document.frontend_kms"]}}, "mode": "managed", "name": "frontend", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key_policy"}, {"address": "aws_lambda_permission.agent_relay_function_url", "expressions": {"action": {"constant_value": "lambda:InvokeFunctionUrl"}, "function_name": {"references": ["var.agent_relay_function_name"]}, "function_url_auth_type": {"constant_value": "AWS_IAM"}, "principal": {"constant_value": "cloudfront.amazonaws.com"}, "source_arn": {"references": ["aws_cloudfront_distribution.frontend.arn", "aws_cloudfront_distribution.frontend"]}, "statement_id": {"constant_value": "AllowCloudFrontOacInvokeFunctionUrl"}}, "mode": "managed", "name": "agent_relay_function_url", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "aws_lambda_permission.agent_relay_invoke_function", "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["var.agent_relay_function_name"]}, "principal": {"constant_value": "cloudfront.amazonaws.com"}, "source_arn": {"references": ["aws_cloudfront_distribution.frontend.arn", "aws_cloudfront_distribution.frontend"]}, "statement_id": {"constant_value": "AllowCloudFrontOacInvokeFunction"}}, "mode": "managed", "name": "agent_relay_invoke_function", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "aws_s3_bucket.logs", "expressions": {"bucket": {"references": ["var.name_prefix", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "force_destroy": {"constant_value": true}, "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket"}, {"address": "aws_s3_bucket.origin", "expressions": {"bucket": {"references": ["var.name_prefix", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "force_destroy": {"constant_value": true}, "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket"}, {"address": "aws_s3_bucket_lifecycle_configuration.logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.logs.id", "aws_s3_bucket.logs"]}, "rule": [{"abort_incomplete_multipart_upload": [{"days_after_initiation": {"constant_value": 7}}], "expiration": [{"days": {"references": ["var.log_retention_days"]}}], "filter": [{}], "id": {"constant_value": "expire-access-logs"}, "noncurrent_version_expiration": [{"noncurrent_days": {"references": ["var.log_retention_days"]}}], "status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 1, "type": "aws_s3_bucket_lifecycle_configuration"}, {"address": "aws_s3_bucket_lifecycle_configuration.origin", "expressions": {"bucket": {"references": ["aws_s3_bucket.origin.id", "aws_s3_bucket.origin"]}, "rule": [{"abort_incomplete_multipart_upload": [{"days_after_initiation": {"constant_value": 7}}], "filter": [{}], "id": {"constant_value": "expire-superseded-builds"}, "noncurrent_version_expiration": [{"noncurrent_days": {"references": ["var.origin_noncurrent_version_retention_days"]}}], "status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 1, "type": "aws_s3_bucket_lifecycle_configuration"}, {"address": "aws_s3_bucket_logging.origin", "expressions": {"bucket": {"references": ["aws_s3_bucket.origin.id", "aws_s3_bucket.origin"]}, "target_bucket": {"references": ["aws_s3_bucket.logs.id", "aws_s3_bucket.logs"]}, "target_prefix": {"constant_value": "s3-access-logs/origin/"}}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_logging"}, {"address": "aws_s3_bucket_ownership_controls.logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.logs.id", "aws_s3_bucket.logs"]}, "rule": [{"object_ownership": {"constant_value": "BucketOwnerPreferred"}}]}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_ownership_controls"}, {"address": "aws_s3_bucket_ownership_controls.origin", "expressions": {"bucket": {"references": ["aws_s3_bucket.origin.id", "aws_s3_bucket.origin"]}, "rule": [{"object_ownership": {"constant_value": "BucketOwnerEnforced"}}]}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_ownership_controls"}, {"address": "aws_s3_bucket_policy.logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.logs.id", "aws_s3_bucket.logs"]}, "policy": {"references": ["data.aws_iam_policy_document.logs_tls_deny.json", "data.aws_iam_policy_document.logs_tls_deny"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_policy"}, {"address": "aws_s3_bucket_policy.origin", "expressions": {"bucket": {"references": ["aws_s3_bucket.origin.id", "aws_s3_bucket.origin"]}, "policy": {"references": ["data.aws_iam_policy_document.origin.json", "data.aws_iam_policy_document.origin"]}}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_policy"}, {"address": "aws_s3_bucket_public_access_block.logs", "expressions": {"block_public_acls": {"constant_value": true}, "block_public_policy": {"constant_value": true}, "bucket": {"references": ["aws_s3_bucket.logs.id", "aws_s3_bucket.logs"]}, "ignore_public_acls": {"constant_value": true}, "restrict_public_buckets": {"constant_value": true}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_public_access_block"}, {"address": "aws_s3_bucket_public_access_block.origin", "expressions": {"block_public_acls": {"constant_value": true}, "block_public_policy": {"constant_value": true}, "bucket": {"references": ["aws_s3_bucket.origin.id", "aws_s3_bucket.origin"]}, "ignore_public_acls": {"constant_value": true}, "restrict_public_buckets": {"constant_value": true}}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_public_access_block"}, {"address": "aws_s3_bucket_server_side_encryption_configuration.logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.logs.id", "aws_s3_bucket.logs"]}, "rule": [{"apply_server_side_encryption_by_default": [{"sse_algorithm": {"constant_value": "AES256"}}], "bucket_key_enabled": {"constant_value": true}}]}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_server_side_encryption_configuration"}, {"address": "aws_s3_bucket_server_side_encryption_configuration.origin", "expressions": {"bucket": {"references": ["aws_s3_bucket.origin.id", "aws_s3_bucket.origin"]}, "rule": [{"apply_server_side_encryption_by_default": [{"kms_master_key_id": {"references": ["aws_kms_key.frontend.arn", "aws_kms_key.frontend"]}, "sse_algorithm": {"constant_value": "aws:kms"}}], "bucket_key_enabled": {"constant_value": true}}]}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_server_side_encryption_configuration"}, {"address": "aws_s3_bucket_versioning.logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.logs.id", "aws_s3_bucket.logs"]}, "versioning_configuration": [{"status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_versioning"}, {"address": "aws_s3_bucket_versioning.origin", "expressions": {"bucket": {"references": ["aws_s3_bucket.origin.id", "aws_s3_bucket.origin"]}, "versioning_configuration": [{"status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_versioning"}, {"address": "data.aws_caller_identity.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_caller_identity"}, {"address": "data.aws_cloudfront_cache_policy.caching_disabled", "expressions": {"name": {"constant_value": "Managed-CachingDisabled"}}, "mode": "data", "name": "caching_disabled", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_cache_policy"}, {"address": "data.aws_cloudfront_cache_policy.caching_optimized", "expressions": {"name": {"constant_value": "Managed-CachingOptimized"}}, "mode": "data", "name": "caching_optimized", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_cache_policy"}, {"address": "data.aws_cloudfront_origin_request_policy.all_viewer_except_host", "expressions": {"name": {"constant_value": "Managed-AllViewerExceptHostHeader"}}, "mode": "data", "name": "all_viewer_except_host", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_origin_request_policy"}, {"address": "data.aws_iam_policy_document.frontend_kms", "expressions": {"statement": [{"actions": {"constant_value": ["kms:*"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "type": {"constant_value": "AWS"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "EnableIAMUserPermissions"}}, {"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["aws_cloudfront_distribution.frontend.arn", "aws_cloudfront_distribution.frontend"]}, "variable": {"constant_value": "AWS:SourceArn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["cloudfront.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "AllowCloudFrontOACDecrypt"}}, {"actions": {"constant_value": ["kms:Decrypt", "kms:Encrypt", "kms:GenerateDataKey*", "kms:ReEncrypt*", "kms:CreateGrant"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.operator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}, {"test": {"constant_value": "Bool"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:PrincipalIsAWSService"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "DenyKeyUseToNonProjectPrincipals"}}, {"actions": {"constant_value": ["kms:PutKeyPolicy", "kms:ScheduleKeyDeletion", "kms:DisableKey", "kms:RevokeGrant", "kms:DisableKeyRotation", "kms:CreateAlias", "kms:UpdateAlias", "kms:DeleteAlias", "kms:TagResource", "kms:UntagResource", "kms:UpdateKeyDescription"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.administrator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "DenyKeyAdministrationToNonOperators"}}]}, "mode": "data", "name": "frontend_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs_tls_deny", "expressions": {"statement": [{"actions": {"constant_value": ["s3:PutObject"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "aws:SourceAccount"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["logging.s3.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"references": ["aws_s3_bucket.logs.arn", "aws_s3_bucket.logs"]}, "sid": {"constant_value": "AllowS3ServerAccessLogDelivery"}}, {"actions": {"constant_value": ["s3:PutObject"]}, "condition": [{"test": {"constant_value": "ArnLike"}, "values": {"references": ["data.aws_partition.current.partition", "data.aws_partition.current", "data.aws_region.current.region", "data.aws_region.current", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "aws:SourceArn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["logdelivery.elasticloadbalancing.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"references": ["aws_s3_bucket.logs.arn", "aws_s3_bucket.logs", "var.alb_access_log_prefix", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "sid": {"constant_value": "AllowAlbAccessLogDelivery"}}, {"actions": {"constant_value": ["s3:*"]}, "condition": [{"test": {"constant_value": "Bool"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:SecureTransport"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["aws_s3_bucket.logs.arn", "aws_s3_bucket.logs", "aws_s3_bucket.logs.arn", "aws_s3_bucket.logs"]}, "sid": {"constant_value": "DenyInsecureTransport"}}]}, "mode": "data", "name": "logs_tls_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.origin", "expressions": {"statement": [{"actions": {"constant_value": ["s3:*"]}, "condition": [{"test": {"constant_value": "Bool"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:SecureTransport"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["aws_s3_bucket.origin.arn", "aws_s3_bucket.origin", "aws_s3_bucket.origin.arn", "aws_s3_bucket.origin"]}, "sid": {"constant_value": "DenyInsecureTransport"}}, {"actions": {"constant_value": ["s3:GetObject"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["aws_cloudfront_distribution.frontend.arn", "aws_cloudfront_distribution.frontend"]}, "variable": {"constant_value": "AWS:SourceArn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["cloudfront.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"references": ["aws_s3_bucket.origin.arn", "aws_s3_bucket.origin"]}, "sid": {"constant_value": "AllowCloudFrontOACRead"}}, {"actions": {"constant_value": ["s3:PutObject", "s3:PutObjectTagging", "s3:DeleteObject", "s3:DeleteObjectVersion", "s3:DeleteObjectTagging", "s3:AbortMultipartUpload", "s3:PutObjectVersionTagging", "s3:DeleteObjectVersionTagging"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.operator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"references": ["aws_s3_bucket.origin.arn", "aws_s3_bucket.origin", "aws_s3_bucket.origin.arn", "aws_s3_bucket.origin"]}, "sid": {"constant_value": "DenyObjectWritesToNonOperators"}}, {"actions": {"constant_value": ["s3:DeleteBucket", "s3:PutBucketPolicy", "s3:DeleteBucketPolicy", "s3:PutBucketVersioning", "s3:PutEncryptionConfiguration", "s3:PutLifecycleConfiguration", "s3:PutBucketLogging", "s3:PutBucketPublicAccessBlock", "s3:PutBucketOwnershipControls", "s3:PutBucketAcl", "s3:PutBucketTagging", "s3:PutReplicationConfiguration", "s3:PutInventoryConfiguration", "s3:PutBucketNotification", "s3:PutBucketObjectLockConfiguration", "s3:PutBucketRequestPayment", "s3:PutBucketWebsite", "s3:PutBucketCORS", "s3:PutAccelerateConfiguration", "s3:PutIntelligentTieringConfiguration", "s3:PutAnalyticsConfiguration", "s3:PutMetricsConfiguration"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.administrator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"references": ["aws_s3_bucket.origin.arn", "aws_s3_bucket.origin"]}, "sid": {"constant_value": "DenyBucketAdministrationToNonOperators"}}]}, "mode": "data", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_partition.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_partition"}, {"address": "data.aws_region.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_region"}], "variables": {"administrator_principal_arns": {"description": "IAM role or user ARNs, or the account root, admitted to administration of the frontend CMK and the origin bucket. Every other principal is denied it."}, "agent_relay_function_name": {"description": "The relay function name (`module.agent_relay.function_name`), for the distribution-scoped `lambda:InvokeFunctionUrl` permission this module declares."}, "agent_relay_function_url_domain": {"description": "Host portion of the relay's Lambda Function URL that the `/agent/*` behaviour routes to (`module.agent_relay.function_url_domain`). The browser reaches the Runtime only through the relay."}, "alb_access_log_prefix": {"description": "Key prefix the internal ALB writes access logs under, used to scope this module ELB log-delivery grant to `//AWSLogs//*`. No default; it must equal the prefix the load balancer is configured with, and the root passes one local to both modules."}, "api_gateway_domain_name": {"description": "Origin hostname for the `/api/*` behaviour, from `module.api.private_origin_domain_name` (`-.execute-api..amazonaws.com`). It is the `Host` header the private REST API routes on, not a name CloudFront resolves; the VPC origin routes by ALB ARN."}, "api_gateway_stage_name": {"description": "Stage name the REST API serves its routes beneath (`infra/modules/api/` `stage_name`). The `/api/*` viewer-request function rewrites `/api/` to `//`, since CloudFront forwards the viewer path to a custom origin unchanged."}, "api_origin_vpc_origin_id": {"description": "Id of the CloudFront VPC origin fronting the private REST API (`module.api_origin.vpc_origin_id`), consumed by the `/api/*` origin `vpc_origin_config`."}, "caller_principal_arn": {"description": "Role or user ARN of the principal running this plan. The key and origin-bucket policies refuse to plan unless it is a listed administrator other than the account root, so no apply can lock its own caller out."}, "csp_connect_src_extra": {"description": "Origins (`https://`) added to the CSP `connect-src` beside `'self'`: the endpoints the SPA calls directly, such as the regional Cognito user-pool endpoint and the hosted-UI domain."}, "csp_script_hashes": {"description": "CSP source hashes (`sha256-`, unquoted) of the SPA's inline scripts, added to `script-src` beside `'self'`."}, "data_classification": {"default": "confidential", "description": "Value for the `data-classification` tag on resources in this module."}, "log_retention_days": {"default": 90, "description": "Retention, in days, for the S3 bucket holding S3 access logs and CloudFront access logs."}, "name_prefix": {"default": "", "description": "Prefix applied to resource names, e.g. project or environment scoping."}, "operator_principal_arns": {"description": "IAM role or user ARNs of the operators: the only non-service principals admitted to frontend-CMK use and to writes into the origin bucket."}, "origin_noncurrent_version_retention_days": {"default": 30, "description": "Days a superseded (noncurrent) object version in the origin bucket is kept before it expires. Current objects never expire."}}}, "source": "./modules/frontend_cdn"}, "lambda_action": {"expressions": {"attach_gateway_target_grant": {"constant_value": true}, "config_parameter_arns": {"references": ["local.routed_tool_names", "each.key", "local.api_allowed_client_ids_parameter_arn"]}, "cursor_kms_grant_enabled": {"references": ["local.cursor_tools", "each.key"]}, "cursor_kms_key_arn": {"references": ["local.cursor_tools", "each.key", "aws_kms_key.cursor.arn", "aws_kms_key.cursor"]}, "denied_own_table_actions": {"references": ["local.tool_dynamodb_grants", "each.key", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "local.tool_dynamodb_grants", "each.key", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb", "local.tool_dynamodb_grants", "each.key"]}, "dynamodb_grants": {"references": ["local.tool_dynamodb_grants", "each.key", "module.dynamodb.table_arns", "module.dynamodb", "local.tool_query_indexes", "each.key", "local.tool_query_indexes", "each.key", "module.dynamodb.gsi_arns", "module.dynamodb", "module.dynamodb.gsi_arns", "module.dynamodb", "local.tool_query_indexes", "each.key"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["local.name_prefix", "local.routed_tool_names", "each.key", "local.api_allowed_client_ids_parameter_name", "local.cursor_tools", "each.key", "aws_kms_key.cursor.arn", "aws_kms_key.cursor"]}, "filename": {"references": ["var.lambda_build_dir", "each.key"]}, "function_name": {"references": ["each.key"]}, "gateway_target_role_arn": {"references": ["aws_iam_role.agentcore_gateway.arn", "aws_iam_role.agentcore_gateway"]}, "handler": {"references": ["each.value.handler", "each.value"]}, "memory_size_mb": {"constant_value": 256}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency", "each.key"]}, "runtime": {"constant_value": "python3.13"}, "source_code_hash": {"references": ["var.lambda_build_dir", "each.key"]}, "table_action_role_matrix_entries": {"references": ["local.tool_dynamodb_grants", "each.key", "each.key"]}, "timeout_seconds": {"constant_value": 30}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "for_each_expression": {"references": ["local.tools"]}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "config_parameter_arns": {"default": [], "description": "SSM parameter ARNs the function reads at runtime. Each is granted `ssm:GetParameter` in the `-logs` policy; no wildcard."}, "cursor_kms_grant_enabled": {"default": false, "description": "Whether the `-dynamodb-kms` policy also grants use of `cursor_kms_key_arn`, as a plan-time-known flag. Requires `dynamodb_kms_grant_enabled`."}, "cursor_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key that seals pagination cursors. The role's\n`-dynamodb-kms` policy grants `kms:Encrypt` and `kms:Decrypt` on it only with the\nencryption context `purpose = crm-cursor`. Required when `cursor_kms_grant_enabled` is true.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.13", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_capabilities": {"expressions": {"config_parameter_arns": {"references": ["local.api_allowed_client_ids_parameter_arn"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_grants": {"constant_value": []}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["local.api_allowed_client_ids_parameter_name"]}, "filename": {"references": ["local.eval_lambda_zip"]}, "function_name": {"constant_value": "crm-agent-eval-capabilities"}, "gateway_target_role_arn": {"constant_value": null}, "handler": {"constant_value": "crm.handlers.capabilities.handler"}, "memory_size_mb": {"constant_value": 256}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"capabilities\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.13"}, "source_code_hash": {"references": ["local.eval_lambda_zip"]}, "timeout_seconds": {"constant_value": 10}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "config_parameter_arns": {"default": [], "description": "SSM parameter ARNs the function reads at runtime. Each is granted `ssm:GetParameter` in the `-logs` policy; no wildcard."}, "cursor_kms_grant_enabled": {"default": false, "description": "Whether the `-dynamodb-kms` policy also grants use of `cursor_kms_key_arn`, as a plan-time-known flag. Requires `dynamodb_kms_grant_enabled`."}, "cursor_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key that seals pagination cursors. The role's\n`-dynamodb-kms` policy grants `kms:Encrypt` and `kms:Decrypt` on it only with the\nencryption context `purpose = crm-cursor`. Required when `cursor_kms_grant_enabled` is true.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.13", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_chat_interceptor": {"expressions": {"attach_gateway_target_grant": {"constant_value": true}, "denied_own_table_actions": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_grants": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb", "local.gateway_service_principal_rep_id"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["var.aws_region", "module.cognito.user_pool_id", "module.cognito", "module.cognito.chat_gateway_allowed_client_ids", "module.cognito", "var.aws_region", "module.cognito.user_pool_id", "module.cognito", "module.cognito.chat_scope_identifier", "module.cognito", "local.gateway_service_principal_rep_id", "local.name_prefix"]}, "filename": {"references": ["var.lambda_build_dir"]}, "function_name": {"references": ["local.name_prefix"]}, "gateway_target_role_arn": {"references": ["module.mcp_chat_gateway.role_arn", "module.mcp_chat_gateway"]}, "handler": {"constant_value": "gateway.identity_interceptor.lambda_handler"}, "memory_size_mb": {"constant_value": 256}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"chat_interceptor\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.13"}, "source_code_hash": {"references": ["var.lambda_build_dir"]}, "table_action_role_matrix_entries": {"references": ["local.name_prefix"]}, "timeout_seconds": {"constant_value": 10}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "config_parameter_arns": {"default": [], "description": "SSM parameter ARNs the function reads at runtime. Each is granted `ssm:GetParameter` in the `-logs` policy; no wildcard."}, "cursor_kms_grant_enabled": {"default": false, "description": "Whether the `-dynamodb-kms` policy also grants use of `cursor_kms_key_arn`, as a plan-time-known flag. Requires `dynamodb_kms_grant_enabled`."}, "cursor_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key that seals pagination cursors. The role's\n`-dynamodb-kms` policy grants `kms:Encrypt` and `kms:Decrypt` on it only with the\nencryption context `purpose = crm-cursor`. Required when `cursor_kms_grant_enabled` is true.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.13", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_chat_target": {"expressions": {"attach_gateway_target_grant": {"constant_value": true}, "denied_own_table_actions": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_grants": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb", "module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["local.name_prefix", "module.agentcore.agent_runtime_arn", "module.agentcore", "local.relay_runtime_qualifier"]}, "filename": {"references": ["var.lambda_build_dir"]}, "function_name": {"references": ["local.name_prefix"]}, "gateway_target_role_arn": {"references": ["module.mcp_chat_gateway.role_arn", "module.mcp_chat_gateway"]}, "handler": {"constant_value": "gateway.chat_target.lambda_handler"}, "memory_size_mb": {"constant_value": 512}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"chat_target\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.13"}, "source_code_hash": {"references": ["var.lambda_build_dir"]}, "table_action_role_matrix_entries": {"references": ["local.name_prefix", "local.name_prefix"]}, "timeout_seconds": {"constant_value": 660}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "config_parameter_arns": {"default": [], "description": "SSM parameter ARNs the function reads at runtime. Each is granted `ssm:GetParameter` in the `-logs` policy; no wildcard."}, "cursor_kms_grant_enabled": {"default": false, "description": "Whether the `-dynamodb-kms` policy also grants use of `cursor_kms_key_arn`, as a plan-time-known flag. Requires `dynamodb_kms_grant_enabled`."}, "cursor_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key that seals pagination cursors. The role's\n`-dynamodb-kms` policy grants `kms:Encrypt` and `kms:Decrypt` on it only with the\nencryption context `purpose = crm-cursor`. Required when `cursor_kms_grant_enabled` is true.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.13", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_eval_trigger": {"expressions": {"config_parameter_arns": {"references": ["local.api_allowed_client_ids_parameter_arn"]}, "denied_own_table_actions": {"references": ["module.dynamodb.table_arns[\"eval_runs\"]", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "local.eval_trigger_eval_runs_grants", "module.dynamodb.table_arns[\"eval_runs\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_grants": {"references": ["local.eval_trigger_eval_runs_grants"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["local.name_prefix", "local.api_allowed_client_ids_parameter_name", "local.eval_sweep_state_machine_arn", "module.eval_artifacts.bucket_name", "module.eval_artifacts", "module.eval_artifacts.artifact_prefix", "module.eval_artifacts"]}, "filename": {"references": ["local.eval_lambda_zip"]}, "function_name": {"constant_value": "crm-agent-eval-eval-trigger"}, "gateway_target_role_arn": {"constant_value": null}, "handler": {"constant_value": "crm.handlers.eval_trigger.handler"}, "memory_size_mb": {"constant_value": 512}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"eval_trigger\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.13"}, "source_code_hash": {"references": ["local.eval_lambda_zip"]}, "timeout_seconds": {"constant_value": 30}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "config_parameter_arns": {"default": [], "description": "SSM parameter ARNs the function reads at runtime. Each is granted `ssm:GetParameter` in the `-logs` policy; no wildcard."}, "cursor_kms_grant_enabled": {"default": false, "description": "Whether the `-dynamodb-kms` policy also grants use of `cursor_kms_key_arn`, as a plan-time-known flag. Requires `dynamodb_kms_grant_enabled`."}, "cursor_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key that seals pagination cursors. The role's\n`-dynamodb-kms` policy grants `kms:Encrypt` and `kms:Decrypt` on it only with the\nencryption context `purpose = crm-cursor`. Required when `cursor_kms_grant_enabled` is true.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.13", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_interceptor": {"expressions": {"attach_gateway_target_grant": {"constant_value": true}, "denied_own_table_actions": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_grants": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb", "local.gateway_service_principal_rep_id"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["var.aws_region", "module.cognito.user_pool_id", "module.cognito", "module.cognito.allowed_client_ids", "module.cognito", "var.aws_region", "module.cognito.user_pool_id", "module.cognito", "module.cognito.gateway_scope_identifier", "module.cognito", "local.gateway_service_principal_rep_id", "local.name_prefix"]}, "filename": {"references": ["var.lambda_build_dir"]}, "function_name": {"constant_value": "crm-agent-eval-identity-interceptor"}, "gateway_target_role_arn": {"references": ["aws_iam_role.agentcore_gateway.arn", "aws_iam_role.agentcore_gateway"]}, "handler": {"constant_value": "gateway.identity_interceptor.lambda_handler"}, "memory_size_mb": {"constant_value": 256}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"identity_interceptor\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.13"}, "source_code_hash": {"references": ["var.lambda_build_dir"]}, "table_action_role_matrix_entries": {"constant_value": [{"action": "dynamodb:GetItem", "isolation_mechanism": "leading_keys", "leading_keys_enforced": true, "role": "crm-agent-eval-identity-interceptor-role", "table": "reps"}]}, "timeout_seconds": {"constant_value": 10}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "config_parameter_arns": {"default": [], "description": "SSM parameter ARNs the function reads at runtime. Each is granted `ssm:GetParameter` in the `-logs` policy; no wildcard."}, "cursor_kms_grant_enabled": {"default": false, "description": "Whether the `-dynamodb-kms` policy also grants use of `cursor_kms_key_arn`, as a plan-time-known flag. Requires `dynamodb_kms_grant_enabled`."}, "cursor_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key that seals pagination cursors. The role's\n`-dynamodb-kms` policy grants `kms:Encrypt` and `kms:Decrypt` on it only with the\nencryption context `purpose = crm-cursor`. Required when `cursor_kms_grant_enabled` is true.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.13", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_pre_token_generation": {"expressions": {"attach_gateway_target_grant": {"constant_value": true}, "denied_own_table_actions": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_grants": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["local.name_prefix", "local.chat_scope_identifier"]}, "filename": {"references": ["var.lambda_build_dir"]}, "function_name": {"constant_value": "crm-agent-eval-pre-token-generation"}, "gateway_target_role_arn": {"references": ["aws_iam_role.agentcore_gateway.arn", "aws_iam_role.agentcore_gateway"]}, "handler": {"constant_value": "crm.auth.pre_token_generation.lambda_handler"}, "memory_size_mb": {"constant_value": 128}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"pre_token_generation\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.13"}, "source_code_hash": {"references": ["var.lambda_build_dir"]}, "table_action_role_matrix_entries": {"constant_value": [{"action": "dynamodb:GetItem", "isolation_mechanism": "not_applicable", "leading_keys_enforced": false, "role": "crm-agent-eval-pre-token-generation-role", "table": "reps"}]}, "timeout_seconds": {"constant_value": 10}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "config_parameter_arns": {"default": [], "description": "SSM parameter ARNs the function reads at runtime. Each is granted `ssm:GetParameter` in the `-logs` policy; no wildcard."}, "cursor_kms_grant_enabled": {"default": false, "description": "Whether the `-dynamodb-kms` policy also grants use of `cursor_kms_key_arn`, as a plan-time-known flag. Requires `dynamodb_kms_grant_enabled`."}, "cursor_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key that seals pagination cursors. The role's\n`-dynamodb-kms` policy grants `kms:Encrypt` and `kms:Decrypt` on it only with the\nencryption context `purpose = crm-cursor`. Required when `cursor_kms_grant_enabled` is true.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.13", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_sweep_control": {"expressions": {"denied_own_table_actions": {"references": ["local.sweep_control_granted_tables", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "local.sweep_control_dynamodb_grants", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb", "local.sweep_control_granted_tables"]}, "dynamodb_allow_statements_per_policy": {"constant_value": 20}, "dynamodb_grants": {"references": ["local.sweep_control_dynamodb_grants", "module.dynamodb.table_arns", "module.dynamodb", "module.dynamodb.gsi_arns", "module.dynamodb", "module.dynamodb.gsi_arns", "module.dynamodb"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "dynamodb_policy_managed": {"constant_value": true}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["local.name_prefix", "module.eval_artifacts.bucket_name", "module.eval_artifacts", "module.eval_artifacts.artifact_prefix", "module.eval_artifacts"]}, "filename": {"references": ["local.eval_lambda_zip"]}, "function_name": {"constant_value": "crm-agent-eval-sweep-control"}, "gateway_target_role_arn": {"constant_value": null}, "handler": {"constant_value": "eval.sfn_handlers.sweep_control_handler"}, "memory_size_mb": {"constant_value": 1024}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"sweep_control\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.13"}, "source_code_hash": {"references": ["local.eval_lambda_zip"]}, "tags": {"references": ["var.data_classification"]}, "timeout_seconds": {"constant_value": 120}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "config_parameter_arns": {"default": [], "description": "SSM parameter ARNs the function reads at runtime. Each is granted `ssm:GetParameter` in the `-logs` policy; no wildcard."}, "cursor_kms_grant_enabled": {"default": false, "description": "Whether the `-dynamodb-kms` policy also grants use of `cursor_kms_key_arn`, as a plan-time-known flag. Requires `dynamodb_kms_grant_enabled`."}, "cursor_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key that seals pagination cursors. The role's\n`-dynamodb-kms` policy grants `kms:Encrypt` and `kms:Decrypt` on it only with the\nencryption context `purpose = crm-cursor`. Required when `cursor_kms_grant_enabled` is true.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.13", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_sweep_task": {"expressions": {"denied_own_table_actions": {"references": ["local.sweep_task_granted_tables", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "local.sweep_task_dynamodb_grants", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb", "local.sweep_task_granted_tables"]}, "dynamodb_grants": {"references": ["local.sweep_task_dynamodb_grants", "module.dynamodb.table_arns", "module.dynamodb", "module.dynamodb.gsi_arns", "module.dynamodb"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "dynamodb_policy_managed": {"constant_value": true}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["local.name_prefix", "module.agentcore.agent_runtime_arn", "module.agentcore", "local.relay_runtime_qualifier"]}, "filename": {"references": ["local.eval_lambda_zip"]}, "function_name": {"constant_value": "crm-agent-eval-sweep-task"}, "gateway_target_role_arn": {"constant_value": null}, "handler": {"constant_value": "eval.sfn_handlers.sweep_task_handler"}, "memory_size_mb": {"constant_value": 1024}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"sweep_task\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.13"}, "source_code_hash": {"references": ["local.eval_lambda_zip"]}, "tags": {"references": ["var.data_classification"]}, "timeout_seconds": {"constant_value": 300}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "config_parameter_arns": {"default": [], "description": "SSM parameter ARNs the function reads at runtime. Each is granted `ssm:GetParameter` in the `-logs` policy; no wildcard."}, "cursor_kms_grant_enabled": {"default": false, "description": "Whether the `-dynamodb-kms` policy also grants use of `cursor_kms_key_arn`, as a plan-time-known flag. Requires `dynamodb_kms_grant_enabled`."}, "cursor_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key that seals pagination cursors. The role's\n`-dynamodb-kms` policy grants `kms:Encrypt` and `kms:Decrypt` on it only with the\nencryption context `purpose = crm-cursor`. Required when `cursor_kms_grant_enabled` is true.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.13", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_user_settings": {"expressions": {"config_parameter_arns": {"references": ["local.api_allowed_client_ids_parameter_arn"]}, "denied_own_table_actions": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_grants": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["local.name_prefix", "local.api_allowed_client_ids_parameter_name"]}, "filename": {"references": ["local.eval_lambda_zip"]}, "function_name": {"references": ["local.name_prefix"]}, "gateway_target_role_arn": {"constant_value": null}, "handler": {"constant_value": "crm.handlers.user_settings.handler"}, "memory_size_mb": {"constant_value": 256}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"user_settings\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.13"}, "source_code_hash": {"references": ["local.eval_lambda_zip"]}, "table_action_role_matrix_entries": {"references": ["local.name_prefix"]}, "timeout_seconds": {"constant_value": 10}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "config_parameter_arns": {"default": [], "description": "SSM parameter ARNs the function reads at runtime. Each is granted `ssm:GetParameter` in the `-logs` policy; no wildcard."}, "cursor_kms_grant_enabled": {"default": false, "description": "Whether the `-dynamodb-kms` policy also grants use of `cursor_kms_key_arn`, as a plan-time-known flag. Requires `dynamodb_kms_grant_enabled`."}, "cursor_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key that seals pagination cursors. The role's\n`-dynamodb-kms` policy grants `kms:Encrypt` and `kms:Decrypt` on it only with the\nencryption context `purpose = crm-cursor`. Required when `cursor_kms_grant_enabled` is true.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.13", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "mcp_chat_gateway": {"expressions": {"account_id": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "aws_region": {"references": ["var.aws_region"]}, "chat_target_lambda_arn": {"references": ["module.lambda_action_chat_target.function_arn", "module.lambda_action_chat_target"]}, "cognito_allowed_client_ids": {"references": ["module.cognito.chat_gateway_allowed_client_ids", "module.cognito"]}, "cognito_allowed_scopes": {"references": ["module.cognito.chat_scope_identifier", "module.cognito"]}, "cognito_discovery_url": {"references": ["var.aws_region", "module.cognito.user_pool_id", "module.cognito"]}, "gateway_name": {"references": ["local.name_prefix"]}, "identity_interceptor_lambda_arn": {"references": ["module.lambda_action_chat_interceptor.function_arn", "module.lambda_action_chat_interceptor"]}, "identity_interceptor_lambda_function_name": {"references": ["module.lambda_action_chat_interceptor.function_name", "module.lambda_action_chat_interceptor"]}, "role_name": {"references": ["local.name_prefix"]}, "tags": {"references": ["var.data_classification"]}}, "module": {"outputs": {"gateway_arn": {"description": "Gateway #2 ARN; the interceptor permission's `source_arn`.", "expression": {"references": ["aws_bedrockagentcore_gateway.this.gateway_arn", "aws_bedrockagentcore_gateway.this"]}}, "gateway_id": {"description": "Gateway #2 id.", "expression": {"references": ["aws_bedrockagentcore_gateway.this.gateway_id", "aws_bedrockagentcore_gateway.this"]}}, "gateway_url": {"description": "MCP endpoint URL of Gateway #2.", "expression": {"references": ["aws_bedrockagentcore_gateway.this.gateway_url", "aws_bedrockagentcore_gateway.this"]}}, "role_arn": {"description": "Gateway #2 execution role ARN; the only Gateway principal admitted by the chat target's resource policy.", "expression": {"references": ["aws_iam_role.gateway.arn", "aws_iam_role.gateway"]}}, "role_name": {"description": "Gateway #2 execution role name.", "expression": {"references": ["aws_iam_role.gateway.name", "aws_iam_role.gateway"]}}}, "resources": [{"address": "aws_bedrockagentcore_gateway.this", "depends_on": ["aws_iam_role_policy.gateway"], "expressions": {"authorizer_configuration": [{"custom_jwt_authorizer": [{"allowed_audience": {"constant_value": null}, "allowed_clients": {"references": ["var.cognito_allowed_client_ids"]}, "allowed_scopes": {"references": ["var.cognito_allowed_scopes"]}, "discovery_url": {"references": ["var.cognito_discovery_url"]}}]}], "authorizer_type": {"constant_value": "CUSTOM_JWT"}, "interceptor_configuration": [{"input_configuration": [{"pass_request_headers": {"constant_value": true}}], "interception_points": {"constant_value": ["REQUEST"]}, "interceptor": [{"lambda": [{"arn": {"references": ["var.identity_interceptor_lambda_arn"]}}]}]}], "name": {"references": ["var.gateway_name"]}, "protocol_configuration": [{"mcp": [{"supported_versions": {"constant_value": ["2025-03-26", "2025-06-18", "2025-11-25"]}}]}], "protocol_type": {"constant_value": "MCP"}, "region": {"references": ["var.aws_region"]}, "role_arn": {"references": ["aws_iam_role.gateway.arn", "aws_iam_role.gateway"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_bedrockagentcore_gateway"}, {"address": "aws_bedrockagentcore_gateway_target.chat", "expressions": {"credential_provider_configuration": [{"gateway_iam_role": [{}]}], "description": {"constant_value": "Gateway target for chat_with_supervisor, backed by the chat_target Lambda."}, "gateway_identifier": {"references": ["aws_bedrockagentcore_gateway.this.gateway_id", "aws_bedrockagentcore_gateway.this"]}, "name": {"constant_value": "chat-with-supervisor"}, "target_configuration": [{"mcp": [{"lambda": [{"lambda_arn": {"references": ["var.chat_target_lambda_arn"]}, "tool_schema": [{"inline_payload": [{"description": {"constant_value": "Send one message to the CRM supervisor agent and receive its answer. Pass the returned conversation_id on later calls to continue the same conversation."}, "input_schema": [{"property": [{"description": {"constant_value": "The message to send, 1 to 8000 characters."}, "name": {"constant_value": "message"}, "required": {"constant_value": true}, "type": {"constant_value": "string"}}, {"description": {"constant_value": "A conversation_id returned by an earlier call; omit to start a new conversation."}, "name": {"constant_value": "conversation_id"}, "required": {"constant_value": false}, "type": {"constant_value": "string"}}], "type": {"constant_value": "object"}}], "name": {"constant_value": "chat_with_supervisor"}}]}]}]}]}]}, "mode": "managed", "name": "chat", "provider_config_key": "aws", "schema_version": 0, "type": "aws_bedrockagentcore_gateway_target"}, {"address": "aws_iam_role.gateway", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.role_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "gateway", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.gateway", "expressions": {"name": {"references": ["var.role_name"]}, "policy": {"references": ["data.aws_iam_policy_document.gateway_permissions.json", "data.aws_iam_policy_document.gateway_permissions"]}, "role": {"references": ["aws_iam_role.gateway.id", "aws_iam_role.gateway"]}}, "mode": "managed", "name": "gateway", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_lambda_permission.gateway_invoke_interceptor", "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["var.identity_interceptor_lambda_function_name"]}, "principal": {"constant_value": "bedrock-agentcore.amazonaws.com"}, "source_account": {"references": ["var.account_id"]}, "source_arn": {"references": ["aws_bedrockagentcore_gateway.this.gateway_arn", "aws_bedrockagentcore_gateway.this"]}, "statement_id": {"constant_value": "AllowChatGatewayInvokeIdentityInterceptor"}}, "mode": "managed", "name": "gateway_invoke_interceptor", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["var.account_id"]}, "variable": {"constant_value": "aws:SourceAccount"}}, {"test": {"constant_value": "ArnLike"}, "values": {"references": ["var.aws_region", "var.account_id"]}, "variable": {"constant_value": "aws:SourceArn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["bedrock-agentcore.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.gateway_permissions", "expressions": {"statement": [{"actions": {"constant_value": ["lambda:InvokeFunction"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.chat_target_lambda_arn"]}, "sid": {"constant_value": "InvokeChatTarget"}}, {"actions": {"constant_value": ["lambda:InvokeFunction"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.identity_interceptor_lambda_arn"]}, "sid": {"constant_value": "InvokeInterceptor"}}]}, "mode": "data", "name": "gateway_permissions", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"account_id": {"description": "Account id for the trust policy's `aws:SourceAccount` and `aws:SourceArn` conditions and the interceptor permission's `source_account`."}, "aws_region": {"description": "Region of the gateway; also the region segment of the trust policy's `aws:SourceArn` pattern."}, "chat_target_lambda_arn": {"description": "ARN of the `chat_with_supervisor` target Lambda; the only target this gateway's role may invoke."}, "cognito_allowed_client_ids": {"description": "Cognito app client ids the `CUSTOM_JWT` authorizer accepts, as on Gateway #1."}, "cognito_allowed_scopes": {"description": "Scopes the `CUSTOM_JWT` authorizer accepts: this gateway's own chat scope, never Gateway #1's."}, "cognito_discovery_url": {"description": "OIDC discovery URL of the Cognito user pool, as on Gateway #1."}, "gateway_name": {"description": "Name of the AgentCore Gateway."}, "identity_interceptor_lambda_arn": {"description": "ARN of the shared REQUEST interceptor Lambda."}, "identity_interceptor_lambda_function_name": {"description": "Function name of the shared REQUEST interceptor Lambda, for this gateway's invoke permission."}, "role_name": {"description": "Name of this gateway's own execution role."}, "tags": {"default": {}, "description": "Tags for the gateway and its role. The provider's default_tags carries the mandatory set."}}}, "source": "./modules/mcp_chat_gateway"}, "observability": {"expressions": {"administrator_principal_arns": {"references": ["var.crm_operator_principal_arns", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "caller_principal_arn": {"references": ["data.aws_iam_session_context.current.issuer_arn", "data.aws_iam_session_context.current"]}, "data_classification": {"references": ["var.data_classification"]}, "log_retention_days": {"constant_value": 365}, "logs_key_user_principal_arns": {"references": ["local.logs_key_user_role_arns", "var.crm_operator_principal_arns"]}, "name_prefix": {"references": ["local.name_prefix"]}, "operator_principal_arns": {"references": ["var.crm_operator_principal_arns"]}}, "module": {"outputs": {"cloudtrail_access_logs_bucket_name": {"description": "Name of the S3 bucket receiving the CloudTrail delivery bucket's own S3 server access logs (`aws_s3_bucket_logging.cloudtrail`'s target). Distinct from `cloudtrail_s3_bucket_name`, which is the source of those logs.", "expression": {"references": ["aws_s3_bucket.cloudtrail_access_logs.id", "aws_s3_bucket.cloudtrail_access_logs"]}}, "cloudtrail_arn": {"description": "ARN of the CloudTrail trail for API activity.", "expression": {"references": ["aws_cloudtrail.this.arn", "aws_cloudtrail.this"]}}, "cloudtrail_kms_key_arn": {"description": "ARN of the customer-managed KMS key encrypting the CloudTrail S3 destination bucket.", "expression": {"references": ["aws_kms_key.cloudtrail.arn", "aws_kms_key.cloudtrail"]}}, "cloudtrail_s3_bucket_name": {"description": "Name of the S3 bucket CloudTrail delivers log files to: the log source whose access logs land in `cloudtrail_access_logs_bucket_name`.", "expression": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}}, "cloudwatch_logs_kms_key_arn": {"description": "ARN of the customer-managed KMS key for CloudWatch Logs log-group encryption. Sibling modules' `aws_cloudwatch_log_group` resources pass this as `kms_key_id`.", "expression": {"references": ["aws_kms_key.logs.arn", "aws_kms_key.logs"]}}, "cloudwatch_logs_kms_key_id": {"description": "Key ID of the customer-managed KMS key for CloudWatch Logs log-group encryption.", "expression": {"references": ["aws_kms_key.logs.key_id", "aws_kms_key.logs"]}}, "eval_metric_namespace": {"description": "CloudWatch custom metric namespace reserved for eval-run metrics; passthrough of `var.eval_metric_namespace`.", "expression": {"references": ["var.eval_metric_namespace"]}}}, "resources": [{"address": "aws_cloudtrail.this", "depends_on": ["aws_s3_bucket_policy.cloudtrail"], "expressions": {"cloud_watch_logs_group_arn": {"references": ["var.enable_cloudtrail_cloudwatch_logs", "aws_cloudwatch_log_group.cloudtrail[0].arn", "aws_cloudwatch_log_group.cloudtrail[0]", "aws_cloudwatch_log_group.cloudtrail"]}, "cloud_watch_logs_role_arn": {"references": ["var.enable_cloudtrail_cloudwatch_logs", "aws_iam_role.cloudtrail_cloudwatch_logs[0].arn", "aws_iam_role.cloudtrail_cloudwatch_logs[0]", "aws_iam_role.cloudtrail_cloudwatch_logs"]}, "enable_log_file_validation": {"constant_value": true}, "event_selector": [{"include_management_events": {"constant_value": true}, "read_write_type": {"constant_value": "All"}}], "include_global_service_events": {"constant_value": true}, "is_multi_region_trail": {"constant_value": true}, "kms_key_id": {"references": ["aws_kms_key.cloudtrail.arn", "aws_kms_key.cloudtrail"]}, "name": {"references": ["local.cloudtrail_name"]}, "s3_bucket_name": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}, "tags": {"references": ["var.tags", "var.data_classification"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 1, "type": "aws_cloudtrail"}, {"address": "aws_cloudwatch_log_group.cloudtrail", "count_expression": {"references": ["var.enable_cloudtrail_cloudwatch_logs"]}, "expressions": {"kms_key_id": {"references": ["aws_kms_key.logs.arn", "aws_kms_key.logs"]}, "name": {"references": ["var.name_prefix"]}, "retention_in_days": {"references": ["var.log_retention_days"]}, "tags": {"references": ["var.tags", "var.data_classification"]}}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_role.cloudtrail_cloudwatch_logs", "count_expression": {"references": ["var.enable_cloudtrail_cloudwatch_logs"]}, "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.cloudtrail_cloudwatch_logs_assume[0].json", "data.aws_iam_policy_document.cloudtrail_cloudwatch_logs_assume[0]", "data.aws_iam_policy_document.cloudtrail_cloudwatch_logs_assume"]}, "name": {"references": ["var.name_prefix"]}, "tags": {"references": ["var.tags", "var.data_classification"]}}, "mode": "managed", "name": "cloudtrail_cloudwatch_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.cloudtrail_cloudwatch_logs", "count_expression": {"references": ["var.enable_cloudtrail_cloudwatch_logs"]}, "expressions": {"name": {"references": ["var.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.cloudtrail_cloudwatch_logs_delivery[0].json", "data.aws_iam_policy_document.cloudtrail_cloudwatch_logs_delivery[0]", "data.aws_iam_policy_document.cloudtrail_cloudwatch_logs_delivery"]}, "role": {"references": ["aws_iam_role.cloudtrail_cloudwatch_logs[0].id", "aws_iam_role.cloudtrail_cloudwatch_logs[0]", "aws_iam_role.cloudtrail_cloudwatch_logs"]}}, "mode": "managed", "name": "cloudtrail_cloudwatch_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_kms_alias.cloudtrail", "expressions": {"name": {"references": ["var.name_prefix"]}, "target_key_id": {"references": ["aws_kms_key.cloudtrail.key_id", "aws_kms_key.cloudtrail"]}}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_alias"}, {"address": "aws_kms_alias.logs", "expressions": {"name": {"references": ["var.name_prefix"]}, "target_key_id": {"references": ["aws_kms_key.logs.key_id", "aws_kms_key.logs"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_alias"}, {"address": "aws_kms_key.cloudtrail", "expressions": {"bypass_policy_lockout_safety_check": {"constant_value": false}, "deletion_window_in_days": {"constant_value": 30}, "description": {"constant_value": "CMK for CloudTrail S3 log destination encryption at rest"}, "enable_key_rotation": {"constant_value": true}, "policy": {"references": ["data.aws_iam_policy_document.cloudtrail_cmk.json", "data.aws_iam_policy_document.cloudtrail_cmk"]}, "tags": {"references": ["var.tags", "var.data_classification"]}}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key"}, {"address": "aws_kms_key.logs", "expressions": {"bypass_policy_lockout_safety_check": {"constant_value": false}, "deletion_window_in_days": {"constant_value": 30}, "description": {"constant_value": "CMK for CloudWatch Logs log group encryption at rest"}, "enable_key_rotation": {"constant_value": true}, "policy": {"references": ["data.aws_iam_policy_document.cloudwatch_logs_cmk.json", "data.aws_iam_policy_document.cloudwatch_logs_cmk"]}, "tags": {"references": ["var.tags", "var.data_classification"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key"}, {"address": "aws_s3_bucket.cloudtrail", "expressions": {"bucket": {"references": ["var.name_prefix", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "force_destroy": {"constant_value": true}, "tags": {"references": ["var.tags", "var.data_classification"]}}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket"}, {"address": "aws_s3_bucket.cloudtrail_access_logs", "expressions": {"bucket": {"references": ["var.name_prefix", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "force_destroy": {"constant_value": true}, "tags": {"references": ["var.tags", "var.data_classification"]}}, "mode": "managed", "name": "cloudtrail_access_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket"}, {"address": "aws_s3_bucket_lifecycle_configuration.cloudtrail", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}, "rule": [{"abort_incomplete_multipart_upload": [{"days_after_initiation": {"constant_value": 7}}], "expiration": [{"days": {"references": ["var.cloudtrail_s3_log_retention_days"]}}], "filter": [{}], "id": {"constant_value": "expire-trail-logs"}, "noncurrent_version_expiration": [{"noncurrent_days": {"references": ["var.cloudtrail_s3_log_retention_days"]}}], "status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 1, "type": "aws_s3_bucket_lifecycle_configuration"}, {"address": "aws_s3_bucket_lifecycle_configuration.cloudtrail_access_logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail_access_logs.id", "aws_s3_bucket.cloudtrail_access_logs"]}, "rule": [{"abort_incomplete_multipart_upload": [{"days_after_initiation": {"constant_value": 7}}], "expiration": [{"days": {"references": ["var.cloudtrail_s3_log_retention_days"]}}], "filter": [{}], "id": {"constant_value": "expire-access-logs"}, "noncurrent_version_expiration": [{"noncurrent_days": {"references": ["var.cloudtrail_s3_log_retention_days"]}}], "status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "cloudtrail_access_logs", "provider_config_key": "aws", "schema_version": 1, "type": "aws_s3_bucket_lifecycle_configuration"}, {"address": "aws_s3_bucket_logging.cloudtrail", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}, "target_bucket": {"references": ["aws_s3_bucket.cloudtrail_access_logs.id", "aws_s3_bucket.cloudtrail_access_logs"]}, "target_prefix": {"constant_value": "s3-access-logs/cloudtrail/"}}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_logging"}, {"address": "aws_s3_bucket_ownership_controls.cloudtrail", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}, "rule": [{"object_ownership": {"constant_value": "BucketOwnerEnforced"}}]}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_ownership_controls"}, {"address": "aws_s3_bucket_ownership_controls.cloudtrail_access_logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail_access_logs.id", "aws_s3_bucket.cloudtrail_access_logs"]}, "rule": [{"object_ownership": {"constant_value": "BucketOwnerEnforced"}}]}, "mode": "managed", "name": "cloudtrail_access_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_ownership_controls"}, {"address": "aws_s3_bucket_policy.cloudtrail", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}, "policy": {"references": ["data.aws_iam_policy_document.cloudtrail_bucket.json", "data.aws_iam_policy_document.cloudtrail_bucket"]}}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_policy"}, {"address": "aws_s3_bucket_policy.cloudtrail_access_logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail_access_logs.id", "aws_s3_bucket.cloudtrail_access_logs"]}, "policy": {"references": ["data.aws_iam_policy_document.cloudtrail_access_logs_tls_deny.json", "data.aws_iam_policy_document.cloudtrail_access_logs_tls_deny"]}}, "mode": "managed", "name": "cloudtrail_access_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_policy"}, {"address": "aws_s3_bucket_public_access_block.cloudtrail", "expressions": {"block_public_acls": {"constant_value": true}, "block_public_policy": {"constant_value": true}, "bucket": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}, "ignore_public_acls": {"constant_value": true}, "restrict_public_buckets": {"constant_value": true}}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_public_access_block"}, {"address": "aws_s3_bucket_public_access_block.cloudtrail_access_logs", "expressions": {"block_public_acls": {"constant_value": true}, "block_public_policy": {"constant_value": true}, "bucket": {"references": ["aws_s3_bucket.cloudtrail_access_logs.id", "aws_s3_bucket.cloudtrail_access_logs"]}, "ignore_public_acls": {"constant_value": true}, "restrict_public_buckets": {"constant_value": true}}, "mode": "managed", "name": "cloudtrail_access_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_public_access_block"}, {"address": "aws_s3_bucket_server_side_encryption_configuration.cloudtrail", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}, "rule": [{"apply_server_side_encryption_by_default": [{"kms_master_key_id": {"references": ["aws_kms_key.cloudtrail.arn", "aws_kms_key.cloudtrail"]}, "sse_algorithm": {"constant_value": "aws:kms"}}], "bucket_key_enabled": {"constant_value": true}}]}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_server_side_encryption_configuration"}, {"address": "aws_s3_bucket_server_side_encryption_configuration.cloudtrail_access_logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail_access_logs.id", "aws_s3_bucket.cloudtrail_access_logs"]}, "rule": [{"apply_server_side_encryption_by_default": [{"sse_algorithm": {"constant_value": "AES256"}}], "bucket_key_enabled": {"constant_value": true}}]}, "mode": "managed", "name": "cloudtrail_access_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_server_side_encryption_configuration"}, {"address": "aws_s3_bucket_versioning.cloudtrail", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}, "versioning_configuration": [{"status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_versioning"}, {"address": "aws_s3_bucket_versioning.cloudtrail_access_logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail_access_logs.id", "aws_s3_bucket.cloudtrail_access_logs"]}, "versioning_configuration": [{"status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "cloudtrail_access_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_versioning"}, {"address": "data.aws_caller_identity.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_caller_identity"}, {"address": "data.aws_iam_policy_document.cloudtrail_access_logs_tls_deny", "expressions": {"statement": [{"actions": {"constant_value": ["s3:PutObject"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "aws:SourceAccount"}}, {"test": {"constant_value": "ArnLike"}, "values": {"references": ["aws_s3_bucket.cloudtrail.arn", "aws_s3_bucket.cloudtrail"]}, "variable": {"constant_value": "aws:SourceArn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["logging.s3.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"references": ["aws_s3_bucket.cloudtrail_access_logs.arn", "aws_s3_bucket.cloudtrail_access_logs"]}, "sid": {"constant_value": "AllowS3ServerAccessLogDelivery"}}, {"actions": {"constant_value": ["s3:*"]}, "condition": [{"test": {"constant_value": "Bool"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:SecureTransport"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["aws_s3_bucket.cloudtrail_access_logs.arn", "aws_s3_bucket.cloudtrail_access_logs", "aws_s3_bucket.cloudtrail_access_logs.arn", "aws_s3_bucket.cloudtrail_access_logs"]}, "sid": {"constant_value": "DenyInsecureTransport"}}]}, "mode": "data", "name": "cloudtrail_access_logs_tls_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.cloudtrail_bucket", "expressions": {"statement": [{"actions": {"constant_value": ["s3:*"]}, "condition": [{"test": {"constant_value": "Bool"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:SecureTransport"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["aws_s3_bucket.cloudtrail.arn", "aws_s3_bucket.cloudtrail", "aws_s3_bucket.cloudtrail.arn", "aws_s3_bucket.cloudtrail"]}, "sid": {"constant_value": "DenyInsecureTransport"}}, {"actions": {"constant_value": ["s3:GetBucketAcl"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["local.cloudtrail_arn"]}, "variable": {"constant_value": "aws:SourceArn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["cloudtrail.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"references": ["aws_s3_bucket.cloudtrail.arn", "aws_s3_bucket.cloudtrail"]}, "sid": {"constant_value": "AWSCloudTrailAclCheck"}}, {"actions": {"constant_value": ["s3:PutObject"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["local.cloudtrail_arn"]}, "variable": {"constant_value": "aws:SourceArn"}}, {"test": {"constant_value": "StringEquals"}, "values": {"constant_value": ["bucket-owner-full-control"]}, "variable": {"constant_value": "s3:x-amz-acl"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["cloudtrail.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"references": ["aws_s3_bucket.cloudtrail.arn", "aws_s3_bucket.cloudtrail", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "sid": {"constant_value": "AWSCloudTrailWrite"}}, {"actions": {"constant_value": ["s3:GetObject", "s3:GetObjectVersion", "s3:GetObjectAttributes", "s3:GetObjectVersionAttributes", "s3:GetObjectTagging", "s3:GetObjectVersionTagging", "s3:RestoreObject", "s3:ListBucket", "s3:ListBucketVersions", "s3:ListBucketMultipartUploads", "s3:ListMultipartUploadParts", "s3:PutObject", "s3:PutObjectTagging", "s3:DeleteObject", "s3:DeleteObjectVersion", "s3:DeleteObjectTagging", "s3:AbortMultipartUpload", "s3:PutObjectVersionTagging", "s3:DeleteObjectVersionTagging"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.operator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}, {"test": {"constant_value": "BoolIfExists"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:PrincipalIsAWSService"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"references": ["aws_s3_bucket.cloudtrail.arn", "aws_s3_bucket.cloudtrail", "aws_s3_bucket.cloudtrail.arn", "aws_s3_bucket.cloudtrail"]}, "sid": {"constant_value": "DenyObjectDataPlaneToNonProjectPrincipals"}}, {"actions": {"constant_value": ["s3:DeleteBucket", "s3:PutBucketPolicy", "s3:DeleteBucketPolicy", "s3:PutBucketVersioning", "s3:PutEncryptionConfiguration", "s3:PutLifecycleConfiguration", "s3:PutBucketLogging", "s3:PutBucketPublicAccessBlock", "s3:PutBucketOwnershipControls", "s3:PutBucketAcl", "s3:PutBucketTagging", "s3:PutReplicationConfiguration", "s3:PutInventoryConfiguration", "s3:PutBucketNotification", "s3:PutBucketObjectLockConfiguration", "s3:PutBucketRequestPayment", "s3:PutBucketWebsite", "s3:PutBucketCORS", "s3:PutAccelerateConfiguration", "s3:PutIntelligentTieringConfiguration", "s3:PutAnalyticsConfiguration", "s3:PutMetricsConfiguration"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.administrator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"references": ["aws_s3_bucket.cloudtrail.arn", "aws_s3_bucket.cloudtrail"]}, "sid": {"constant_value": "DenyBucketAdministrationToNonOperators"}}]}, "mode": "data", "name": "cloudtrail_bucket", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.cloudtrail_cloudwatch_logs_assume", "count_expression": {"references": ["var.enable_cloudtrail_cloudwatch_logs"]}, "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["cloudtrail.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "cloudtrail_cloudwatch_logs_assume", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.cloudtrail_cloudwatch_logs_delivery", "count_expression": {"references": ["var.enable_cloudtrail_cloudwatch_logs"]}, "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.cloudtrail[0].arn", "aws_cloudwatch_log_group.cloudtrail[0]", "aws_cloudwatch_log_group.cloudtrail"]}}]}, "mode": "data", "name": "cloudtrail_cloudwatch_logs_delivery", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.cloudtrail_cmk", "expressions": {"statement": [{"actions": {"constant_value": ["kms:*"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "type": {"constant_value": "AWS"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "EnableIAMUserPermissions"}}, {"actions": {"constant_value": ["kms:GenerateDataKey*"]}, "condition": [{"test": {"constant_value": "StringLike"}, "values": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "kms:EncryptionContext:aws:cloudtrail:arn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["cloudtrail.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "AllowCloudTrailToEncryptLogs"}}, {"actions": {"constant_value": ["kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["cloudtrail.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "AllowCloudTrailToDescribeKey"}}, {"actions": {"constant_value": ["kms:Decrypt", "kms:ReEncryptFrom"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "kms:CallerAccount"}}, {"test": {"constant_value": "StringLike"}, "values": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "kms:EncryptionContext:aws:cloudtrail:arn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "AllowPrincipalsInAccountToDecryptLogFiles"}}, {"actions": {"constant_value": ["kms:Decrypt", "kms:Encrypt", "kms:GenerateDataKey*", "kms:ReEncrypt*", "kms:CreateGrant"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.operator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}, {"test": {"constant_value": "Bool"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:PrincipalIsAWSService"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "DenyKeyUseToNonProjectPrincipals"}}, {"actions": {"constant_value": ["kms:PutKeyPolicy", "kms:ScheduleKeyDeletion", "kms:DisableKey", "kms:RevokeGrant", "kms:DisableKeyRotation", "kms:CreateAlias", "kms:UpdateAlias", "kms:DeleteAlias", "kms:TagResource", "kms:UntagResource", "kms:UpdateKeyDescription"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.administrator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "DenyKeyAdministrationToNonOperators"}}]}, "mode": "data", "name": "cloudtrail_cmk", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.cloudwatch_logs_cmk", "expressions": {"statement": [{"actions": {"constant_value": ["kms:*"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "type": {"constant_value": "AWS"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "EnableIAMUserPermissions"}}, {"actions": {"constant_value": ["kms:Encrypt", "kms:Decrypt", "kms:ReEncrypt*", "kms:GenerateDataKey*", "kms:Describe*"]}, "condition": [{"test": {"constant_value": "ArnLike"}, "values": {"references": ["data.aws_region.current.region", "data.aws_region.current", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "kms:EncryptionContext:aws:logs:arn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"references": ["data.aws_region.current.region", "data.aws_region.current"]}, "type": {"constant_value": "Service"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "AllowCloudWatchLogsUseOfTheKey"}}, {"actions": {"constant_value": ["kms:Decrypt", "kms:Encrypt", "kms:GenerateDataKey*", "kms:ReEncrypt*", "kms:CreateGrant"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.logs_key_user_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}, {"test": {"constant_value": "Bool"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:PrincipalIsAWSService"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "DenyKeyUseToNonProjectPrincipals"}}, {"actions": {"constant_value": ["kms:PutKeyPolicy", "kms:ScheduleKeyDeletion", "kms:DisableKey", "kms:RevokeGrant", "kms:DisableKeyRotation", "kms:CreateAlias", "kms:UpdateAlias", "kms:DeleteAlias", "kms:TagResource", "kms:UntagResource", "kms:UpdateKeyDescription"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.administrator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "DenyKeyAdministrationToNonOperators"}}]}, "mode": "data", "name": "cloudwatch_logs_cmk", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_region.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_region"}], "variables": {"administrator_principal_arns": {"description": "IAM role or user ARNs, or the account root, admitted to administration of both CMKs and of the CloudTrail bucket. Every other principal is denied it."}, "caller_principal_arn": {"description": "Role or user ARN of the principal running this plan. The key and bucket policies refuse to plan unless it is a listed administrator other than the account root, so no apply can lock its own caller out."}, "cloudtrail_s3_log_retention_days": {"default": 365, "description": "Lifecycle expiration, in days, for CloudTrail delivered log objects in the trail S3 destination bucket."}, "data_classification": {"default": "confidential", "description": "Value for the `data-classification` tag on resources in this module."}, "enable_cloudtrail_cloudwatch_logs": {"default": false, "description": "Whether the trail also delivers to a CloudWatch Logs log group (via\n`cloud_watch_logs_group_arn`/`cloud_watch_logs_role_arn`), in addition to its S3 destination.\nDefaults to false. The CMK this module creates already grants `logs..amazonaws.com` the\nactions CloudWatch Logs needs.\n"}, "eval_metric_namespace": {"default": "CrmAgentEval/Eval", "description": "CloudWatch custom metric namespace reserved for eval-run metrics. No code\nunder `src/` publishes a CloudWatch metric; eval metrics are written to the\n`matrix.json`/`.md`/`.csv` report files instead.\n"}, "log_retention_days": {"default": 365, "description": "CloudWatch Logs retention, in days, for the CloudTrail CloudWatch Logs integration log group this module creates."}, "logs_key_user_principal_arns": {"description": "IAM role or user ARNs admitted to key use on the CloudWatch Logs CMK: every execution role whose Lambda environment the key encrypts, plus the operators. Every other non-service principal is denied key use."}, "name_prefix": {"default": "", "description": "Prefix applied to resource names, e.g. project or environment scoping."}, "operator_principal_arns": {"description": "IAM role or user ARNs of the operators: the only non-service principals admitted to CloudTrail-key use and to the CloudTrail bucket's data plane."}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-resource override or addition."}}}, "source": "./modules/observability"}, "vpc": {"expressions": {"flow_log_enabled": {"references": ["var.vpc_flow_log_enabled"]}, "flow_log_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "gateway_endpoint_service_names": {"constant_value": ["s3", "dynamodb"]}, "interface_endpoint_service_names": {"references": ["local.vpc_interface_endpoint_services"]}, "name_prefix": {"references": ["local.name_prefix"]}, "nat_gateway_enabled": {"references": ["var.vpc_nat_gateway_enabled"]}, "nat_public_subnet_id": {"references": ["var.vpc_nat_public_subnet_id"]}, "private_route_table_ids": {"references": ["var.vpc_private_route_table_ids"]}, "private_subnet_ids": {"references": ["var.vpc_private_subnet_ids"]}, "region": {"references": ["var.aws_region"]}, "runtime_route_table_ids": {"references": ["var.vpc_runtime_route_table_ids"]}, "runtime_subnet_ids": {"references": ["var.vpc_runtime_subnet_ids"]}, "tags": {"references": ["var.data_classification"]}, "vpc_cidr_block": {"references": ["var.vpc_cidr_block"]}, "vpc_id": {"references": ["var.vpc_id"]}}, "module": {"outputs": {"bedrock_agentcore_vpc_endpoint_id": {"description": "The `bedrock-agentcore` interface endpoint's id, for the runtime resource policies' `aws:SourceVpce`\ncondition: the Deny keyed on it denies every caller not arriving through this endpoint. Read from the\nendpoint map by key. Fails at plan time if `bedrock-agentcore` is absent from the interface list.\n", "expression": {"references": ["aws_vpc_endpoint.interface[\"bedrock-agentcore\"].id", "aws_vpc_endpoint.interface[\"bedrock-agentcore\"]", "aws_vpc_endpoint.interface"]}}, "endpoint_security_group_id": {"description": "The interface-endpoint security group's id.", "expression": {"references": ["aws_security_group.endpoints.id", "aws_security_group.endpoints"]}}, "execute_api_network_interface_ids": {"description": "The `execute-api` endpoint's ENI ids, for the private-origin ALB's target group.\n\n`modules/api_origin` indexes this list positionally under `count = length(var.private_subnet_ids)`,\nso it holds exactly one entry per private subnet; the precondition below asserts the length.\n", "expression": {"references": ["aws_vpc_endpoint.interface[\"execute-api\"].network_interface_ids", "aws_vpc_endpoint.interface[\"execute-api\"]", "aws_vpc_endpoint.interface"]}}, "execute_api_security_group_id": {"description": "The security group on the `execute-api` endpoint's ENIs, and the ALB's single egress destination.\nEvery interface endpoint in this module shares it; its ingress is 443 from the Lambda group, plus\nthe ALB's 443 ingress rule, which the root composition attaches.\n", "expression": {"references": ["aws_security_group.endpoints.id", "aws_security_group.endpoints"]}}, "execute_api_vpc_endpoint_id": {"description": "The `execute-api` interface endpoint's id, for the private REST API's\n`endpoint_configuration.vpc_endpoint_ids` and its resource-policy allowlist. Read from the endpoint\nmap by key. Fails at plan time if `execute-api` is absent from the endpoint list.\n", "expression": {"references": ["aws_vpc_endpoint.interface[\"execute-api\"].id", "aws_vpc_endpoint.interface[\"execute-api\"]", "aws_vpc_endpoint.interface"]}}, "flow_log_group_name": {"description": "The VPC flow-log group name, or null when flow logs are disabled. Read by the access-log delivery smoke check as its source-side target.", "expression": {"references": ["var.flow_log_enabled", "aws_cloudwatch_log_group.flow_logs[0].name", "aws_cloudwatch_log_group.flow_logs[0]", "aws_cloudwatch_log_group.flow_logs"]}}, "gateway_endpoint_service_names": {"description": "Fully-qualified service names of the gateway endpoints created.", "expression": {"references": ["aws_vpc_endpoint.gateway"]}}, "interface_endpoint_service_names": {"description": "Fully-qualified service names of the interface endpoints created, for a Layer 4 check asserting the deployed set.", "expression": {"references": ["aws_vpc_endpoint.interface"]}}, "lambda_security_group_ids": {"description": "The single Lambda security group, for the `security_group_ids` half of every Lambda `vpc_config`. No ingress.", "expression": {"references": ["aws_security_group.lambda.id", "aws_security_group.lambda"]}}, "lambda_subnet_ids": {"description": "Private subnet ids, for the `subnet_ids` half of every Lambda `vpc_config`. Returns `var.private_subnet_ids` alone, sorted; a precondition in `nat.tf` asserts `var.nat_public_subnet_id` is absent from it.", "expression": {"references": ["var.private_subnet_ids"]}}, "nat_gateway_public_ip": {"description": "The NAT gateway Elastic IP, or null when NAT is disabled. A Layer 4 check asserts the relay egress leaves by this address.", "expression": {"references": ["var.nat_gateway_enabled", "aws_eip.nat[0].public_ip", "aws_eip.nat[0]", "aws_eip.nat"]}}, "runtime_security_group_id": {"description": "The dedicated AgentCore Runtime security group's id, for the Runtime's VPC-mode\n`network_mode_config.security_groups`. No ingress; egress only to the endpoint group and the gateway\nprefix lists. Distinct from `lambda_security_group_ids`.\n", "expression": {"references": ["aws_security_group.agent_runtime.id", "aws_security_group.agent_runtime"]}}, "runtime_subnet_ids": {"description": "The Runtime VPC-mode subnet ids, for the Runtime `network_mode_config.subnets`. Returns `var.runtime_subnet_ids` sorted. Empty when the Runtime is not in VPC mode.", "expression": {"references": ["var.runtime_subnet_ids"]}}, "states_vpc_endpoint_id": {"description": "The `states` interface endpoint's id, for the root's endpoint policy scoping it to the eval sweep.\nRead from the endpoint map by key. Fails at plan time if `states` is absent from the\ninterface list.\n", "expression": {"references": ["aws_vpc_endpoint.interface[\"states\"].id", "aws_vpc_endpoint.interface[\"states\"]", "aws_vpc_endpoint.interface"]}}, "vpc_cidr_block": {"description": "The VPC's IPv4 CIDR.", "expression": {"references": ["var.vpc_cidr_block"]}}, "vpc_id": {"description": "The VPC's id.", "expression": {"references": ["var.vpc_id"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.flow_logs", "count_expression": {"references": ["var.flow_log_enabled"]}, "expressions": {"kms_key_id": {"references": ["var.flow_log_kms_key_arn"]}, "name": {"references": ["var.name_prefix"]}, "retention_in_days": {"references": ["var.flow_log_retention_days"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "flow_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_eip.nat", "count_expression": {"references": ["var.nat_gateway_enabled"]}, "expressions": {"domain": {"constant_value": "vpc"}, "tags": {"references": ["var.tags", "var.name_prefix"]}}, "mode": "managed", "name": "nat", "provider_config_key": "aws", "schema_version": 0, "type": "aws_eip"}, {"address": "aws_flow_log.this", "count_expression": {"references": ["var.flow_log_enabled"]}, "depends_on": ["aws_iam_role_policy.flow_logs"], "expressions": {"iam_role_arn": {"references": ["aws_iam_role.flow_logs[0].arn", "aws_iam_role.flow_logs[0]", "aws_iam_role.flow_logs"]}, "log_destination": {"references": ["aws_cloudwatch_log_group.flow_logs[0].arn", "aws_cloudwatch_log_group.flow_logs[0]", "aws_cloudwatch_log_group.flow_logs"]}, "log_destination_type": {"constant_value": "cloud-watch-logs"}, "max_aggregation_interval": {"constant_value": 60}, "tags": {"references": ["var.tags", "var.name_prefix"]}, "traffic_type": {"constant_value": "ALL"}, "vpc_id": {"references": ["var.vpc_id"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 1, "type": "aws_flow_log"}, {"address": "aws_iam_role.flow_logs", "count_expression": {"references": ["var.flow_log_enabled"]}, "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.flow_logs_assume_role[0].json", "data.aws_iam_policy_document.flow_logs_assume_role[0]", "data.aws_iam_policy_document.flow_logs_assume_role"]}, "name": {"references": ["var.name_prefix"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "flow_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.flow_logs", "count_expression": {"references": ["var.flow_log_enabled"]}, "expressions": {"name": {"references": ["var.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.flow_logs_delivery[0].json", "data.aws_iam_policy_document.flow_logs_delivery[0]", "data.aws_iam_policy_document.flow_logs_delivery"]}, "role": {"references": ["aws_iam_role.flow_logs[0].id", "aws_iam_role.flow_logs[0]", "aws_iam_role.flow_logs"]}}, "mode": "managed", "name": "flow_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_nat_gateway.this", "count_expression": {"references": ["var.nat_gateway_enabled"]}, "expressions": {"allocation_id": {"references": ["aws_eip.nat[0].id", "aws_eip.nat[0]", "aws_eip.nat"]}, "subnet_id": {"references": ["var.nat_public_subnet_id"]}, "tags": {"references": ["var.tags", "var.name_prefix"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_nat_gateway"}, {"address": "aws_route.private_nat", "expressions": {"destination_cidr_block": {"constant_value": "0.0.0.0/0"}, "nat_gateway_id": {"references": ["aws_nat_gateway.this[0].id", "aws_nat_gateway.this[0]", "aws_nat_gateway.this"]}, "route_table_id": {"references": ["each.value"]}}, "for_each_expression": {"references": ["var.nat_gateway_enabled", "var.private_route_table_ids"]}, "mode": "managed", "name": "private_nat", "provider_config_key": "aws", "schema_version": 0, "type": "aws_route"}, {"address": "aws_security_group.agent_runtime", "expressions": {"description": {"constant_value": "AgentCore Runtime ENIs: no ingress, egress only to the VPC endpoint group and gateway prefix lists on 443."}, "name": {"references": ["var.name_prefix"]}, "tags": {"references": ["var.tags", "var.name_prefix"]}, "vpc_id": {"references": ["var.vpc_id"]}}, "mode": "managed", "name": "agent_runtime", "provider_config_key": "aws", "schema_version": 1, "type": "aws_security_group"}, {"address": "aws_security_group.endpoints", "expressions": {"description": {"constant_value": "Interface VPC endpoint ENIs: ingress 443 from the Lambda group only, no egress."}, "name": {"references": ["var.name_prefix"]}, "tags": {"references": ["var.tags", "var.name_prefix"]}, "vpc_id": {"references": ["var.vpc_id"]}}, "mode": "managed", "name": "endpoints", "provider_config_key": "aws", "schema_version": 1, "type": "aws_security_group"}, {"address": "aws_security_group.lambda", "expressions": {"description": {"constant_value": "Lambda ENIs: no ingress, egress only to the VPC endpoint group on 443."}, "name": {"references": ["var.name_prefix"]}, "tags": {"references": ["var.tags", "var.name_prefix"]}, "vpc_id": {"references": ["var.vpc_id"]}}, "mode": "managed", "name": "lambda", "provider_config_key": "aws", "schema_version": 1, "type": "aws_security_group"}, {"address": "aws_vpc_endpoint.gateway", "expressions": {"route_table_ids": {"references": ["var.private_route_table_ids", "var.runtime_route_table_ids"]}, "service_name": {"references": ["var.region", "each.key"]}, "tags": {"references": ["var.tags", "var.name_prefix", "each.key"]}, "vpc_endpoint_type": {"constant_value": "Gateway"}, "vpc_id": {"references": ["var.vpc_id"]}}, "for_each_expression": {"references": ["var.gateway_endpoint_service_names"]}, "mode": "managed", "name": "gateway", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_endpoint"}, {"address": "aws_vpc_endpoint.interface", "expressions": {"private_dns_enabled": {"references": ["var.private_dns_disabled_services", "each.key"]}, "security_group_ids": {"references": ["aws_security_group.endpoints.id", "aws_security_group.endpoints"]}, "service_name": {"references": ["var.region", "each.key"]}, "subnet_ids": {"references": ["var.private_subnet_ids"]}, "tags": {"references": ["var.tags", "var.name_prefix", "each.key"]}, "vpc_endpoint_type": {"constant_value": "Interface"}, "vpc_id": {"references": ["var.vpc_id"]}}, "for_each_expression": {"references": ["var.interface_endpoint_service_names"]}, "mode": "managed", "name": "interface", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_endpoint"}, {"address": "aws_vpc_security_group_egress_rule.agent_runtime_to_endpoints", "expressions": {"description": {"constant_value": "HTTPS to the interface VPC endpoints. Reaches bedrock-runtime, ecr.api, ecr.dkr, lambda and logs cross-AZ via private DNS."}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "referenced_security_group_id": {"references": ["aws_security_group.endpoints.id", "aws_security_group.endpoints"]}, "security_group_id": {"references": ["aws_security_group.agent_runtime.id", "aws_security_group.agent_runtime"]}, "to_port": {"constant_value": 443}}, "mode": "managed", "name": "agent_runtime_to_endpoints", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_egress_rule"}, {"address": "aws_vpc_security_group_egress_rule.agent_runtime_to_gateway_endpoints", "expressions": {"description": {"references": ["each.key"]}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "prefix_list_id": {"references": ["aws_vpc_endpoint.gateway", "each.key"]}, "security_group_id": {"references": ["aws_security_group.agent_runtime.id", "aws_security_group.agent_runtime"]}, "to_port": {"constant_value": 443}}, "for_each_expression": {"references": ["var.gateway_endpoint_service_names"]}, "mode": "managed", "name": "agent_runtime_to_gateway_endpoints", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_egress_rule"}, {"address": "aws_vpc_security_group_egress_rule.lambda_https_via_nat", "count_expression": {"references": ["var.nat_gateway_enabled"]}, "expressions": {"cidr_ipv4": {"constant_value": "0.0.0.0/0"}, "description": {"constant_value": "HTTPS egress via the NAT gateway for the relay Cognito JWKS fetch."}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "security_group_id": {"references": ["aws_security_group.lambda.id", "aws_security_group.lambda"]}, "to_port": {"constant_value": 443}}, "mode": "managed", "name": "lambda_https_via_nat", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_egress_rule"}, {"address": "aws_vpc_security_group_egress_rule.lambda_to_endpoints", "expressions": {"description": {"constant_value": "HTTPS to the interface VPC endpoints. The only in-VPC egress any Lambda has."}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "referenced_security_group_id": {"references": ["aws_security_group.endpoints.id", "aws_security_group.endpoints"]}, "security_group_id": {"references": ["aws_security_group.lambda.id", "aws_security_group.lambda"]}, "to_port": {"constant_value": 443}}, "mode": "managed", "name": "lambda_to_endpoints", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_egress_rule"}, {"address": "aws_vpc_security_group_egress_rule.lambda_to_gateway_endpoints", "expressions": {"description": {"references": ["each.key"]}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "prefix_list_id": {"references": ["aws_vpc_endpoint.gateway", "each.key"]}, "security_group_id": {"references": ["aws_security_group.lambda.id", "aws_security_group.lambda"]}, "to_port": {"constant_value": 443}}, "for_each_expression": {"references": ["var.gateway_endpoint_service_names"]}, "mode": "managed", "name": "lambda_to_gateway_endpoints", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_egress_rule"}, {"address": "aws_vpc_security_group_ingress_rule.endpoints_from_agent_runtime", "expressions": {"description": {"constant_value": "HTTPS from the Runtime ENIs. The second SG source on the endpoint group, alongside the Lambda group and the root module ALB rule."}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "referenced_security_group_id": {"references": ["aws_security_group.agent_runtime.id", "aws_security_group.agent_runtime"]}, "security_group_id": {"references": ["aws_security_group.endpoints.id", "aws_security_group.endpoints"]}, "to_port": {"constant_value": 443}}, "mode": "managed", "name": "endpoints_from_agent_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_ingress_rule"}, {"address": "aws_vpc_security_group_ingress_rule.endpoints_from_lambda", "expressions": {"description": {"constant_value": "HTTPS from the Lambda ENIs. One of two ingresses on the endpoint group: the root adds the private-origin ALB for health checks."}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "referenced_security_group_id": {"references": ["aws_security_group.lambda.id", "aws_security_group.lambda"]}, "security_group_id": {"references": ["aws_security_group.endpoints.id", "aws_security_group.endpoints"]}, "to_port": {"constant_value": 443}}, "mode": "managed", "name": "endpoints_from_lambda", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_ingress_rule"}, {"address": "data.aws_iam_policy_document.flow_logs_assume_role", "count_expression": {"references": ["var.flow_log_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["vpc-flow-logs.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "flow_logs_assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.flow_logs_delivery", "count_expression": {"references": ["var.flow_log_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents", "logs:DescribeLogStreams"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.flow_logs[0].arn", "aws_cloudwatch_log_group.flow_logs[0]", "aws_cloudwatch_log_group.flow_logs"]}, "sid": {"constant_value": "DeliverFlowLogsToOwnGroup"}}]}, "mode": "data", "name": "flow_logs_delivery", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"flow_log_enabled": {"default": true, "description": "Whether to deliver VPC flow logs to CloudWatch Logs. A plain `bool` input, so the flow-log `count`\nis known at plan time.\n"}, "flow_log_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the flow-log group."}, "flow_log_retention_days": {"default": 365, "description": "CloudWatch Logs retention, in days, for the flow-log group."}, "gateway_endpoint_service_names": {"default": ["s3", "dynamodb"], "description": "Short service names for the gateway VPC endpoints (route-table entries, not ENIs); only `s3` and `dynamodb` support this form."}, "interface_endpoint_service_names": {"description": "Short service names for the interface (AWS PrivateLink) VPC endpoints this workload needs, e.g.\n`[\"kms\", \"logs\"]`. Each is expanded to `com.amazonaws..`. A Lambda call to an AWS\nservice with no endpoint here presents as a connection timeout, not as an authorization error.\n"}, "name_prefix": {"description": "Prefix for every resource name and `Name` tag this module creates."}, "nat_gateway_enabled": {"description": "Whether to create the egress-only internet path: an EIP and NAT gateway in the adopted IGW-routed\nsubnet, the default route it adds to the adopted private route tables, and a 443-only egress rule on\nthe Lambda group. The NAT gateway admits no inbound connection, and the private subnets are never\nassociated with the public route table (see `nat.tf`).\n\nNo default; plan refuses until a value is set. With `false` the relay cannot fetch the Cognito JWKS\n(the user pool has a domain, so the `cognito-idp` interface endpoint cannot serve it) and every agent\nturn fails authentication. `true` creates a NAT gateway, billed hourly and per GB.\n"}, "nat_public_subnet_id": {"default": null, "description": "Id of an existing IGW-routed subnet in the adopted VPC for the NAT gateway to land in. Required when\n`nat_gateway_enabled` is true; ignored otherwise. No default.\n\nMust not appear in `private_subnet_ids`; a precondition on `aws_nat_gateway.this` in `nat.tf`\nasserts that at plan time.\n"}, "private_dns_disabled_services": {"default": ["execute-api"], "description": "Interface-endpoint services whose private DNS is off. Defaults to `[\"execute-api\"]`: private DNS on\nan `execute-api` endpoint would resolve `*.execute-api..amazonaws.com` to this endpoint for\nevery workload in the adopted VPC. CloudFront routes to the VPC origin by load balancer ARN and uses\nthe hostname only as the `Host` header.\n"}, "private_route_table_ids": {"description": "Route table ids the adopted private subnets use. No default.\n\nMust not be the VPC's main route table, nor a table serving subnets outside `private_subnet_ids`;\npreconditions refuse both at plan time.\n\nTwo consumers: the NAT default route in `nat.tf`, and the gateway endpoints' `route_table_ids` in\n`endpoints.tf`. Every table named here receives a `0.0.0.0/0` route to this stack's NAT gateway;\n`scripts/teardown.sh` removes exactly that route.\n"}, "private_subnet_ids": {"description": "Ids of the existing private subnets in the adopted VPC to place Lambda ENIs in. No default.\n\nThese are the subnets whose route tables receive the NAT default route. They must be private; the\nmodule cannot detect a public subnet from its id.\n"}, "region": {"description": "Region the endpoint service names are built for."}, "runtime_route_table_ids": {"default": [], "description": "Route table ids of the Runtime subnets, associated with the S3/DynamoDB gateway endpoints so ECR\nimage-layer pulls have an S3 path. Separate from `private_route_table_ids`: these tables get no NAT\ndefault route, so the Runtime has no internet path. Empty when the Runtime is not in VPC mode.\n"}, "runtime_subnet_ids": {"default": [], "description": "Subnet ids for the AgentCore Runtime's VPC-mode ENIs, separate from `private_subnet_ids` (which\nfeeds every interface endpoint's `subnet_ids` and the `execute-api` positional-length contract). The\nRuntime reaches the interface endpoints through private DNS, so it needs no local endpoint ENI.\n\nEmpty when the Runtime is not in VPC mode. When non-empty, the subnets must be in AgentCore-supported\nAZs for the region (`infra/regions.json`) and must not include `nat_public_subnet_id`;\n`preflight_adopted_vpc.sh` asserts the AZs and the precondition below asserts the disjointness.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already carries the mandatory tags; this adds or overrides per-resource."}, "vpc_cidr_block": {"description": "The adopted VPC's IPv4 CIDR, used only for the `vpc_cidr_block` output that Layer 4 checks read."}, "vpc_id": {"description": "Id of the existing VPC to adopt. This module creates no VPC.\n\nNo default; set it through the gitignored tfvars. `terraform.tfvars.example` carries a placeholder.\n"}}}, "source": "./modules/vpc"}}, "outputs": {"agent_relay_function_name": {"description": "The relay Lambda's function name, for the relay smoke check's `get-function-configuration` env-var assertions.", "expression": {"references": ["module.agent_relay.function_name", "module.agent_relay"]}}, "agent_relay_function_url": {"description": "The relay Function URL, scheme included. The relay smoke check asserts an unauthenticated call to this hostname, not through the distribution, is denied.", "expression": {"references": ["module.agent_relay.function_url", "module.agent_relay"]}}, "agent_relay_log_group_name": {"description": "The relay Lambda CloudWatch log group name, taken from `aws_cloudwatch_log_group.this.name`. Read by the relay-IAM smoke check to simulate `logs:CreateLogStream`/`logs:PutLogEvents` against the deployed group.", "expression": {"references": ["module.agent_relay.log_group_name", "module.agent_relay"]}}, "agent_relay_role_arn": {"description": "The relay Lambda execution role ARN. Read by `scripts/smoke/iam_roles.py` to simulate the relay rows against the deployed role.", "expression": {"references": ["module.agent_relay.role_arn", "module.agent_relay"]}}, "agentcore_gateway_mcp_url": {"description": "MCP endpoint of Gateway #1: `agentcore_gateway_url` with the `/mcp` path, which the deployed `gatewayUrl` omits.", "expression": {"references": ["module.agentcore.gateway_url", "module.agentcore"]}}, "agentcore_gateway_url": {"description": "AgentCore Gateway invocation URL.", "expression": {"references": ["module.agentcore.gateway_url", "module.agentcore"]}}, "agentcore_runtime_arn": {"description": "Deployed AgentCore Runtime ARN.", "expression": {"references": ["module.agentcore.agent_runtime_arn", "module.agentcore"]}}, "agentcore_runtime_log_group_name": {"description": "CloudWatch Logs group name for the AgentCore Runtime's default endpoint stdout.", "expression": {"references": ["module.agentcore.agent_runtime_log_group_name", "module.agentcore"]}}, "agentcore_runtime_role_arn": {"description": "Execution role ARN of the AgentCore Runtime, the positive-control principal for the relay-IAM smoke check deny rows.", "expression": {"references": ["aws_iam_role.agentcore_runtime.arn", "aws_iam_role.agentcore_runtime"]}}, "api_endpoint": {"description": "The private REST API invoke hostname. Not a public endpoint: it is reachable only through the `execute-api` VPC endpoint, and CloudFront uses it only as a `Host` header. Use `api_id` to identify the API.", "expression": {"references": ["module.api.private_origin_domain_name", "module.api"]}}, "api_id": {"description": "The REST API's id, read by `scripts/smoke/api_routes.py` to identify the API.", "expression": {"references": ["module.api.api_id", "module.api"]}}, "api_origin_alb_arn": {"description": "Internal ALB fronting the private REST API. The CloudFront VPC origin references it by this ARN and performs no DNS lookup.", "expression": {"references": ["module.api_origin.alb_arn", "module.api_origin"]}}, "api_origin_alb_security_group_id": {"description": "The ALB security group, the source of `aws_vpc_security_group_ingress_rule.endpoints_from_api_origin_alb`. A T3 check asserts the endpoint group admits this group.", "expression": {"references": ["module.api_origin.alb_security_group_id", "module.api_origin"]}}, "api_origin_listener_protocol": {"description": "The listener protocol deployed on the ALB. A check asserts the `http-only` listener against the resource.", "expression": {"references": ["module.api_origin.listener_protocol", "module.api_origin"]}}, "api_origin_target_group_arn": {"description": "Target group holding the `execute-api` endpoint ENI IPs. A T3 check reads `describe-target-health` here.", "expression": {"references": ["module.api_origin.target_group_arn", "module.api_origin"]}}, "api_origin_vpc_origin_id": {"description": "Id of the CloudFront VPC origin, which `module.frontend_cdn` consumes as `api_origin_vpc_origin_id` for the `/api/*` origin `vpc_origin_config`. A T3 check asserts the deployed distribution routes `/api/*` through this origin.", "expression": {"references": ["module.api_origin.vpc_origin_id", "module.api_origin"]}}, "api_stage_invoke_url": {"description": "Full invoke URL for the deployed API stage.", "expression": {"references": ["module.api.stage_invoke_url", "module.api"]}}, "cloudfront_distribution_id": {"description": "CloudFront distribution id, used to invalidate cached assets after a frontend publish.", "expression": {"references": ["module.frontend_cdn.distribution_id", "module.frontend_cdn"]}}, "cloudfront_domain_name": {"description": "CloudFront distribution domain name serving the frontend build.", "expression": {"references": ["module.frontend_cdn.distribution_domain_name", "module.frontend_cdn"]}}, "cloudtrail_access_logs_bucket_name": {"description": "Destination bucket for the CloudTrail delivery bucket S3 server access logs. Its log source is `cloudtrail_s3_bucket_name`, a different bucket.", "expression": {"references": ["module.observability.cloudtrail_access_logs_bucket_name", "module.observability"]}}, "cloudtrail_s3_bucket_name": {"description": "The CloudTrail log-file delivery bucket, whose access logs land in `cloudtrail_access_logs_bucket_name`. Read by the delivery smoke check as the source side of its target assertion.", "expression": {"references": ["module.observability.cloudtrail_s3_bucket_name", "module.observability"]}}, "cognito_domain": {"description": "Cognito prefix domain (no custom ACM certificate). Combine with `var.aws_region` as `https://.auth..amazoncognito.com` to reach the `/oauth2/token` endpoint the MCP `client_credentials` flow uses; see `docs/mcp-client-guide.md`.", "expression": {"references": ["module.cognito.domain", "module.cognito"]}}, "cognito_gateway_scope": {"description": "The `gateway/invoke` resource-server scope identifier, re-exported from `module.cognito.gateway_scope_identifier`. Read by `scripts/smoke/gateway_tools.py`.", "expression": {"references": ["module.cognito.gateway_scope_identifier", "module.cognito"]}}, "cognito_mcp_client_id": {"description": "App client id for MCP clients (confidential client).", "expression": {"references": ["module.cognito.mcp_client_id", "module.cognito"]}}, "cognito_mcp_client_secret": {"description": "App client secret for the MCP client, empty after the first secret rotation (`scripts/rotate_mcp_client_secret.py`). Sensitive; never write it to a tracked file. Any copy kept elsewhere, for example in Secrets Manager, is made out of band; nothing in this stack stores one.", "expression": {"references": ["module.cognito.mcp_client_secret", "module.cognito"]}, "sensitive": true}, "cognito_mcp_oauth_client_id": {"description": "App client id for interactive MCP OAuth clients (public client, authorization code, loopback callbacks); accepted by Gateway #2 only.", "expression": {"references": ["module.cognito.mcp_oauth_client_id", "module.cognito"]}}, "cognito_spa_client_id": {"description": "App client id for the SPA (public client).", "expression": {"references": ["module.cognito.spa_client_id", "module.cognito"]}}, "cognito_token_endpoint": {"description": "Fully-formed Cognito `/oauth2/token` endpoint URL for the MCP app client's `client_credentials` grant.", "expression": {"references": ["module.cognito.domain", "module.cognito", "var.aws_region"]}}, "cognito_user_pool_id": {"description": "Cognito user pool id.", "expression": {"references": ["module.cognito.user_pool_id", "module.cognito"]}}, "crm_operator_principal_arns": {"description": "The operator principals admitted by the DynamoDB table and CMK policies. Read by the Layer 4 `dynamodb_principal_deny` smoke check to assert the deployed policies' allowlists.", "expression": {"references": ["var.crm_operator_principal_arns"]}}, "dynamodb_table_names": {"description": "Map of logical table name to physical DynamoDB table name, for the 11 tables.", "expression": {"references": ["module.dynamodb.table_names", "module.dynamodb"]}}, "eval_artifacts_bucket_arn": {"description": "The eval-artefacts bucket ARN, for a smoke check composing its own policy or simulation against it.", "expression": {"references": ["module.eval_artifacts.bucket_arn", "module.eval_artifacts"]}}, "eval_artifacts_bucket_name": {"description": "The eval-artefacts bucket name, which embeds the account id. Read by `sweep_control` (as EVAL_ARTIFACTS_BUCKET) and by the presigned-URL smoke check.", "expression": {"references": ["module.eval_artifacts.bucket_name", "module.eval_artifacts"]}}, "eval_artifacts_prefix": {"description": "The single key prefix artefacts are written under, and the only prefix the `sweep_control` artifacts grant covers. Read by `sweep_control` as EVAL_ARTIFACTS_PREFIX.", "expression": {"references": ["module.eval_artifacts.artifact_prefix", "module.eval_artifacts"]}}, "eval_state_machine_arn": {"description": "ARN of the eval_sweep Step Functions state machine, started by eval_trigger.", "expression": {"references": ["aws_sfn_state_machine.eval_sweep.arn", "aws_sfn_state_machine.eval_sweep"]}}, "eval_trigger_function_name": {"description": "The `eval_trigger` Lambda's function name. Read by the smoke checks: `admin_authz` derives the Lambda name prefix from it, `eval_sfn` and `chat_path_iam` read its configuration, and `resource_protection` checks its log group.", "expression": {"references": ["module.lambda_action_eval_trigger.function_name", "module.lambda_action_eval_trigger"]}}, "frontend_cdn_logs_bucket_name": {"description": "Destination bucket for the CloudFront origin bucket and eval-artefacts bucket S3 server access logs, and for CloudFront standard access logs. Log sources: `frontend_origin_bucket_name`, `eval_artifacts_bucket_name`, and the distribution.", "expression": {"references": ["module.frontend_cdn.logs_bucket_name", "module.frontend_cdn"]}}, "frontend_origin_bucket_name": {"description": "Private S3 bucket holding the frontend static build \u2014 the `aws s3 sync` target of the deploy script's publish step.", "expression": {"references": ["module.frontend_cdn.origin_bucket_name", "module.frontend_cdn"]}}, "mcp_chat_gateway_url": {"description": "MCP endpoint URL of Gateway #2, which exposes only `chat_with_supervisor`.", "expression": {"references": ["module.mcp_chat_gateway.gateway_url", "module.mcp_chat_gateway"]}}, "vpc_flow_log_group_name": {"description": "The VPC flow-log group name, or null when flow logs are disabled. Blocked egress appears here as REJECT records.", "expression": {"references": ["module.vpc.flow_log_group_name", "module.vpc"]}}, "vpc_id": {"description": "Id of the adopted VPC the stack deploys into. Read by the Layer 4 VPC smoke check.", "expression": {"references": ["module.vpc.vpc_id", "module.vpc"]}}, "vpc_interface_endpoint_service_names": {"description": "Fully-qualified service names of the interface endpoints created: the AWS services the workload can reach privately. Read by checks that assert a dependency is reachable.", "expression": {"references": ["module.vpc.interface_endpoint_service_names", "module.vpc"]}}, "vpc_lambda_security_group_ids": {"description": "The Lambda ENI security group. Read by Layer 4 to assert it has no ingress rule and no egress destination outside this VPC's endpoints.", "expression": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}}, "vpc_lambda_subnet_ids": {"description": "The private subnet ids every Lambda's `vpc_config` places ENIs in. Read by the Layer 4 VPC smoke check to assert each subnet's route table carries no route to a gateway.", "expression": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}}, "resources": [{"address": "aws_bedrockagentcore_resource_policy.agent_runtime_endpoint_relay_only", "expressions": {"policy": {"references": ["data.aws_iam_policy_document.agent_runtime_endpoint_relay_only.json", "data.aws_iam_policy_document.agent_runtime_endpoint_relay_only"]}, "resource_arn": {"references": ["local.agent_runtime_endpoint_arn"]}}, "mode": "managed", "name": "agent_runtime_endpoint_relay_only", "provider_config_key": "aws", "schema_version": 0, "type": "aws_bedrockagentcore_resource_policy"}, {"address": "aws_bedrockagentcore_resource_policy.agent_runtime_relay_only", "expressions": {"policy": {"references": ["data.aws_iam_policy_document.agent_runtime_relay_only.json", "data.aws_iam_policy_document.agent_runtime_relay_only"]}, "resource_arn": {"references": ["module.agentcore.agent_runtime_arn", "module.agentcore"]}}, "mode": "managed", "name": "agent_runtime_relay_only", "provider_config_key": "aws", "schema_version": 0, "type": "aws_bedrockagentcore_resource_policy"}, {"address": "aws_cloudwatch_log_group.eval_sweep", "expressions": {"kms_key_id": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "name": {"references": ["local.eval_sweep_state_machine_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "eval_sweep", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_role.agentcore_gateway", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.agentcore_assume_role.json", "data.aws_iam_policy_document.agentcore_assume_role"]}, "name": {"constant_value": "crm-agent-eval-gateway-role"}}, "mode": "managed", "name": "agentcore_gateway", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role.agentcore_runtime", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.agentcore_assume_role.json", "data.aws_iam_policy_document.agentcore_assume_role"]}, "name": {"constant_value": "crm-agent-eval-runtime-role"}}, "mode": "managed", "name": "agentcore_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role.eval_sweep", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.eval_sweep_assume_role.json", "data.aws_iam_policy_document.eval_sweep_assume_role"]}, "name": {"references": ["local.eval_sweep_state_machine_name"]}, "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "eval_sweep", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.agentcore_gateway", "expressions": {"name": {"constant_value": "crm-agent-eval-gateway-permissions"}, "policy": {"references": ["data.aws_iam_policy_document.agentcore_gateway_permissions.json", "data.aws_iam_policy_document.agentcore_gateway_permissions"]}, "role": {"references": ["aws_iam_role.agentcore_gateway.id", "aws_iam_role.agentcore_gateway"]}}, "mode": "managed", "name": "agentcore_gateway", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.agentcore_runtime", "expressions": {"name": {"constant_value": "crm-agent-eval-runtime-permissions"}, "policy": {"references": ["data.aws_iam_policy_document.agentcore_runtime_permissions.json", "data.aws_iam_policy_document.agentcore_runtime_permissions"]}, "role": {"references": ["aws_iam_role.agentcore_runtime.id", "aws_iam_role.agentcore_runtime"]}}, "mode": "managed", "name": "agentcore_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.agentcore_runtime_logs", "expressions": {"name": {"constant_value": "crm-agent-eval-runtime-logs"}, "policy": {"references": ["data.aws_iam_policy_document.agentcore_runtime_logs.json", "data.aws_iam_policy_document.agentcore_runtime_logs"]}, "role": {"references": ["aws_iam_role.agentcore_runtime.id", "aws_iam_role.agentcore_runtime"]}}, "mode": "managed", "name": "agentcore_runtime_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.chat_target_invoke_runtime", "expressions": {"name": {"references": ["local.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.chat_target_invoke_runtime.json", "data.aws_iam_policy_document.chat_target_invoke_runtime"]}, "role": {"references": ["module.lambda_action_chat_target.role_name", "module.lambda_action_chat_target"]}}, "mode": "managed", "name": "chat_target_invoke_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.eval_sweep", "expressions": {"name": {"references": ["local.eval_sweep_state_machine_name"]}, "policy": {"references": ["data.aws_iam_policy_document.eval_sweep_permissions.json", "data.aws_iam_policy_document.eval_sweep_permissions"]}, "role": {"references": ["aws_iam_role.eval_sweep.name", "aws_iam_role.eval_sweep"]}}, "mode": "managed", "name": "eval_sweep", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.eval_trigger_artifacts", "expressions": {"name": {"references": ["local.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.eval_trigger_artifacts.json", "data.aws_iam_policy_document.eval_trigger_artifacts"]}, "role": {"references": ["module.lambda_action_eval_trigger.role_name", "module.lambda_action_eval_trigger"]}}, "mode": "managed", "name": "eval_trigger_artifacts", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.eval_trigger_states", "expressions": {"name": {"references": ["local.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.eval_trigger_states.json", "data.aws_iam_policy_document.eval_trigger_states"]}, "role": {"references": ["module.lambda_action_eval_trigger.role_name", "module.lambda_action_eval_trigger"]}}, "mode": "managed", "name": "eval_trigger_states", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.sweep_control_artifacts", "expressions": {"name": {"references": ["local.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.sweep_control_artifacts.json", "data.aws_iam_policy_document.sweep_control_artifacts"]}, "role": {"references": ["module.lambda_action_sweep_control.role_name", "module.lambda_action_sweep_control"]}}, "mode": "managed", "name": "sweep_control_artifacts", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.sweep_task_invoke_runtime", "expressions": {"name": {"references": ["local.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.sweep_task_invoke_runtime.json", "data.aws_iam_policy_document.sweep_task_invoke_runtime"]}, "role": {"references": ["module.lambda_action_sweep_task.role_name", "module.lambda_action_sweep_task"]}}, "mode": "managed", "name": "sweep_task_invoke_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_kms_alias.cursor", "expressions": {"name": {"references": ["local.name_prefix"]}, "target_key_id": {"references": ["aws_kms_key.cursor.key_id", "aws_kms_key.cursor"]}}, "mode": "managed", "name": "cursor", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_alias"}, {"address": "aws_kms_alias.eval_artifacts", "expressions": {"name": {"references": ["local.name_prefix"]}, "target_key_id": {"references": ["aws_kms_key.eval_artifacts.key_id", "aws_kms_key.eval_artifacts"]}}, "mode": "managed", "name": "eval_artifacts", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_alias"}, {"address": "aws_kms_key.cursor", "expressions": {"deletion_window_in_days": {"constant_value": 7}, "description": {"references": ["local.name_prefix"]}, "enable_key_rotation": {"constant_value": true}, "tags": {"constant_value": {"data-classification": "internal"}}}, "mode": "managed", "name": "cursor", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key"}, {"address": "aws_kms_key.eval_artifacts", "expressions": {"deletion_window_in_days": {"constant_value": 7}, "description": {"references": ["local.name_prefix"]}, "enable_key_rotation": {"constant_value": true}, "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "eval_artifacts", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key"}, {"address": "aws_kms_key_policy.cursor", "expressions": {"bypass_policy_lockout_safety_check": {"constant_value": false}, "key_id": {"references": ["aws_kms_key.cursor.id", "aws_kms_key.cursor"]}, "policy": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current", "local.cursor_key_principal_arns", "var.crm_operator_principal_arns", "var.crm_operator_principal_arns", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}}, "mode": "managed", "name": "cursor", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key_policy"}, {"address": "aws_kms_key_policy.eval_artifacts", "expressions": {"bypass_policy_lockout_safety_check": {"constant_value": false}, "key_id": {"references": ["aws_kms_key.eval_artifacts.id", "aws_kms_key.eval_artifacts"]}, "policy": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current", "local.eval_artifacts_principal_arns", "var.crm_operator_principal_arns", "var.crm_operator_principal_arns", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}}, "mode": "managed", "name": "eval_artifacts", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key_policy"}, {"address": "aws_s3_object.agent_source", "expressions": {"bucket": {"references": ["module.eval_artifacts.bucket_name", "module.eval_artifacts"]}, "key": {"constant_value": "agent-source/agent.zip"}, "kms_key_id": {"references": ["aws_kms_key.eval_artifacts.arn", "aws_kms_key.eval_artifacts"]}, "source": {"references": ["var.lambda_build_dir"]}, "source_hash": {"references": ["var.lambda_build_dir"]}, "tags": {"constant_value": {"data-classification": "internal"}}}, "mode": "managed", "name": "agent_source", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_object"}, {"address": "aws_sfn_state_machine.eval_sweep", "depends_on": ["aws_iam_role_policy.eval_sweep"], "expressions": {"definition": {"references": ["path.module", "module.lambda_action_sweep_control.function_arn", "module.lambda_action_sweep_control", "module.lambda_action_sweep_task.function_arn", "module.lambda_action_sweep_task"]}, "logging_configuration": [{"include_execution_data": {"constant_value": false}, "level": {"constant_value": "ALL"}, "log_destination": {"references": ["aws_cloudwatch_log_group.eval_sweep.arn", "aws_cloudwatch_log_group.eval_sweep"]}}], "name": {"references": ["local.eval_sweep_state_machine_name"]}, "role_arn": {"references": ["aws_iam_role.eval_sweep.arn", "aws_iam_role.eval_sweep"]}, "tags": {"references": ["var.data_classification"]}, "tracing_configuration": [{"enabled": {"constant_value": true}}], "type": {"constant_value": "STANDARD"}}, "mode": "managed", "name": "eval_sweep", "provider_config_key": "aws", "schema_version": 0, "type": "aws_sfn_state_machine"}, {"address": "aws_ssm_parameter.api_allowed_client_ids", "expressions": {"name": {"references": ["local.api_allowed_client_ids_parameter_name"]}, "tags": {"constant_value": {"data-classification": "internal"}}, "type": {"constant_value": "String"}, "value": {"references": ["module.cognito.spa_client_id", "module.cognito"]}}, "mode": "managed", "name": "api_allowed_client_ids", "provider_config_key": "aws", "schema_version": 0, "type": "aws_ssm_parameter"}, {"address": "aws_ssm_parameter.relay_cognito_audience", "expressions": {"name": {"references": ["local.relay_cognito_audience_parameter_name"]}, "tags": {"constant_value": {"data-classification": "internal"}}, "type": {"constant_value": "String"}, "value": {"references": ["module.cognito.spa_client_id", "module.cognito"]}}, "mode": "managed", "name": "relay_cognito_audience", "provider_config_key": "aws", "schema_version": 0, "type": "aws_ssm_parameter"}, {"address": "aws_vpc_endpoint_policy.states", "expressions": {"policy": {"references": ["data.aws_iam_policy_document.states_endpoint.json", "data.aws_iam_policy_document.states_endpoint"]}, "vpc_endpoint_id": {"references": ["module.vpc.states_vpc_endpoint_id", "module.vpc"]}}, "mode": "managed", "name": "states", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_endpoint_policy"}, {"address": "aws_vpc_security_group_ingress_rule.endpoints_from_api_origin_alb", "expressions": {"description": {"constant_value": "HTTPS from the private-origin ALB. The only ingress any endpoint has besides the Lambda group."}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "referenced_security_group_id": {"references": ["module.api_origin.alb_security_group_id", "module.api_origin"]}, "security_group_id": {"references": ["module.vpc.execute_api_security_group_id", "module.vpc"]}, "to_port": {"constant_value": 443}}, "mode": "managed", "name": "endpoints_from_api_origin_alb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_ingress_rule"}, {"address": "terraform_data.agent_only_tools_guard", "mode": "managed", "name": "agent_only_tools_guard", "provider_config_key": "terraform", "schema_version": 0, "type": "terraform_data"}, {"address": "terraform_data.chat_scope_agreement", "mode": "managed", "name": "chat_scope_agreement", "provider_config_key": "terraform", "schema_version": 0, "type": "terraform_data"}, {"address": "terraform_data.reserved_concurrency_headroom_guard", "mode": "managed", "name": "reserved_concurrency_headroom_guard", "provider_config_key": "terraform", "schema_version": 0, "type": "terraform_data"}, {"address": "data.aws_caller_identity.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_caller_identity"}, {"address": "data.aws_iam_policy_document.agent_runtime_endpoint_relay_only", "expressions": {"statement": [{"actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"references": ["local.runtime_invoker_role_arns"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["local.agent_runtime_endpoint_arn"]}, "sid": {"constant_value": "OnlyTheInvokerRolesMayInvokeThisEndpoint"}}, {"actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime", "bedrock-agentcore:InvokeAgentRuntimeForUser", "bedrock-agentcore:InvokeAgentRuntimeCommand", "bedrock-agentcore:InvokeAgentRuntimeCommandShell", "bedrock-agentcore:InvokeAgentRuntimeWithWebSocketStream", "bedrock-agentcore:InvokeAgentRuntimeWithWebSocketStreamForUser", "bedrock-agentcore:StopRuntimeSession", "bedrock-agentcore:GetAgentCard"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["local.runtime_invoker_role_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["local.agent_runtime_endpoint_arn"]}, "sid": {"constant_value": "DenyRuntimeDataPlaneToAnyOtherPrincipal"}}]}, "mode": "data", "name": "agent_runtime_endpoint_relay_only", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.agent_runtime_relay_only", "expressions": {"statement": [{"actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"references": ["local.runtime_invoker_role_arns"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["module.agentcore.agent_runtime_arn", "module.agentcore"]}, "sid": {"constant_value": "OnlyTheInvokerRolesMayInvokeThisRuntime"}}, {"actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime", "bedrock-agentcore:InvokeAgentRuntimeForUser", "bedrock-agentcore:InvokeAgentRuntimeCommand", "bedrock-agentcore:InvokeAgentRuntimeCommandShell", "bedrock-agentcore:InvokeAgentRuntimeWithWebSocketStream", "bedrock-agentcore:InvokeAgentRuntimeWithWebSocketStreamForUser", "bedrock-agentcore:StopRuntimeSession", "bedrock-agentcore:GetAgentCard"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["local.runtime_invoker_role_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["module.agentcore.agent_runtime_arn", "module.agentcore"]}, "sid": {"constant_value": "DenyRuntimeDataPlaneToAnyOtherPrincipal"}}]}, "mode": "data", "name": "agent_runtime_relay_only", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.agentcore_assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["bedrock-agentcore.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "agentcore_assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.agentcore_gateway_permissions", "expressions": {"statement": [{"actions": {"constant_value": ["lambda:InvokeFunction"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.lambda_action"]}, "sid": {"constant_value": "InvokeActionLambdas"}}, {"actions": {"constant_value": ["lambda:InvokeFunction"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.lambda_action_interceptor.function_arn", "module.lambda_action_interceptor"]}, "sid": {"constant_value": "InvokeInterceptor"}}]}, "mode": "data", "name": "agentcore_gateway_permissions", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.agentcore_runtime_logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents", "logs:DescribeLogStreams"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.agentcore.agent_runtime_log_group_arn", "module.agentcore", "module.agentcore.agent_runtime_log_group_arn", "module.agentcore"]}, "sid": {"constant_value": "CloudWatchLogsAccess"}}]}, "mode": "data", "name": "agentcore_runtime_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.agentcore_runtime_permissions", "expressions": {"statement": [{"actions": {"constant_value": ["lambda:InvokeFunction"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.lambda_action", "local.runtime_uninvocable_tools"]}, "sid": {"constant_value": "InvokeActionLambdas"}}, {"actions": {"constant_value": ["bedrock:InvokeModel", "bedrock:InvokeModelWithResponseStream"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["local.bedrock_inference_profiles", "var.aws_region", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current", "var.aws_region", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "sid": {"constant_value": "BedrockInference"}}, {"actions": {"constant_value": ["bedrock:InvokeModel", "bedrock:InvokeModelWithResponseStream"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["local.bedrock_inference_profiles", "var.aws_region", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "bedrock:InferenceProfileArn"}}], "effect": {"constant_value": "Allow"}, "resources": {"references": ["local.bedrock_foundation_models", "local.bedrock_foundation_models"]}, "sid": {"constant_value": "BedrockInferenceFoundationModels"}}, {"actions": {"constant_value": ["ecr:BatchGetImage", "ecr:GetDownloadUrlForLayer"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.aws_region", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current", "local.agent_ecr_repository_name"]}, "sid": {"constant_value": "EcrImageAccess"}}, {"actions": {"constant_value": ["ecr:GetAuthorizationToken"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "EcrTokenAccess"}}]}, "mode": "data", "name": "agentcore_runtime_permissions", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.chat_target_invoke_runtime", "expressions": {"statement": [{"actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.agentcore.agent_runtime_arn", "module.agentcore", "local.agent_runtime_endpoint_arn"]}, "sid": {"constant_value": "InvokeTheRuntimeDefaultEndpoint"}}, {"effect": {"constant_value": "Deny"}, "not_actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime"]}, "resources": {"references": ["module.agentcore.agent_runtime_arn", "module.agentcore", "local.agent_runtime_endpoint_arn"]}, "sid": {"constant_value": "DenyEverythingButInvokeOnThisRuntime"}}]}, "mode": "data", "name": "chat_target_invoke_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.eval_sweep_assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "aws:SourceAccount"}}, {"test": {"constant_value": "ArnEquals"}, "values": {"references": ["local.eval_sweep_state_machine_arn"]}, "variable": {"constant_value": "aws:SourceArn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["states.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "eval_sweep_assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.eval_sweep_permissions", "expressions": {"statement": [{"actions": {"constant_value": ["lambda:InvokeFunction"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.lambda_action_sweep_control.function_arn", "module.lambda_action_sweep_control", "module.lambda_action_sweep_control.function_arn", "module.lambda_action_sweep_control", "module.lambda_action_sweep_task.function_arn", "module.lambda_action_sweep_task", "module.lambda_action_sweep_task.function_arn", "module.lambda_action_sweep_task"]}, "sid": {"constant_value": "InvokeSweepLambdas"}}, {"actions": {"references": ["local.sfn_vended_log_delivery_actions"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "SfnVendedLogDelivery"}}, {"actions": {"references": ["local.sfn_xray_tracing_actions"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "SfnXRayTracing"}}]}, "mode": "data", "name": "eval_sweep_permissions", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.eval_trigger_artifacts", "expressions": {"statement": [{"actions": {"constant_value": ["s3:GetObject"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.eval_artifacts.bucket_arn", "module.eval_artifacts", "module.eval_artifacts.artifact_prefix", "module.eval_artifacts"]}, "sid": {"constant_value": "ReadArtifactPrefix"}}, {"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["var.aws_region"]}, "variable": {"constant_value": "kms:ViaService"}}], "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_kms_key.eval_artifacts.arn", "aws_kms_key.eval_artifacts"]}, "sid": {"constant_value": "DecryptArtifactsViaS3"}}]}, "mode": "data", "name": "eval_trigger_artifacts", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.eval_trigger_states", "expressions": {"statement": [{"actions": {"constant_value": ["states:StartExecution"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["local.eval_sweep_state_machine_arn"]}, "sid": {"constant_value": "StartTheEvalSweep"}}, {"actions": {"constant_value": ["states:DescribeExecution"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["local.eval_sweep_execution_arn_pattern"]}, "sid": {"constant_value": "DescribeEvalSweepExecutions"}}]}, "mode": "data", "name": "eval_trigger_states", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.states_endpoint", "expressions": {"statement": [{"actions": {"constant_value": ["states:StartExecution"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "aws:PrincipalAccount"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"references": ["local.eval_sweep_state_machine_arn"]}, "sid": {"constant_value": "StartTheEvalSweep"}}, {"actions": {"constant_value": ["states:DescribeExecution"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "aws:PrincipalAccount"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"references": ["local.eval_sweep_execution_arn_pattern"]}, "sid": {"constant_value": "DescribeEvalSweepExecutions"}}]}, "mode": "data", "name": "states_endpoint", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.sweep_control_artifacts", "expressions": {"statement": [{"actions": {"constant_value": ["s3:PutObject", "s3:GetObject"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.eval_artifacts.bucket_arn", "module.eval_artifacts", "module.eval_artifacts.artifact_prefix", "module.eval_artifacts"]}, "sid": {"constant_value": "WriteAndReadArtifactPrefix"}}, {"actions": {"constant_value": ["kms:GenerateDataKey", "kms:Decrypt"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_kms_key.eval_artifacts.arn", "aws_kms_key.eval_artifacts"]}, "sid": {"constant_value": "UseArtifactsBucketCmk"}}]}, "mode": "data", "name": "sweep_control_artifacts", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.sweep_task_invoke_runtime", "expressions": {"statement": [{"actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.agentcore.agent_runtime_arn", "module.agentcore", "local.agent_runtime_endpoint_arn"]}, "sid": {"constant_value": "InvokeAgentRuntimeEvalTurn"}}]}, "mode": "data", "name": "sweep_task_invoke_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_session_context.current", "expressions": {"arn": {"references": ["data.aws_caller_identity.current.arn", "data.aws_caller_identity.current"]}}, "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_session_context"}, {"address": "data.aws_network_interface.execute_api", "count_expression": {"references": ["var.vpc_private_subnet_ids"]}, "expressions": {"id": {"references": ["module.vpc.execute_api_network_interface_ids", "module.vpc", "count.index"]}}, "mode": "data", "name": "execute_api", "provider_config_key": "aws", "schema_version": 0, "type": "aws_network_interface"}], "variables": {"api_origin_ingress_security_group_ids": {"description": "Security group ids permitted to reach the internal ALB's listener port (the `/api/*` private origin\npath). Passed to `modules/api_origin`, whose validation refuses anything that is not an `sg-` id.\nNo default; set it in the gitignored `terraform.tfvars`.\n\nThe value is the CloudFront service-managed group `CloudFront-VPCOrigins-Service-SG`, which AWS\ncreates in the adopted VPC when `aws_cloudfront_vpc_origin` is first applied. The first deployment\nof this path is therefore two-phase: apply, read the group id, set this variable, apply again. See\nthe `api_origin` variables and the runbook.\n"}, "aws_profile": {"default": "default", "description": "Named AWS CLI profile to use for all provider operations."}, "aws_region": {"default": "us-east-1", "description": "AWS region to deploy into: a US commercial region listed in `infra/regions.json`."}, "cost_center": {"default": "crm-agent-eval", "description": "Value for the mandatory `cost-center` tag applied to every resource."}, "crm_operator_principal_arns": {"description": "IAM role or user ARNs of the operators who deploy, seed and smoke-test this stack. Admitted to the\nDynamoDB tables' data plane and to table and CMK administration; every principal outside these and\nthe project's Lambda roles is denied. No default; set it in the gitignored\n`terraform.tfvars`. A plan whose caller is not listed fails at a precondition.\n"}, "data_classification": {"default": "confidential", "description": "Default value for the mandatory `data-classification` tag. Individual modules may override this per resource where a more specific classification applies."}, "environment": {"default": "dev", "description": "Value for the mandatory `environment` tag applied to every resource."}, "lambda_build_dir": {"default": "build/lambda", "description": "Directory holding the pre-built archives this composition reads, resolved\nrelative to `infra/`: one Lambda zip per `local.tool_names` entry, plus\n`identity_interceptor.zip`, `pre_token_generation.zip`, `eval_trigger.zip`\n(shared by the eval trigger, capabilities, user-settings and sweep functions),\n`chat_target.zip` (the chat Gateway's target) and `relay.zip` \u2014 and\n`agent-source.zip`, the CodeBuild source for the AgentCore container image. `scripts/package_lambdas.sh` and `scripts/package_relay.sh`\npopulate the default location, `infra/build/lambda`.\n"}, "owner": {"default": "crm-agent-eval-team", "description": "Value for the mandatory `owner` tag applied to every resource."}, "runtime_source_vpce_deny_enabled": {"default": false, "description": "Stage 2: whether the runtime resource policies carry the inbound Deny. When true, both policies deny\n`InvokeAgentRuntime` from every principal not arriving through the bedrock-agentcore VPC endpoint\n(with `aws:ViaAWSService = false` exempting internal service calls).\n\nDefaults to false. Enable it only once the relay's calls are shown to carry `aws:SourceVpce`;\notherwise every chat turn is denied. Set `-var runtime_source_vpce_deny_enabled=true` (or in a\ngitignored `*.auto.tfvars`) as a separate apply after stage 1 is verified.\n"}, "runtime_source_vpce_report_only_enabled": {"default": true, "description": "Stage 1: whether the runtime resource policies carry the report-only `aws:SourceVpce` Allow for any\nprincipal arriving through the bedrock-agentcore VPC endpoint. It grants nothing the relay-role\nAllow does not already cover for the relay; it shows, before the Deny, that traffic through this\nstack's endpoint is admitted by the SourceVpce condition.\n"}, "service": {"default": "crm-agent-eval", "description": "Value for the mandatory `service` tag applied to every resource."}, "vpc_cidr_block": {"default": "10.20.0.0/20", "description": "The adopted VPC's IPv4 CIDR, published as an output for Layer 4 checks. Nothing is sized from it.\nIt must match the adopted VPC.\n"}, "vpc_flow_log_enabled": {"default": true, "description": "Whether to deliver VPC flow logs to CloudWatch Logs."}, "vpc_id": {"description": "Id of the existing VPC this deployment adopts. The stack creates no VPC; it creates only the NAT\ngateway path, the route that path adds to the adopted private route tables, two security groups,\nand the VPC endpoints.\n\nNo default. Set it in the gitignored `terraform.tfvars`; `terraform.tfvars.example` shows the shape\nwith a placeholder.\n"}, "vpc_nat_gateway_enabled": {"description": "Whether to create the egress-only internet path the relay's Cognito JWKS fetch requires.\n\nNo default; `terraform plan` refuses until a value is set. `false` leaves the relay unable to\nauthenticate any request (the user pool has a domain, so the `cognito-idp` interface endpoint cannot\nserve it). `true` creates a NAT gateway, billed hourly and per GB.\n\nSet it on the command line (`-var vpc_nat_gateway_enabled=true`) or in a gitignored `*.auto.tfvars`.\nThe NAT gateway is egress-only: it admits no inbound connection (see `infra/modules/vpc/nat.tf`).\n"}, "vpc_nat_public_subnet_id": {"default": null, "description": "Id of an existing IGW-routed subnet in the adopted VPC for the NAT gateway to land in. Required when\n`vpc_nat_gateway_enabled` is true; the plan fails otherwise. No default.\n\nMust not also appear in `vpc_private_subnet_ids`; the module asserts that at plan time.\n"}, "vpc_private_route_table_ids": {"description": "Route table ids the adopted private subnets use. No default.\n\nMust not be the VPC's main route table; a precondition refuses it at plan time.\n\nEvery table named here receives a `0.0.0.0/0` route to this stack's NAT gateway and the S3/DynamoDB\ngateway-endpoint associations.\n"}, "vpc_private_subnet_ids": {"description": "Ids of the existing private subnets in the adopted VPC that every Lambda's ENIs are placed in. No\ndefault; set it in the gitignored `terraform.tfvars`.\n\nThe AZ set is whatever these subnets are; it is not derived from the region.\n"}, "vpc_runtime_route_table_ids": {"default": [], "description": "Route table ids of the `vpc_runtime_subnet_ids` subnets, associated with the S3/DynamoDB gateway\nendpoints so ECR image-layer pulls have an S3 path. They receive no NAT default route (that stays\non `vpc_private_route_table_ids`), so the Runtime has no internet path. Defaults to empty.\n"}, "vpc_runtime_subnet_ids": {"default": [], "description": "Ids of the private subnets for the AgentCore Runtime's VPC-mode ENIs, separate from\n`vpc_private_subnet_ids` (see the vpc module's `runtime_subnet_ids`).\n\nEvery subnet must be in an AgentCore-supported AZ for the region (`infra/regions.json`) and must\nnot be `vpc_nat_public_subnet_id`; `scripts/preflight_adopted_vpc.sh` and a module precondition\nassert both. The Runtime runs in VPC mode, so an empty list fails the plan.\n"}}}}, "format_version": "1.2", "variables": {"api_origin_ingress_security_group_ids": {"value": ["sg-cloudfrontvpcoriginplaceholder"]}, "aws_profile": {"value": "example-deployer"}, "aws_region": {"value": "us-east-1"}, "cost_center": {"value": "crm-agent-eval"}, "crm_operator_principal_arns": {"value": ["arn:aws:iam::123456789012:role/example-deployer"]}, "data_classification": {"value": "confidential"}, "environment": {"value": "dev"}, "lambda_build_dir": {"value": "build/lambda"}, "owner": {"value": "crm-agent-eval-team"}, "runtime_source_vpce_deny_enabled": {"value": false}, "runtime_source_vpce_report_only_enabled": {"value": true}, "service": {"value": "crm-agent-eval"}, "vpc_cidr_block": {"value": "10.20.0.0/20"}, "vpc_flow_log_enabled": {"value": true}, "vpc_id": {"value": "vpc-adoptedplaceholder"}, "vpc_nat_gateway_enabled": {"value": true}, "vpc_nat_public_subnet_id": {"value": "subnet-natpublicplaceholder"}, "vpc_private_route_table_ids": {"value": ["rtb-privateoneplaceholder", "rtb-privatetwoplaceholder"]}, "vpc_private_subnet_ids": {"value": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}, "vpc_runtime_route_table_ids": {"value": ["rtb-runtimeplaceholder"]}, "vpc_runtime_subnet_ids": {"value": ["subnet-runtimeoneplaceholder", "subnet-runtimetwoplaceholder"]}}} {"action_reason": "read_because_config_unknown", "address": "data.aws_iam_policy_document.agent_runtime_endpoint_relay_only", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["bedrock-agentcore:InvokeAgentRuntime"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": [null, null, null], "type": "AWS"}], "resources": [null], "sid": "OnlyTheInvokerRolesMayInvokeThisEndpoint"}, {"actions": ["bedrock-agentcore:GetAgentCard", "bedrock-agentcore:InvokeAgentRuntime", "bedrock-agentcore:InvokeAgentRuntimeCommand", "bedrock-agentcore:InvokeAgentRuntimeCommandShell", "bedrock-agentcore:InvokeAgentRuntimeForUser", "bedrock-agentcore:InvokeAgentRuntimeWithWebSocketStream", "bedrock-agentcore:InvokeAgentRuntimeWithWebSocketStreamForUser", "bedrock-agentcore:StopRuntimeSession"], "condition": [{"test": "ArnNotEquals", "values": [null, null, null], "variable": "aws:PrincipalArn"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": ["*"], "type": "AWS"}], "resources": [null], "sid": "DenyRuntimeDataPlaneToAnyOtherPrincipal"}, {"actions": ["bedrock-agentcore:InvokeAgentRuntime"], "condition": [{"test": "StringEquals", "values": [null], "variable": "aws:SourceVpce"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": [null, null, null], "type": "AWS"}], "resources": [null], "sid": "AllowInvokeViaOurVpcEndpoint"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [{"identifiers": [false, false, false]}], "resources": [false]}, {"actions": [false, false, false, false, false, false, false, false], "condition": [{"values": [false, false, false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false, false, false]}], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [{"identifiers": [true, true, true]}], "resources": [true]}, {"actions": [false, false, false, false, false, false, false, false], "condition": [{"values": [true, true, true]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [true]}, {"actions": [false], "condition": [{"values": [true]}], "not_principals": [], "principals": [{"identifiers": [true, true, true]}], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "name": "agent_runtime_endpoint_relay_only", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "data.aws_iam_policy_document.agent_runtime_relay_only", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["bedrock-agentcore:InvokeAgentRuntime"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": [null, null, null], "type": "AWS"}], "resources": [null], "sid": "OnlyTheInvokerRolesMayInvokeThisRuntime"}, {"actions": ["bedrock-agentcore:GetAgentCard", "bedrock-agentcore:InvokeAgentRuntime", "bedrock-agentcore:InvokeAgentRuntimeCommand", "bedrock-agentcore:InvokeAgentRuntimeCommandShell", "bedrock-agentcore:InvokeAgentRuntimeForUser", "bedrock-agentcore:InvokeAgentRuntimeWithWebSocketStream", "bedrock-agentcore:InvokeAgentRuntimeWithWebSocketStreamForUser", "bedrock-agentcore:StopRuntimeSession"], "condition": [{"test": "ArnNotEquals", "values": [null, null, null], "variable": "aws:PrincipalArn"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": ["*"], "type": "AWS"}], "resources": [null], "sid": "DenyRuntimeDataPlaneToAnyOtherPrincipal"}, {"actions": ["bedrock-agentcore:InvokeAgentRuntime"], "condition": [{"test": "StringEquals", "values": [null], "variable": "aws:SourceVpce"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": [null, null, null], "type": "AWS"}], "resources": [null], "sid": "AllowInvokeViaOurVpcEndpoint"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [{"identifiers": [false, false, false]}], "resources": [false]}, {"actions": [false, false, false, false, false, false, false, false], "condition": [{"values": [false, false, false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false, false, false]}], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [{"identifiers": [true, true, true]}], "resources": [true]}, {"actions": [false, false, false, false, false, false, false, false], "condition": [{"values": [true, true, true]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [true]}, {"actions": [false], "condition": [{"values": [true]}], "not_principals": [], "principals": [{"identifiers": [true, true, true]}], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "name": "agent_runtime_relay_only", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "data.aws_iam_policy_document.agentcore_gateway_permissions", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["lambda:InvokeFunction"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "InvokeActionLambdas"}, {"actions": ["lambda:InvokeFunction"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "InvokeInterceptor"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "name": "agentcore_gateway_permissions", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -26,11 +26,15 @@ {"address": "aws_iam_role_policy.eval_trigger_states", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-eval-trigger-states", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":\"states:StartExecution\",\"Effect\":\"Allow\",\"Resource\":\"arn:aws:states:us-east-1:123456789012:stateMachine:crm-agent-eval-eval-sweep\",\"Sid\":\"StartTheEvalSweep\"},{\"Action\":\"states:DescribeExecution\",\"Effect\":\"Allow\",\"Resource\":\"arn:aws:states:us-east-1:123456789012:execution:crm-agent-eval-eval-sweep:*\",\"Sid\":\"DescribeEvalSweepExecutions\"}]}", "role": "crm-agent-eval-eval-trigger-role"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true}, "before": null, "before_sensitive": false}, "mode": "managed", "name": "eval_trigger_states", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "aws_iam_role_policy.sweep_control_artifacts", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-sweep-control-artifacts", "role": "crm-agent-eval-sweep-control-role"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true}, "before": null, "before_sensitive": false}, "mode": "managed", "name": "sweep_control_artifacts", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "aws_iam_role_policy.sweep_task_invoke_runtime", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-sweep-task-invoke-runtime", "role": "crm-agent-eval-sweep-task-role"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true}, "before": null, "before_sensitive": false}, "mode": "managed", "name": "sweep_task_invoke_runtime", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} +{"address": "aws_kms_alias.cursor", "change": {"actions": ["create"], "after": {"name": "alias/crm-agent-eval-cursor", "region": "us-east-1"}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {}, "after_unknown": {"arn": true, "id": true, "name_prefix": true, "target_key_arn": true, "target_key_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "name": "cursor", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_kms_alias"} {"address": "aws_kms_alias.eval_artifacts", "change": {"actions": ["create"], "after": {"name": "alias/crm-agent-eval-eval-artifacts", "region": "us-east-1"}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {}, "after_unknown": {"arn": true, "id": true, "name_prefix": true, "target_key_arn": true, "target_key_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "name": "eval_artifacts", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_kms_alias"} +{"address": "aws_kms_key.cursor", "change": {"actions": ["create"], "after": {"bypass_policy_lockout_safety_check": false, "custom_key_store_id": null, "customer_master_key_spec": "SYMMETRIC_DEFAULT", "deletion_window_in_days": 7, "description": "crm-agent-eval pagination cursor sealing", "enable_key_rotation": true, "is_enabled": true, "key_usage": "ENCRYPT_DECRYPT", "region": "us-east-1", "tags": {"data-classification": "internal"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "internal", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "timeouts": null, "xks_key_id": null}, "after_identity": {"account_id": null, "id": null, "region": null}, "after_sensitive": {"tags": {}, "tags_all": {}}, "after_unknown": {"arn": true, "id": true, "key_id": true, "multi_region": true, "policy": true, "rotation_period_in_days": true, "tags": {}, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "name": "cursor", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_kms_key"} {"address": "aws_kms_key.eval_artifacts", "change": {"actions": ["create"], "after": {"bypass_policy_lockout_safety_check": false, "custom_key_store_id": null, "customer_master_key_spec": "SYMMETRIC_DEFAULT", "deletion_window_in_days": 7, "description": "crm-agent-eval eval sweep artefacts (S3 SSE-KMS)", "enable_key_rotation": true, "is_enabled": true, "key_usage": "ENCRYPT_DECRYPT", "region": "us-east-1", "tags": {"data-classification": "confidential"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "timeouts": null, "xks_key_id": null}, "after_identity": {"account_id": null, "id": null, "region": null}, "after_sensitive": {"tags": {}, "tags_all": {}}, "after_unknown": {"arn": true, "id": true, "key_id": true, "multi_region": true, "policy": true, "rotation_period_in_days": true, "tags": {}, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "name": "eval_artifacts", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_kms_key"} +{"address": "aws_kms_key_policy.cursor", "change": {"actions": ["create"], "after": {"bypass_policy_lockout_safety_check": false, "region": "us-east-1"}, "after_sensitive": {}, "after_unknown": {"id": true, "key_id": true, "policy": true}, "before": null, "before_sensitive": false}, "mode": "managed", "name": "cursor", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_kms_key_policy"} {"address": "aws_kms_key_policy.eval_artifacts", "change": {"actions": ["create"], "after": {"bypass_policy_lockout_safety_check": false, "region": "us-east-1"}, "after_sensitive": {}, "after_unknown": {"id": true, "key_id": true, "policy": true}, "before": null, "before_sensitive": false}, "mode": "managed", "name": "eval_artifacts", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_kms_key_policy"} -{"address": "aws_s3_object.agent_source", "change": {"actions": ["create"], "after": {"cache_control": null, "checksum_algorithm": null, "content": null, "content_base64": null, "content_disposition": null, "content_encoding": null, "content_language": null, "force_destroy": false, "key": "agent-source/agent.zip", "metadata": null, "object_lock_legal_hold_status": null, "object_lock_mode": null, "object_lock_retain_until_date": null, "override_provider": [], "region": "us-east-1", "source": "build/lambda/agent-source.zip", "source_hash": "zeVpudBplo+yhAOvFyl7Ewscdxvw7SpL4sfAYWsl2hY=", "tags": {"data-classification": "internal"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "internal", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "website_redirect": null}, "after_identity": {"account_id": null, "bucket": null, "key": null, "region": null}, "after_sensitive": {"override_provider": [], "tags": {}, "tags_all": {}}, "after_unknown": {"acl": true, "arn": true, "bucket": true, "bucket_key_enabled": true, "checksum_crc32": true, "checksum_crc32c": true, "checksum_crc64nvme": true, "checksum_sha1": true, "checksum_sha256": true, "content_type": true, "etag": true, "id": true, "kms_key_id": true, "override_provider": [], "server_side_encryption": true, "storage_class": true, "tags": {}, "tags_all": {}, "version_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "name": "agent_source", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_s3_object"} +{"address": "aws_s3_object.agent_source", "change": {"actions": ["create"], "after": {"cache_control": null, "checksum_algorithm": null, "content": null, "content_base64": null, "content_disposition": null, "content_encoding": null, "content_language": null, "force_destroy": false, "key": "agent-source/agent.zip", "metadata": null, "object_lock_legal_hold_status": null, "object_lock_mode": null, "object_lock_retain_until_date": null, "override_provider": [], "region": "us-east-1", "source": "build/lambda/agent-source.zip", "source_hash": "/nj8+11mAmStTEeW3WkkO6CgHjLaNtqdtaOZ37l0NiI=", "tags": {"data-classification": "internal"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "internal", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "website_redirect": null}, "after_identity": {"account_id": null, "bucket": null, "key": null, "region": null}, "after_sensitive": {"override_provider": [], "tags": {}, "tags_all": {}}, "after_unknown": {"acl": true, "arn": true, "bucket": true, "bucket_key_enabled": true, "checksum_crc32": true, "checksum_crc32c": true, "checksum_crc64nvme": true, "checksum_sha1": true, "checksum_sha256": true, "content_type": true, "etag": true, "id": true, "kms_key_id": true, "override_provider": [], "server_side_encryption": true, "storage_class": true, "tags": {}, "tags_all": {}, "version_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "name": "agent_source", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_s3_object"} {"address": "aws_sfn_state_machine.eval_sweep", "change": {"actions": ["create"], "after": {"logging_configuration": [{"include_execution_data": false, "level": "ALL"}], "name": "crm-agent-eval-eval-sweep", "publish": false, "region": "us-east-1", "tags": {"data-classification": "confidential"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "timeouts": null, "tracing_configuration": [{"enabled": true}], "type": "STANDARD"}, "after_identity": {"arn": null}, "after_sensitive": {"encryption_configuration": [], "logging_configuration": [{}], "tags": {}, "tags_all": {}, "tracing_configuration": [{}]}, "after_unknown": {"arn": true, "creation_date": true, "definition": true, "description": true, "encryption_configuration": true, "id": true, "logging_configuration": [{"log_destination": true}], "name_prefix": true, "revision_id": true, "role_arn": true, "state_machine_version_arn": true, "status": true, "tags": {}, "tags_all": {}, "tracing_configuration": [{}], "version_description": true}, "before": null, "before_sensitive": false}, "mode": "managed", "name": "eval_sweep", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_sfn_state_machine"} +{"address": "aws_ssm_parameter.api_allowed_client_ids", "change": {"actions": ["create"], "after": {"allowed_pattern": null, "description": null, "name": "/crm-agent-eval/api/allowed-client-ids", "overwrite": null, "region": "us-east-1", "tags": {"data-classification": "internal"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "internal", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "type": "String", "value_wo": null, "value_wo_version": null}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags": {}, "tags_all": {}, "value": true, "value_wo": true}, "after_unknown": {"arn": true, "data_type": true, "has_value_wo": true, "id": true, "insecure_value": true, "key_id": true, "tags": {}, "tags_all": {}, "tier": true, "value": true, "version": true}, "before": null, "before_sensitive": false}, "mode": "managed", "name": "api_allowed_client_ids", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_ssm_parameter"} {"address": "aws_ssm_parameter.relay_cognito_audience", "change": {"actions": ["create"], "after": {"allowed_pattern": null, "description": null, "name": "/crm-agent-eval/relay/cognito-audience", "overwrite": null, "region": "us-east-1", "tags": {"data-classification": "internal"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "internal", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "type": "String", "value_wo": null, "value_wo_version": null}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags": {}, "tags_all": {}, "value": true, "value_wo": true}, "after_unknown": {"arn": true, "data_type": true, "has_value_wo": true, "id": true, "insecure_value": true, "key_id": true, "tags": {}, "tags_all": {}, "tier": true, "value": true, "version": true}, "before": null, "before_sensitive": false}, "mode": "managed", "name": "relay_cognito_audience", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_ssm_parameter"} {"address": "aws_vpc_endpoint_policy.states", "change": {"actions": ["create"], "after": {"policy": "{\"Statement\":[{\"Action\":\"states:StartExecution\",\"Condition\":{\"StringEquals\":{\"aws:PrincipalAccount\":\"123456789012\"}},\"Effect\":\"Allow\",\"Principal\":\"*\",\"Resource\":\"arn:aws:states:us-east-1:123456789012:stateMachine:crm-agent-eval-eval-sweep\",\"Sid\":\"StartTheEvalSweep\"},{\"Action\":\"states:DescribeExecution\",\"Condition\":{\"StringEquals\":{\"aws:PrincipalAccount\":\"123456789012\"}},\"Effect\":\"Allow\",\"Principal\":\"*\",\"Resource\":\"arn:aws:states:us-east-1:123456789012:execution:crm-agent-eval-eval-sweep:*\",\"Sid\":\"DescribeEvalSweepExecutions\"}],\"Version\":\"2012-10-17\"}", "region": "us-east-1", "timeouts": null}, "after_sensitive": {}, "after_unknown": {"id": true, "vpc_endpoint_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "name": "states", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_vpc_endpoint_policy"} {"address": "aws_vpc_security_group_ingress_rule.endpoints_from_api_origin_alb", "change": {"actions": ["create"], "after": {"cidr_ipv4": null, "cidr_ipv6": null, "description": "HTTPS from the private-origin ALB. The only ingress any endpoint has besides the Lambda group.", "from_port": 443, "ip_protocol": "tcp", "prefix_list_id": null, "region": "us-east-1", "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "to_port": 443}, "after_sensitive": {"tags_all": {}}, "after_unknown": {"arn": true, "id": true, "referenced_security_group_id": true, "security_group_id": true, "security_group_rule_id": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "name": "endpoints_from_api_origin_alb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_vpc_security_group_ingress_rule"} @@ -46,7 +50,7 @@ {"address": "module.agent_relay.aws_iam_role_policy.read_audience_parameter", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-agent-relay-read-parameters", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":\"ssm:GetParameter\",\"Effect\":\"Allow\",\"Resource\":\"arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/relay/cognito-audience\",\"Sid\":\"ReadRelayParameters\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agent_relay", "name": "read_audience_parameter", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.agent_relay.aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-agent-relay-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agent_relay", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.agent_relay.aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-agent-relay-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agent_relay", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.agent_relay.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/relay.zip", "function_name": "crm-agent-eval-agent-relay", "handler": "index.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 512, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "nodejs24.x", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "+FMON6wWdwOUeRDf4YdMAEXOUMQ4mUt7HlHgF4zkY/s=", "source_kms_key_arn": null, "tags": {"data-classification": "confidential"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 660, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags": {}, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags": {}, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agent_relay", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.agent_relay.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/relay.zip", "function_name": "crm-agent-eval-agent-relay", "handler": "index.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 512, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "nodejs24.x", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "7mLoAe1HSrZZiieHU4gOJatEDm41k1Q+YnUy+rpxGd0=", "source_kms_key_arn": null, "tags": {"data-classification": "confidential"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 660, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags": {}, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags": {}, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agent_relay", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.agent_relay.aws_lambda_function_url.this", "change": {"actions": ["create"], "after": {"authorization_type": "AWS_IAM", "cors": [], "function_name": "crm-agent-eval-agent-relay", "invoke_mode": "RESPONSE_STREAM", "qualifier": null, "region": "us-east-1", "timeouts": null}, "after_sensitive": {"cors": []}, "after_unknown": {"cors": [], "function_arn": true, "function_url": true, "id": true, "url_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agent_relay", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function_url"} {"action_reason": "read_because_dependency_pending", "address": "module.agentcore.data.aws_iam_policy_document.codebuild_assume_role", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["sts:AssumeRole"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": ["codebuild.amazonaws.com"], "type": "Service"}], "resources": null, "sid": null}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [{"identifiers": [false]}]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [{"identifiers": [false]}]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.agentcore", "name": "codebuild_assume_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.agentcore.data.aws_iam_policy_document.codebuild_permissions", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "Logs"}, {"actions": ["ecr:GetAuthorizationToken"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": ["*"], "sid": "EcrAuth"}, {"actions": ["ecr:BatchCheckLayerAvailability", "ecr:BatchGetImage", "ecr:CompleteLayerUpload", "ecr:GetDownloadUrlForLayer", "ecr:InitiateLayerUpload", "ecr:PutImage", "ecr:UploadLayerPart"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "EcrPush"}, {"actions": ["s3:GetObject", "s3:GetObjectVersion"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "SourceObject"}, {"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:Encrypt", "kms:GenerateDataKey*"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "ProjectKms"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.agentcore", "name": "codebuild_permissions", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -80,13 +84,13 @@ {"address": "module.agentcore.aws_bedrockagentcore_gateway_target.tool[\"update_opportunity\"]", "change": {"actions": ["create"], "after": {"credential_provider_configuration": [{"api_key": [], "caller_iam_credentials": [], "gateway_iam_role": [{"region": null, "service": null}], "jwt_passthrough": [], "oauth": []}], "description": "Gateway target for CRM tool update_opportunity, backed by its action Lambda.", "metadata_configuration": [], "name": "update-opportunity", "private_endpoint": [], "region": "us-east-1", "target_configuration": [{"http": [], "inference": [], "mcp": [{"api_gateway": [], "connector": [], "lambda": [{"tool_schema": [{"inline_payload": [{"description": "Update low-risk opportunity fields such as name, description, source, and competitor. Stage, value, close date, owner, and primary contact are not changeable here \u2014 use submit_proposal for those.", "input_schema": [{"description": null, "items": [], "property": [{"description": "Fields to change, keyed by field name. Allowed keys: competitor, description, name, source. Omit any field you are not changing. close_date, owner_rep_id, primary_contact_id, stage, value are not accepted here; use submit_proposal.", "items": [], "name": "fields", "property": [], "required": true, "type": "object"}, {"description": "Idempotency key. Use a new unique value (for example a random UUID) for each distinct change. Reuse a key only to retry the exact same change: a retry is never applied twice and returns the original result or a conflict. Never reuse a key for a different change; it can be refused as a conflict.", "items": [], "name": "transaction_key", "property": [], "required": true, "type": "string"}, {"description": null, "items": [], "name": "opportunity_id", "property": [], "required": true, "type": "string"}], "type": "object"}], "name": "update_opportunity", "output_schema": []}], "s3": []}]}], "mcp_server": [], "open_api_schema": [], "smithy_model": []}]}], "timeouts": null}, "after_sensitive": {"credential_provider_configuration": [{"api_key": [], "caller_iam_credentials": [], "gateway_iam_role": [{}], "jwt_passthrough": [], "oauth": []}], "metadata_configuration": [], "private_endpoint": [], "target_configuration": [{"http": [], "inference": [], "mcp": [{"api_gateway": [], "connector": [], "lambda": [{"tool_schema": [{"inline_payload": [{"input_schema": [{"items": [], "property": [{"items": [], "property": []}, {"items": [], "property": []}, {"items": [], "property": []}]}], "output_schema": []}], "s3": []}]}], "mcp_server": [], "open_api_schema": [], "smithy_model": []}]}]}, "after_unknown": {"credential_provider_configuration": [{"api_key": [], "caller_iam_credentials": [], "gateway_iam_role": [{}], "jwt_passthrough": [], "oauth": []}], "gateway_identifier": true, "metadata_configuration": [], "private_endpoint": [], "target_configuration": [{"http": [], "inference": [], "mcp": [{"api_gateway": [], "connector": [], "lambda": [{"lambda_arn": true, "tool_schema": [{"inline_payload": [{"input_schema": [{"items": [], "property": [{"items": [], "property": []}, {"items": [], "property": []}, {"items": [], "property": []}]}], "output_schema": []}], "s3": []}]}], "mcp_server": [], "open_api_schema": [], "smithy_model": []}]}], "target_id": true}, "before": null, "before_sensitive": false}, "index": "update_opportunity", "mode": "managed", "module_address": "module.agentcore", "name": "tool", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_bedrockagentcore_gateway_target"} {"address": "module.agentcore.aws_cloudwatch_log_group.codebuild", "change": {"actions": ["create"], "after": {"name": "/aws/codebuild/crm-agent-eval-agent-image", "region": "us-east-1", "retention_in_days": 365, "skip_destroy": false, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags_all": {}}, "after_unknown": {"arn": true, "deletion_protection_enabled": true, "id": true, "kms_key_id": true, "log_group_class": true, "name_prefix": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agentcore", "name": "codebuild", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudwatch_log_group"} {"address": "module.agentcore.aws_cloudwatch_log_group.runtime", "change": {"actions": ["create"], "after": {"region": "us-east-1", "retention_in_days": 365, "skip_destroy": false, "tags": {"data-classification": "confidential"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags": {}, "tags_all": {}}, "after_unknown": {"arn": true, "deletion_protection_enabled": true, "id": true, "kms_key_id": true, "log_group_class": true, "name": true, "name_prefix": true, "tags": {}, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agentcore", "name": "runtime", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudwatch_log_group"} -{"address": "module.agentcore.aws_codebuild_project.agent_image", "change": {"actions": ["create"], "after": {"artifacts": [{"artifact_identifier": null, "bucket_owner_access": null, "encryption_disabled": false, "location": null, "name": null, "namespace_type": null, "override_artifact_name": false, "packaging": null, "path": null, "type": "NO_ARTIFACTS"}], "badge_enabled": false, "build_batch_config": [], "build_timeout": 30, "cache": [], "concurrent_build_limit": null, "description": "Builds and pushes the AgentCore Runtime container image.", "environment": [{"certificate": null, "compute_type": "BUILD_GENERAL1_SMALL", "docker_server": [], "environment_variable": [{"name": "ECR_REPOSITORY_URI", "type": "PLAINTEXT"}, {"name": "AWS_DEFAULT_REGION", "type": "PLAINTEXT", "value": "us-east-1"}], "fleet": [], "image": "aws/codebuild/amazonlinux2-aarch64-standard:3.0", "image_pull_credentials_type": "CODEBUILD", "privileged_mode": true, "registry_credential": [], "type": "ARM_CONTAINER"}], "file_system_locations": [], "logs_config": [{"cloudwatch_logs": [{"group_name": "/aws/codebuild/crm-agent-eval-agent-image", "status": "ENABLED", "stream_name": null}], "s3_logs": []}], "name": "crm-agent-eval-agent-image", "project_visibility": "PRIVATE", "queued_timeout": 480, "region": "us-east-1", "resource_access_role": null, "secondary_artifacts": [], "secondary_source_version": [], "secondary_sources": [], "source": [{"auth": [], "build_status_config": [], "buildspec": "\"phases\":\n \"build\":\n \"commands\":\n - \"docker build -t ${ECR_REPOSITORY_URI}:sha-cde569b9d069 .\"\n \"post_build\":\n \"commands\":\n - \"docker push ${ECR_REPOSITORY_URI}:sha-cde569b9d069\"\n \"pre_build\":\n \"commands\":\n - \"REGISTRY_HOST=${ECR_REPOSITORY_URI%%/*}\"\n - \"aws ecr get-login-password --region ${AWS_DEFAULT_REGION} | docker login --username\n AWS --password-stdin ${REGISTRY_HOST}\"\n\"version\": \"0.2\"\n", "git_clone_depth": null, "git_submodules_config": [], "insecure_ssl": null, "report_build_status": null, "type": "S3"}], "source_version": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "vpc_config": []}, "after_identity": {"arn": null}, "after_sensitive": {"artifacts": [{}], "build_batch_config": [], "cache": [], "environment": [{"docker_server": [], "environment_variable": [{}, {}], "fleet": [], "registry_credential": []}], "file_system_locations": [], "logs_config": [{"cloudwatch_logs": [{}], "s3_logs": []}], "secondary_artifacts": [], "secondary_source_version": [], "secondary_sources": [], "source": [{"auth": [], "build_status_config": [], "git_submodules_config": []}], "tags_all": {}, "vpc_config": []}, "after_unknown": {"arn": true, "artifacts": [{}], "auto_retry_limit": true, "badge_url": true, "build_batch_config": [], "cache": [], "encryption_key": true, "environment": [{"docker_server": [], "environment_variable": [{"value": true}, {}], "fleet": [], "host_kernel": true, "registry_credential": []}], "file_system_locations": [], "id": true, "logs_config": [{"cloudwatch_logs": [{}], "s3_logs": []}], "public_project_alias": true, "secondary_artifacts": [], "secondary_source_version": [], "secondary_sources": [], "service_role": true, "source": [{"auth": [], "build_status_config": [], "git_submodules_config": [], "location": true}], "tags_all": {}, "vpc_config": []}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agentcore", "name": "agent_image", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_codebuild_project"} +{"address": "module.agentcore.aws_codebuild_project.agent_image", "change": {"actions": ["create"], "after": {"artifacts": [{"artifact_identifier": null, "bucket_owner_access": null, "encryption_disabled": false, "location": null, "name": null, "namespace_type": null, "override_artifact_name": false, "packaging": null, "path": null, "type": "NO_ARTIFACTS"}], "badge_enabled": false, "build_batch_config": [], "build_timeout": 30, "cache": [], "concurrent_build_limit": null, "description": "Builds and pushes the AgentCore Runtime container image.", "environment": [{"certificate": null, "compute_type": "BUILD_GENERAL1_SMALL", "docker_server": [], "environment_variable": [{"name": "ECR_REPOSITORY_URI", "type": "PLAINTEXT"}, {"name": "AWS_DEFAULT_REGION", "type": "PLAINTEXT", "value": "us-east-1"}], "fleet": [], "image": "aws/codebuild/amazonlinux2-aarch64-standard:3.0", "image_pull_credentials_type": "CODEBUILD", "privileged_mode": true, "registry_credential": [], "type": "ARM_CONTAINER"}], "file_system_locations": [], "logs_config": [{"cloudwatch_logs": [{"group_name": "/aws/codebuild/crm-agent-eval-agent-image", "status": "ENABLED", "stream_name": null}], "s3_logs": []}], "name": "crm-agent-eval-agent-image", "project_visibility": "PRIVATE", "queued_timeout": 480, "region": "us-east-1", "resource_access_role": null, "secondary_artifacts": [], "secondary_source_version": [], "secondary_sources": [], "source": [{"auth": [], "build_status_config": [], "buildspec": "\"phases\":\n \"build\":\n \"commands\":\n - \"docker build -t ${ECR_REPOSITORY_URI}:sha-fe78fcfb5d66 .\"\n \"post_build\":\n \"commands\":\n - \"docker push ${ECR_REPOSITORY_URI}:sha-fe78fcfb5d66\"\n \"pre_build\":\n \"commands\":\n - \"REGISTRY_HOST=${ECR_REPOSITORY_URI%%/*}\"\n - \"aws ecr get-login-password --region ${AWS_DEFAULT_REGION} | docker login --username\n AWS --password-stdin ${REGISTRY_HOST}\"\n\"version\": \"0.2\"\n", "git_clone_depth": null, "git_submodules_config": [], "insecure_ssl": null, "report_build_status": null, "type": "S3"}], "source_version": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "vpc_config": []}, "after_identity": {"arn": null}, "after_sensitive": {"artifacts": [{}], "build_batch_config": [], "cache": [], "environment": [{"docker_server": [], "environment_variable": [{}, {}], "fleet": [], "registry_credential": []}], "file_system_locations": [], "logs_config": [{"cloudwatch_logs": [{}], "s3_logs": []}], "secondary_artifacts": [], "secondary_source_version": [], "secondary_sources": [], "source": [{"auth": [], "build_status_config": [], "git_submodules_config": []}], "tags_all": {}, "vpc_config": []}, "after_unknown": {"arn": true, "artifacts": [{}], "auto_retry_limit": true, "badge_url": true, "build_batch_config": [], "cache": [], "encryption_key": true, "environment": [{"docker_server": [], "environment_variable": [{"value": true}, {}], "fleet": [], "host_kernel": true, "registry_credential": []}], "file_system_locations": [], "id": true, "logs_config": [{"cloudwatch_logs": [{}], "s3_logs": []}], "public_project_alias": true, "secondary_artifacts": [], "secondary_source_version": [], "secondary_sources": [], "service_role": true, "source": [{"auth": [], "build_status_config": [], "git_submodules_config": [], "location": true}], "tags_all": {}, "vpc_config": []}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agentcore", "name": "agent_image", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_codebuild_project"} {"address": "module.agentcore.aws_ecr_lifecycle_policy.agent", "change": {"actions": ["create"], "after": {"policy": "{\"rules\":[{\"action\":{\"type\":\"expire\"},\"description\":\"Expire untagged images after 14 days\",\"rulePriority\":1,\"selection\":{\"countNumber\":14,\"countType\":\"sinceImagePushed\",\"countUnit\":\"days\",\"tagStatus\":\"untagged\"}},{\"action\":{\"type\":\"expire\"},\"description\":\"Keep only the most recent 10 tagged images\",\"rulePriority\":2,\"selection\":{\"countNumber\":10,\"countType\":\"imageCountMoreThan\",\"tagPrefixList\":[\"sha-\"],\"tagStatus\":\"tagged\"}}]}", "region": "us-east-1", "repository": "crm-agent-eval-agent"}, "after_identity": {"account_id": null, "region": null, "repository": null}, "after_sensitive": {}, "after_unknown": {"id": true, "registry_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agentcore", "name": "agent", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_ecr_lifecycle_policy"} {"address": "module.agentcore.aws_ecr_repository.agent", "change": {"actions": ["create"], "after": {"encryption_configuration": [{"encryption_type": "KMS"}], "force_delete": true, "image_scanning_configuration": [{"scan_on_push": true}], "image_tag_mutability": "IMMUTABLE", "image_tag_mutability_exclusion_filter": [], "name": "crm-agent-eval-agent", "region": "us-east-1", "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "timeouts": null}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"encryption_configuration": [{}], "image_scanning_configuration": [{}], "image_tag_mutability_exclusion_filter": [], "tags_all": {}}, "after_unknown": {"arn": true, "encryption_configuration": [{"kms_key": true}], "id": true, "image_scanning_configuration": [{}], "image_tag_mutability_exclusion_filter": [], "registry_id": true, "repository_url": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agentcore", "name": "agent", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_ecr_repository"} {"address": "module.agentcore.aws_iam_role.codebuild", "change": {"actions": ["create"], "after": {"description": null, "force_detach_policies": false, "max_session_duration": 3600, "name": "crm-agent-eval-codebuild-role", "path": "/", "permissions_boundary": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null}, "after_sensitive": {"inline_policy": [], "managed_policy_arns": [], "tags_all": {}}, "after_unknown": {"arn": true, "assume_role_policy": true, "create_date": true, "id": true, "inline_policy": true, "managed_policy_arns": true, "name_prefix": true, "tags_all": {}, "unique_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agentcore", "name": "codebuild", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role"} {"address": "module.agentcore.aws_iam_role_policy.codebuild", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-codebuild"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agentcore", "name": "codebuild", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.agentcore.aws_lambda_permission.gateway_invoke_interceptor", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-identity-interceptor", "function_url_auth_type": null, "invoked_via_function_url": null, "principal": "bedrock-agentcore.amazonaws.com", "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "statement_id": "AllowGatewayInvokeIdentityInterceptor", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "source_arn": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agentcore", "name": "gateway_invoke_interceptor", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} -{"address": "module.agentcore.null_resource.image_build", "change": {"actions": ["create"], "after": {"triggers": {"project_name": "crm-agent-eval-agent-image", "source_content_hash": "zeVpudBplo+yhAOvFyl7Ewscdxvw7SpL4sfAYWsl2hY="}}, "after_sensitive": {"triggers": {}}, "after_unknown": {"id": true, "triggers": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agentcore", "name": "image_build", "provider_name": "registry.terraform.io/hashicorp/null", "type": "null_resource"} +{"address": "module.agentcore.null_resource.image_build", "change": {"actions": ["create"], "after": {"triggers": {"project_name": "crm-agent-eval-agent-image", "source_content_hash": "/nj8+11mAmStTEeW3WkkO6CgHjLaNtqdtaOZ37l0NiI="}}, "after_sensitive": {"triggers": {}}, "after_unknown": {"id": true, "triggers": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agentcore", "name": "image_build", "provider_name": "registry.terraform.io/hashicorp/null", "type": "null_resource"} {"action_reason": "read_because_config_unknown", "address": "module.api.data.aws_iam_policy_document.resource_policy", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["execute-api:Invoke"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": ["*"], "type": "AWS"}], "resources": ["execute-api:/*"], "sid": "AllowInvokeFromNamedVpcEndpointsOnly"}, {"actions": ["execute-api:Invoke"], "condition": [{"test": "StringNotEquals", "values": [null], "variable": "aws:sourceVpce"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": ["*"], "type": "AWS"}], "resources": ["execute-api:/*"], "sid": "DenyInvokeFromAnyOtherVpcEndpoint"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}, {"actions": [false], "condition": [{"values": [true]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.api", "name": "resource_policy", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"address": "module.api.aws_api_gateway_authorizer.cognito", "change": {"actions": ["create"], "after": {"authorizer_credentials": null, "authorizer_result_ttl_in_seconds": 300, "authorizer_uri": null, "identity_source": "method.request.header.Authorization", "identity_validation_expression": null, "name": "cognito-user-pools", "region": "us-east-1", "type": "COGNITO_USER_POOLS"}, "after_sensitive": {"provider_arns": []}, "after_unknown": {"arn": true, "id": true, "provider_arns": true, "rest_api_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.api", "name": "cognito", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_api_gateway_authorizer"} {"address": "module.api.aws_api_gateway_deployment.this", "change": {"actions": ["create"], "after": {"description": null, "region": "us-east-1", "variables": null}, "after_identity": {"account_id": null, "id": null, "region": null, "rest_api_id": null}, "after_sensitive": {"triggers": {}}, "after_unknown": {"created_date": true, "id": true, "rest_api_id": true, "triggers": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.api", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_api_gateway_deployment"} @@ -265,12 +269,13 @@ {"action_reason": "read_because_config_unknown", "address": "module.frontend_cdn.data.aws_iam_policy_document.frontend_kms", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:*"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": ["arn:aws:iam::123456789012:root"], "type": "AWS"}], "resources": ["*"], "sid": "EnableIAMUserPermissions"}, {"actions": ["kms:Decrypt"], "condition": [{"test": "StringEquals", "values": [null], "variable": "AWS:SourceArn"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": ["cloudfront.amazonaws.com"], "type": "Service"}], "resources": ["*"], "sid": "AllowCloudFrontOACDecrypt"}, {"actions": ["kms:CreateGrant", "kms:Decrypt", "kms:Encrypt", "kms:GenerateDataKey*", "kms:ReEncrypt*"], "condition": [{"test": "ArnNotEquals", "values": ["arn:aws:iam::123456789012:role/example-deployer"], "variable": "aws:PrincipalArn"}, {"test": "Bool", "values": ["false"], "variable": "aws:PrincipalIsAWSService"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": ["*"], "type": "*"}], "resources": ["*"], "sid": "DenyKeyUseToNonProjectPrincipals"}, {"actions": ["kms:CreateAlias", "kms:DeleteAlias", "kms:DisableKey", "kms:DisableKeyRotation", "kms:PutKeyPolicy", "kms:RevokeGrant", "kms:ScheduleKeyDeletion", "kms:TagResource", "kms:UntagResource", "kms:UpdateAlias", "kms:UpdateKeyDescription"], "condition": [{"test": "ArnNotEquals", "values": ["arn:aws:iam::123456789012:role/example-deployer", "arn:aws:iam::123456789012:root"], "variable": "aws:PrincipalArn"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": ["*"], "type": "*"}], "resources": ["*"], "sid": "DenyKeyAdministrationToNonOperators"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}, {"actions": [false, false, false, false, false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}, {"actions": [false, false, false, false, false, false, false, false, false, false, false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}, {"actions": [false], "condition": [{"values": [true]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}, {"actions": [false, false, false, false, false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}, {"actions": [false, false, false, false, false, false, false, false, false, false, false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.frontend_cdn", "name": "frontend_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.frontend_cdn.data.aws_iam_policy_document.logs_tls_deny", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["s3:PutObject"], "condition": [{"test": "StringEquals", "values": ["123456789012"], "variable": "aws:SourceAccount"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": ["logging.s3.amazonaws.com"], "type": "Service"}], "resources": [null], "sid": "AllowS3ServerAccessLogDelivery"}, {"actions": ["s3:PutObject"], "condition": [{"test": "ArnLike", "values": ["arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/*"], "variable": "aws:SourceArn"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": ["logdelivery.elasticloadbalancing.amazonaws.com"], "type": "Service"}], "resources": [null], "sid": "AllowAlbAccessLogDelivery"}, {"actions": ["s3:*"], "condition": [{"test": "Bool", "values": ["false"], "variable": "aws:SecureTransport"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": ["*"], "type": "AWS"}], "resources": [null, null], "sid": "DenyInsecureTransport"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.frontend_cdn", "name": "logs_tls_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.frontend_cdn.data.aws_iam_policy_document.origin", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["s3:*"], "condition": [{"test": "Bool", "values": ["false"], "variable": "aws:SecureTransport"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": ["*"], "type": "AWS"}], "resources": [null, null], "sid": "DenyInsecureTransport"}, {"actions": ["s3:GetObject"], "condition": [{"test": "StringEquals", "values": [null], "variable": "AWS:SourceArn"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": ["cloudfront.amazonaws.com"], "type": "Service"}], "resources": [null], "sid": "AllowCloudFrontOACRead"}, {"actions": ["s3:AbortMultipartUpload", "s3:DeleteObject", "s3:DeleteObjectTagging", "s3:DeleteObjectVersion", "s3:DeleteObjectVersionTagging", "s3:PutObject", "s3:PutObjectTagging", "s3:PutObjectVersionTagging"], "condition": [{"test": "ArnNotEquals", "values": ["arn:aws:iam::123456789012:role/example-deployer"], "variable": "aws:PrincipalArn"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": ["*"], "type": "*"}], "resources": [null, null], "sid": "DenyObjectWritesToNonOperators"}, {"actions": ["s3:DeleteBucket", "s3:DeleteBucketPolicy", "s3:PutAccelerateConfiguration", "s3:PutAnalyticsConfiguration", "s3:PutBucketAcl", "s3:PutBucketCORS", "s3:PutBucketLogging", "s3:PutBucketNotification", "s3:PutBucketObjectLockConfiguration", "s3:PutBucketOwnershipControls", "s3:PutBucketPolicy", "s3:PutBucketPublicAccessBlock", "s3:PutBucketRequestPayment", "s3:PutBucketTagging", "s3:PutBucketVersioning", "s3:PutBucketWebsite", "s3:PutEncryptionConfiguration", "s3:PutIntelligentTieringConfiguration", "s3:PutInventoryConfiguration", "s3:PutLifecycleConfiguration", "s3:PutMetricsConfiguration", "s3:PutReplicationConfiguration"], "condition": [{"test": "ArnNotEquals", "values": ["arn:aws:iam::123456789012:role/example-deployer", "arn:aws:iam::123456789012:root"], "variable": "aws:PrincipalArn"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": ["*"], "type": "*"}], "resources": [null], "sid": "DenyBucketAdministrationToNonOperators"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false, false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}, {"actions": [false, false, false, false, false, false, false, false], "condition": [{"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false, false]}, {"actions": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [true, true]}, {"actions": [false], "condition": [{"values": [true]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [true]}, {"actions": [false, false, false, false, false, false, false, false], "condition": [{"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [true, true]}, {"actions": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.frontend_cdn", "name": "origin", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"address": "module.frontend_cdn.aws_cloudfront_distribution.frontend", "change": {"actions": ["create"], "after": {"aliases": null, "anycast_ip_list_id": null, "cache_tag_config": [], "comment": "crm-agent-evalcrm frontend", "connection_function_association": [], "custom_error_response": [], "default_cache_behavior": [{"allowed_methods": ["GET", "HEAD"], "cache_policy_id": "658327ea-f89d-4fab-a63d-7e88639e58f6", "cached_methods": ["GET", "HEAD"], "compress": true, "field_level_encryption_id": null, "forwarded_values": [], "function_association": [{"event_type": "viewer-request"}], "lambda_function_association": [], "min_ttl": 0, "origin_request_policy_id": null, "realtime_log_config_arn": null, "response_headers_policy_id": "67f7725c-6f97-4210-82d7-5512b31e9d03", "smooth_streaming": null, "target_origin_id": "s3-frontend-origin", "viewer_protocol_policy": "redirect-to-https"}], "default_root_object": "index.html", "enabled": true, "http_version": "http2", "is_ipv6_enabled": false, "logging_config": [{"include_cookies": false, "prefix": "cloudfront-access-logs/"}], "ordered_cache_behavior": [{"allowed_methods": ["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"], "cache_policy_id": "4135ea2d-6df8-44a3-9df3-4b5a84be39ad", "cached_methods": ["GET", "HEAD"], "compress": true, "field_level_encryption_id": null, "forwarded_values": [], "function_association": [{"event_type": "viewer-request"}], "lambda_function_association": [], "min_ttl": 0, "origin_request_policy_id": "b689b0a8-53d0-40ab-baf2-68738e2966ac", "path_pattern": "/api/*", "realtime_log_config_arn": null, "response_headers_policy_id": "67f7725c-6f97-4210-82d7-5512b31e9d03", "smooth_streaming": null, "target_origin_id": "api-gateway-origin", "trusted_key_groups": null, "trusted_signers": null, "viewer_protocol_policy": "https-only"}, {"allowed_methods": ["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"], "cache_policy_id": "4135ea2d-6df8-44a3-9df3-4b5a84be39ad", "cached_methods": ["GET", "HEAD"], "compress": false, "field_level_encryption_id": null, "forwarded_values": [], "function_association": [], "lambda_function_association": [], "min_ttl": 0, "path_pattern": "/agent/*", "realtime_log_config_arn": null, "response_headers_policy_id": "67f7725c-6f97-4210-82d7-5512b31e9d03", "smooth_streaming": null, "target_origin_id": "agent-relay-origin", "trusted_key_groups": null, "trusted_signers": null, "viewer_protocol_policy": "https-only"}], "origin": [{"connection_attempts": 3, "connection_timeout": 10, "custom_header": [], "custom_origin_config": [{"http_port": 80, "https_port": 443, "ip_address_type": "", "origin_keepalive_timeout": 5, "origin_mtls_config": [], "origin_protocol_policy": "https-only", "origin_read_timeout": 60, "origin_ssl_protocols": ["TLSv1.2"]}], "origin_id": "agent-relay-origin", "origin_path": "", "origin_shield": [], "s3_origin_config": [], "vpc_origin_config": []}, {"connection_attempts": 3, "connection_timeout": 10, "custom_header": [], "custom_origin_config": [], "origin_access_control_id": "", "origin_id": "api-gateway-origin", "origin_path": "", "origin_shield": [], "s3_origin_config": [], "vpc_origin_config": [{"origin_keepalive_timeout": 5, "origin_read_timeout": 30, "owner_account_id": ""}]}, {"connection_attempts": 3, "connection_timeout": 10, "custom_header": [], "custom_origin_config": [], "origin_id": "s3-frontend-origin", "origin_path": "", "origin_shield": [], "s3_origin_config": [], "vpc_origin_config": []}], "origin_group": [], "price_class": "PriceClass_100", "restrictions": [{"geo_restriction": [{"restriction_type": "none"}]}], "retain_on_delete": false, "staging": false, "tags": {"data-classification": "confidential"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "viewer_certificate": [{"acm_certificate_arn": null, "cloudfront_default_certificate": true, "iam_certificate_id": null, "minimum_protocol_version": "TLSv1", "ssl_support_method": null}], "viewer_mtls_config": [], "wait_for_deployment": true, "web_acl_id": null}, "after_identity": {"account_id": null, "id": null}, "after_sensitive": {"cache_tag_config": [], "connection_function_association": [], "custom_error_response": [], "default_cache_behavior": [{"allowed_methods": [false, false], "cached_methods": [false, false], "forwarded_values": [], "function_association": [{}], "grpc_config": [], "lambda_function_association": [], "trusted_key_groups": [], "trusted_signers": []}], "logging_config": [{}], "ordered_cache_behavior": [{"allowed_methods": [false, false, false, false, false, false, false], "cached_methods": [false, false], "forwarded_values": [], "function_association": [{}], "grpc_config": [], "lambda_function_association": []}, {"allowed_methods": [false, false, false, false, false, false, false], "cached_methods": [false, false], "forwarded_values": [], "function_association": [], "grpc_config": [], "lambda_function_association": []}], "origin": [{"custom_header": [], "custom_origin_config": [{"origin_mtls_config": [], "origin_ssl_protocols": [false]}], "origin_shield": [], "s3_origin_config": [], "vpc_origin_config": []}, {"custom_header": [], "custom_origin_config": [], "origin_shield": [], "s3_origin_config": [], "vpc_origin_config": [{}]}, {"custom_header": [], "custom_origin_config": [], "origin_shield": [], "s3_origin_config": [], "vpc_origin_config": []}], "origin_group": [], "restrictions": [{"geo_restriction": [{"locations": []}]}], "tags": {}, "tags_all": {}, "trusted_key_groups": [], "trusted_signers": [], "viewer_certificate": [{}], "viewer_mtls_config": []}, "after_unknown": {"arn": true, "cache_tag_config": [], "caller_reference": true, "connection_function_association": [], "continuous_deployment_policy_id": true, "custom_error_response": [], "default_cache_behavior": [{"allowed_methods": [false, false], "cached_methods": [false, false], "default_ttl": true, "forwarded_values": [], "function_association": [{"function_arn": true}], "grpc_config": true, "lambda_function_association": [], "max_ttl": true, "trusted_key_groups": true, "trusted_signers": true}], "domain_name": true, "etag": true, "hosted_zone_id": true, "id": true, "in_progress_validation_batches": true, "last_modified_time": true, "logging_config": [{"bucket": true}], "logging_v1_enabled": true, "ordered_cache_behavior": [{"allowed_methods": [false, false, false, false, false, false, false], "cached_methods": [false, false], "default_ttl": true, "forwarded_values": [], "function_association": [{"function_arn": true}], "grpc_config": true, "lambda_function_association": [], "max_ttl": true}, {"allowed_methods": [false, false, false, false, false, false, false], "cached_methods": [false, false], "default_ttl": true, "forwarded_values": [], "function_association": [], "grpc_config": true, "lambda_function_association": [], "max_ttl": true, "origin_request_policy_id": true}], "origin": [{"custom_header": [], "custom_origin_config": [{"origin_mtls_config": [], "origin_ssl_protocols": [false]}], "domain_name": true, "origin_access_control_id": true, "origin_shield": [], "response_completion_timeout": true, "s3_origin_config": [], "vpc_origin_config": []}, {"custom_header": [], "custom_origin_config": [], "domain_name": true, "origin_shield": [], "response_completion_timeout": true, "s3_origin_config": [], "vpc_origin_config": [{"vpc_origin_id": true}]}, {"custom_header": [], "custom_origin_config": [], "domain_name": true, "origin_access_control_id": true, "origin_shield": [], "response_completion_timeout": true, "s3_origin_config": [], "vpc_origin_config": []}], "origin_group": [], "restrictions": [{"geo_restriction": [{"locations": true}]}], "status": true, "tags": {}, "tags_all": {}, "trusted_key_groups": true, "trusted_signers": true, "viewer_certificate": [{}], "viewer_mtls_config": []}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.frontend_cdn", "name": "frontend", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudfront_distribution"} +{"address": "module.frontend_cdn.aws_cloudfront_distribution.frontend", "change": {"actions": ["create"], "after": {"aliases": null, "anycast_ip_list_id": null, "cache_tag_config": [], "comment": "crm-agent-evalcrm frontend", "connection_function_association": [], "custom_error_response": [], "default_cache_behavior": [{"allowed_methods": ["GET", "HEAD"], "cache_policy_id": "658327ea-f89d-4fab-a63d-7e88639e58f6", "cached_methods": ["GET", "HEAD"], "compress": true, "field_level_encryption_id": null, "forwarded_values": [], "function_association": [{"event_type": "viewer-request"}], "lambda_function_association": [], "min_ttl": 0, "origin_request_policy_id": null, "realtime_log_config_arn": null, "smooth_streaming": null, "target_origin_id": "s3-frontend-origin", "viewer_protocol_policy": "redirect-to-https"}], "default_root_object": "index.html", "enabled": true, "http_version": "http2", "is_ipv6_enabled": false, "logging_config": [{"include_cookies": false, "prefix": "cloudfront-access-logs/"}], "ordered_cache_behavior": [{"allowed_methods": ["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"], "cache_policy_id": "4135ea2d-6df8-44a3-9df3-4b5a84be39ad", "cached_methods": ["GET", "HEAD"], "compress": true, "field_level_encryption_id": null, "forwarded_values": [], "function_association": [{"event_type": "viewer-request"}], "lambda_function_association": [], "min_ttl": 0, "origin_request_policy_id": "b689b0a8-53d0-40ab-baf2-68738e2966ac", "path_pattern": "/api/*", "realtime_log_config_arn": null, "smooth_streaming": null, "target_origin_id": "api-gateway-origin", "trusted_key_groups": null, "trusted_signers": null, "viewer_protocol_policy": "https-only"}, {"allowed_methods": ["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"], "cache_policy_id": "4135ea2d-6df8-44a3-9df3-4b5a84be39ad", "cached_methods": ["GET", "HEAD"], "compress": false, "field_level_encryption_id": null, "forwarded_values": [], "function_association": [], "lambda_function_association": [], "min_ttl": 0, "path_pattern": "/agent/*", "realtime_log_config_arn": null, "smooth_streaming": null, "target_origin_id": "agent-relay-origin", "trusted_key_groups": null, "trusted_signers": null, "viewer_protocol_policy": "https-only"}], "origin": [{"connection_attempts": 3, "connection_timeout": 10, "custom_header": [], "custom_origin_config": [{"http_port": 80, "https_port": 443, "ip_address_type": "", "origin_keepalive_timeout": 5, "origin_mtls_config": [], "origin_protocol_policy": "https-only", "origin_read_timeout": 60, "origin_ssl_protocols": ["TLSv1.2"]}], "origin_id": "agent-relay-origin", "origin_path": "", "origin_shield": [], "s3_origin_config": [], "vpc_origin_config": []}, {"connection_attempts": 3, "connection_timeout": 10, "custom_header": [], "custom_origin_config": [], "origin_access_control_id": "", "origin_id": "api-gateway-origin", "origin_path": "", "origin_shield": [], "s3_origin_config": [], "vpc_origin_config": [{"origin_keepalive_timeout": 5, "origin_read_timeout": 30, "owner_account_id": ""}]}, {"connection_attempts": 3, "connection_timeout": 10, "custom_header": [], "custom_origin_config": [], "origin_id": "s3-frontend-origin", "origin_path": "", "origin_shield": [], "s3_origin_config": [], "vpc_origin_config": []}], "origin_group": [], "price_class": "PriceClass_100", "restrictions": [{"geo_restriction": [{"restriction_type": "none"}]}], "retain_on_delete": false, "staging": false, "tags": {"data-classification": "confidential"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "viewer_certificate": [{"acm_certificate_arn": null, "cloudfront_default_certificate": true, "iam_certificate_id": null, "minimum_protocol_version": "TLSv1", "ssl_support_method": null}], "viewer_mtls_config": [], "wait_for_deployment": true, "web_acl_id": null}, "after_identity": {"account_id": null, "id": null}, "after_sensitive": {"cache_tag_config": [], "connection_function_association": [], "custom_error_response": [], "default_cache_behavior": [{"allowed_methods": [false, false], "cached_methods": [false, false], "forwarded_values": [], "function_association": [{}], "grpc_config": [], "lambda_function_association": [], "trusted_key_groups": [], "trusted_signers": []}], "logging_config": [{}], "ordered_cache_behavior": [{"allowed_methods": [false, false, false, false, false, false, false], "cached_methods": [false, false], "forwarded_values": [], "function_association": [{}], "grpc_config": [], "lambda_function_association": []}, {"allowed_methods": [false, false, false, false, false, false, false], "cached_methods": [false, false], "forwarded_values": [], "function_association": [], "grpc_config": [], "lambda_function_association": []}], "origin": [{"custom_header": [], "custom_origin_config": [{"origin_mtls_config": [], "origin_ssl_protocols": [false]}], "origin_shield": [], "s3_origin_config": [], "vpc_origin_config": []}, {"custom_header": [], "custom_origin_config": [], "origin_shield": [], "s3_origin_config": [], "vpc_origin_config": [{}]}, {"custom_header": [], "custom_origin_config": [], "origin_shield": [], "s3_origin_config": [], "vpc_origin_config": []}], "origin_group": [], "restrictions": [{"geo_restriction": [{"locations": []}]}], "tags": {}, "tags_all": {}, "trusted_key_groups": [], "trusted_signers": [], "viewer_certificate": [{}], "viewer_mtls_config": []}, "after_unknown": {"arn": true, "cache_tag_config": [], "caller_reference": true, "connection_function_association": [], "continuous_deployment_policy_id": true, "custom_error_response": [], "default_cache_behavior": [{"allowed_methods": [false, false], "cached_methods": [false, false], "default_ttl": true, "forwarded_values": [], "function_association": [{"function_arn": true}], "grpc_config": true, "lambda_function_association": [], "max_ttl": true, "response_headers_policy_id": true, "trusted_key_groups": true, "trusted_signers": true}], "domain_name": true, "etag": true, "hosted_zone_id": true, "id": true, "in_progress_validation_batches": true, "last_modified_time": true, "logging_config": [{"bucket": true}], "logging_v1_enabled": true, "ordered_cache_behavior": [{"allowed_methods": [false, false, false, false, false, false, false], "cached_methods": [false, false], "default_ttl": true, "forwarded_values": [], "function_association": [{"function_arn": true}], "grpc_config": true, "lambda_function_association": [], "max_ttl": true, "response_headers_policy_id": true}, {"allowed_methods": [false, false, false, false, false, false, false], "cached_methods": [false, false], "default_ttl": true, "forwarded_values": [], "function_association": [], "grpc_config": true, "lambda_function_association": [], "max_ttl": true, "origin_request_policy_id": true, "response_headers_policy_id": true}], "origin": [{"custom_header": [], "custom_origin_config": [{"origin_mtls_config": [], "origin_ssl_protocols": [false]}], "domain_name": true, "origin_access_control_id": true, "origin_shield": [], "response_completion_timeout": true, "s3_origin_config": [], "vpc_origin_config": []}, {"custom_header": [], "custom_origin_config": [], "domain_name": true, "origin_shield": [], "response_completion_timeout": true, "s3_origin_config": [], "vpc_origin_config": [{"vpc_origin_id": true}]}, {"custom_header": [], "custom_origin_config": [], "domain_name": true, "origin_access_control_id": true, "origin_shield": [], "response_completion_timeout": true, "s3_origin_config": [], "vpc_origin_config": []}], "origin_group": [], "restrictions": [{"geo_restriction": [{"locations": true}]}], "status": true, "tags": {}, "tags_all": {}, "trusted_key_groups": true, "trusted_signers": true, "viewer_certificate": [{}], "viewer_mtls_config": []}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.frontend_cdn", "name": "frontend", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudfront_distribution"} {"address": "module.frontend_cdn.aws_cloudfront_function.api_path_rewrite", "change": {"actions": ["create"], "after": {"code": "// SPDX-License-Identifier: MIT\n// CloudFront viewer-request function for the `/api/*` behaviour: rewrites\n// `/api/` to `/prod/` so a request the SPA\n// sends to `apiBaseUrl = \"/api\"` lands on the REST API's stage-qualified route.\n// Rendered by Terraform (`templatefile`); `prod` is the\n// deployed stage name, never a hardcoded literal.\nfunction handler(event) {\n var request = event.request;\n var prefix = '/api';\n if (request.uri === prefix) {\n request.uri = '/prod';\n } else if (request.uri.startsWith(prefix + '/')) {\n request.uri = '/prod' + request.uri.substring(prefix.length);\n }\n return request;\n}\n", "comment": "Rewrite /api/* onto the REST API's stage path", "key_value_store_associations": null, "name": "crm-agent-evalapi-path-rewrite", "publish": true, "runtime": "cloudfront-js-2.0", "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_sensitive": {"tags_all": {}}, "after_unknown": {"arn": true, "etag": true, "id": true, "live_stage_etag": true, "status": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.frontend_cdn", "name": "api_path_rewrite", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudfront_function"} {"address": "module.frontend_cdn.aws_cloudfront_function.spa_history_fallback", "change": {"actions": ["create"], "after": {"code": "// SPDX-License-Identifier: MIT\n// CloudFront viewer-request function for the default (S3) behaviour: serves\n// `/index.html` for any client-side route so a deep link or a refresh reaches\n// the SPA. The private origin bucket answers a missing key with 403, so a route\n// path would otherwise render CloudFront's error document. Attached to the\n// default behaviour only; `/api/*` and `/agent/*` responses are unaffected.\n//\n// A URI whose last path segment contains a `.` is treated as a file and left\n// unchanged. Any other URI is rewritten to `/index.html`; method, headers,\n// query string and body are untouched.\nfunction handler(event) {\n var request = event.request;\n var uri = request.uri;\n var lastSegment = uri.substring(uri.lastIndexOf('/') + 1);\n if (lastSegment.indexOf('.') === -1) {\n request.uri = '/index.html';\n }\n return request;\n}\n", "comment": "Serve /index.html for SPA client-side routes", "key_value_store_associations": null, "name": "crm-agent-evalspa-history-fallback", "publish": true, "runtime": "cloudfront-js-2.0", "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_sensitive": {"tags_all": {}}, "after_unknown": {"arn": true, "etag": true, "id": true, "live_stage_etag": true, "status": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.frontend_cdn", "name": "spa_history_fallback", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudfront_function"} {"address": "module.frontend_cdn.aws_cloudfront_origin_access_control.agent_relay", "change": {"actions": ["create"], "after": {"description": "SigV4-signs origin requests to the relay's AWS_IAM Function URL", "name": "crm-agent-evalagent-relay-oac", "origin_access_control_origin_type": "lambda", "signing_behavior": "always", "signing_protocol": "sigv4"}, "after_sensitive": {}, "after_unknown": {"arn": true, "etag": true, "id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.frontend_cdn", "name": "agent_relay", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudfront_origin_access_control"} {"address": "module.frontend_cdn.aws_cloudfront_origin_access_control.origin", "change": {"actions": ["create"], "after": {"description": "Managed by Terraform", "name": "crm-agent-evalfrontend-cdn-oac", "origin_access_control_origin_type": "s3", "signing_behavior": "always", "signing_protocol": "sigv4"}, "after_sensitive": {}, "after_unknown": {"arn": true, "etag": true, "id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.frontend_cdn", "name": "origin", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudfront_origin_access_control"} {"address": "module.frontend_cdn.aws_cloudfront_origin_request_policy.agent_relay", "change": {"actions": ["create"], "after": {"comment": "Forward every viewer header except Host to the relay origin", "cookies_config": [{"cookie_behavior": "all", "cookies": []}], "headers_config": [{"header_behavior": "allExcept", "headers": [{"items": ["host"]}]}], "name": "crm-agent-evalagent-relay-origin-request", "query_strings_config": [{"query_string_behavior": "all", "query_strings": []}]}, "after_sensitive": {"cookies_config": [{"cookies": []}], "headers_config": [{"headers": [{"items": [false]}]}], "query_strings_config": [{"query_strings": []}]}, "after_unknown": {"arn": true, "cookies_config": [{"cookies": []}], "etag": true, "headers_config": [{"headers": [{"items": [false]}]}], "id": true, "query_strings_config": [{"query_strings": []}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.frontend_cdn", "name": "agent_relay", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudfront_origin_request_policy"} +{"address": "module.frontend_cdn.aws_cloudfront_response_headers_policy.security_headers", "change": {"actions": ["create"], "after": {"comment": "Security headers and an enforced Content-Security-Policy for the CRM frontend", "cors_config": [], "custom_headers_config": [], "name": "crm-agent-evalfrontend-security-headers", "remove_headers_config": [], "security_headers_config": [{"content_security_policy": [{"override": true}], "content_type_options": [{"override": true}], "frame_options": [{"frame_option": "DENY", "override": true}], "referrer_policy": [{"override": true, "referrer_policy": "strict-origin-when-cross-origin"}], "strict_transport_security": [{"access_control_max_age_sec": 31536000, "include_subdomains": false, "override": true, "preload": false}], "xss_protection": [{"mode_block": true, "override": true, "protection": true, "report_uri": null}]}], "server_timing_headers_config": []}, "after_sensitive": {"cors_config": [], "custom_headers_config": [], "remove_headers_config": [], "security_headers_config": [{"content_security_policy": [{}], "content_type_options": [{}], "frame_options": [{}], "referrer_policy": [{}], "strict_transport_security": [{}], "xss_protection": [{}]}], "server_timing_headers_config": []}, "after_unknown": {"arn": true, "cors_config": [], "custom_headers_config": [], "etag": true, "id": true, "remove_headers_config": [], "security_headers_config": [{"content_security_policy": [{"content_security_policy": true}], "content_type_options": [{}], "frame_options": [{}], "referrer_policy": [{}], "strict_transport_security": [{}], "xss_protection": [{}]}], "server_timing_headers_config": []}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.frontend_cdn", "name": "security_headers", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudfront_response_headers_policy"} {"address": "module.frontend_cdn.aws_kms_alias.frontend", "change": {"actions": ["create"], "after": {"name": "alias/crm-agent-evalfrontend-cdn", "region": "us-east-1"}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {}, "after_unknown": {"arn": true, "id": true, "name_prefix": true, "target_key_arn": true, "target_key_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.frontend_cdn", "name": "frontend", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_kms_alias"} {"address": "module.frontend_cdn.aws_kms_key.frontend", "change": {"actions": ["create"], "after": {"bypass_policy_lockout_safety_check": false, "custom_key_store_id": null, "customer_master_key_spec": "SYMMETRIC_DEFAULT", "deletion_window_in_days": 30, "description": "CMK for CRM frontend CDN origin bucket encryption at rest", "enable_key_rotation": true, "is_enabled": true, "key_usage": "ENCRYPT_DECRYPT", "region": "us-east-1", "tags": {"data-classification": "confidential"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "timeouts": null, "xks_key_id": null}, "after_identity": {"account_id": null, "id": null, "region": null}, "after_sensitive": {"tags": {}, "tags_all": {}}, "after_unknown": {"arn": true, "id": true, "key_id": true, "multi_region": true, "policy": true, "rotation_period_in_days": true, "tags": {}, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.frontend_cdn", "name": "frontend", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_kms_key"} {"address": "module.frontend_cdn.aws_kms_key_policy.frontend", "change": {"actions": ["create"], "after": {"bypass_policy_lockout_safety_check": false, "region": "us-east-1"}, "after_sensitive": {}, "after_unknown": {"id": true, "key_id": true, "policy": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.frontend_cdn", "name": "frontend", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_kms_key_policy"} @@ -291,9 +296,9 @@ {"address": "module.frontend_cdn.aws_s3_bucket_server_side_encryption_configuration.origin", "change": {"actions": ["create"], "after": {"expected_bucket_owner": null, "region": "us-east-1", "rule": [{"apply_server_side_encryption_by_default": [{"sse_algorithm": "aws:kms"}], "bucket_key_enabled": true}]}, "after_identity": {"account_id": null, "bucket": null, "region": null}, "after_sensitive": {"rule": [{"apply_server_side_encryption_by_default": [{}], "blocked_encryption_types": []}]}, "after_unknown": {"bucket": true, "id": true, "rule": [{"apply_server_side_encryption_by_default": [{"kms_master_key_id": true}], "blocked_encryption_types": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.frontend_cdn", "name": "origin", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_s3_bucket_server_side_encryption_configuration"} {"address": "module.frontend_cdn.aws_s3_bucket_versioning.logs", "change": {"actions": ["create"], "after": {"expected_bucket_owner": null, "mfa": null, "region": "us-east-1", "versioning_configuration": [{"status": "Enabled"}]}, "after_identity": {"account_id": null, "bucket": null, "region": null}, "after_sensitive": {"versioning_configuration": [{}]}, "after_unknown": {"bucket": true, "id": true, "versioning_configuration": [{"mfa_delete": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.frontend_cdn", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_s3_bucket_versioning"} {"address": "module.frontend_cdn.aws_s3_bucket_versioning.origin", "change": {"actions": ["create"], "after": {"expected_bucket_owner": null, "mfa": null, "region": "us-east-1", "versioning_configuration": [{"status": "Enabled"}]}, "after_identity": {"account_id": null, "bucket": null, "region": null}, "after_sensitive": {"versioning_configuration": [{}]}, "after_unknown": {"bucket": true, "id": true, "versioning_configuration": [{"mfa_delete": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.frontend_cdn", "name": "origin", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_s3_bucket_versioning"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"approve_proposal\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbProposals0"}, {"actions": ["dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAccounts1"}, {"actions": ["dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbContacts2"}, {"actions": ["dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbOpportunities3"}, {"actions": ["dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbActivities4"}, {"actions": ["dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAuditrecords5"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedProposals0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:PutItem", "dynamodb:Query"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAccounts1"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:PutItem", "dynamodb:Query"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedContacts2"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:PutItem", "dynamodb:Query"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities3"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:PutItem", "dynamodb:Query"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedActivities4"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAuditrecords5"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"approve_proposal\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"approve_proposal\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbProposals0"}, {"actions": ["dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAccounts1"}, {"actions": ["dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbContacts2"}, {"actions": ["dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbOpportunities3"}, {"actions": ["dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbActivities4"}, {"actions": ["dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAuditrecords5"}, {"actions": ["dynamodb:Query"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbOpportunities6"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedProposals0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:PutItem", "dynamodb:Query"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAccounts1"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:PutItem", "dynamodb:Query"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedContacts2"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:PutItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities3"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:PutItem", "dynamodb:Query"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedActivities4"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAuditrecords5"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"approve_proposal\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"approve_proposal\"].data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"approve_proposal\"]", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"approve_proposal\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"approve_proposal\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"approve_proposal\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}, {"actions": ["ssm:GetParameter"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "sid": "ReadConfigParameters"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"approve_proposal\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"address": "module.lambda_action[\"approve_proposal\"].aws_cloudwatch_log_group.this", "change": {"actions": ["create"], "after": {"name": "/aws/lambda/crm-agent-eval-approve_proposal", "region": "us-east-1", "retention_in_days": 365, "skip_destroy": false, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags_all": {}}, "after_unknown": {"arn": true, "deletion_protection_enabled": true, "id": true, "kms_key_id": true, "log_group_class": true, "name_prefix": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"approve_proposal\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudwatch_log_group"} {"address": "module.lambda_action[\"approve_proposal\"].aws_iam_role.this", "change": {"actions": ["create"], "after": {"assume_role_policy": "{\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"}}],\"Version\":\"2012-10-17\"}", "description": null, "force_detach_policies": false, "max_session_duration": 3600, "name": "crm-agent-eval-approve_proposal-role", "path": "/", "permissions_boundary": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null}, "after_sensitive": {"inline_policy": [], "managed_policy_arns": [], "tags_all": {}}, "after_unknown": {"arn": true, "create_date": true, "id": true, "inline_policy": true, "managed_policy_arns": true, "name_prefix": true, "tags_all": {}, "unique_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"approve_proposal\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role"} {"address": "module.lambda_action[\"approve_proposal\"].aws_iam_role_policy.dynamodb[0]", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-approve_proposal-dynamodb"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"approve_proposal\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} @@ -301,11 +306,11 @@ {"address": "module.lambda_action[\"approve_proposal\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-approve_proposal-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"approve_proposal\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"approve_proposal\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-approve_proposal-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"approve_proposal\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"approve_proposal\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-approve_proposal-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"approve_proposal\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"approve_proposal\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/approve_proposal.zip", "function_name": "crm-agent-eval-approve_proposal", "handler": "crm.handlers.approve_proposal.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "3vTY77S5IeXHiWCVxr5hu9Cplgf7edu9VqcBarnx8uU=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"approve_proposal\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"approve_proposal\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/approve_proposal.zip", "function_name": "crm-agent-eval-approve_proposal", "handler": "crm.handlers.approve_proposal.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "K1M2jvlUTQEnDHU9gvR3phHVm+wG6Dzn0HmT+7VoewE=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"approve_proposal\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"approve_proposal\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-approve_proposal", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"approve_proposal\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"create_account\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem", "dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAccounts0"}, {"actions": ["dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAuditrecords1"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAccounts0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAuditrecords1"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"create_account\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"create_account\"].data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"create_account\"]", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"create_account\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"create_account\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"create_account\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}, {"actions": ["ssm:GetParameter"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "sid": "ReadConfigParameters"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"create_account\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"address": "module.lambda_action[\"create_account\"].aws_cloudwatch_log_group.this", "change": {"actions": ["create"], "after": {"name": "/aws/lambda/crm-agent-eval-create_account", "region": "us-east-1", "retention_in_days": 365, "skip_destroy": false, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags_all": {}}, "after_unknown": {"arn": true, "deletion_protection_enabled": true, "id": true, "kms_key_id": true, "log_group_class": true, "name_prefix": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_account\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudwatch_log_group"} {"address": "module.lambda_action[\"create_account\"].aws_iam_role.this", "change": {"actions": ["create"], "after": {"assume_role_policy": "{\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"}}],\"Version\":\"2012-10-17\"}", "description": null, "force_detach_policies": false, "max_session_duration": 3600, "name": "crm-agent-eval-create_account-role", "path": "/", "permissions_boundary": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null}, "after_sensitive": {"inline_policy": [], "managed_policy_arns": [], "tags_all": {}}, "after_unknown": {"arn": true, "create_date": true, "id": true, "inline_policy": true, "managed_policy_arns": true, "name_prefix": true, "tags_all": {}, "unique_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_account\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role"} {"address": "module.lambda_action[\"create_account\"].aws_iam_role_policy.dynamodb[0]", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-create_account-dynamodb"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"create_account\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} @@ -313,11 +318,11 @@ {"address": "module.lambda_action[\"create_account\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-create_account-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_account\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"create_account\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-create_account-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_account\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"create_account\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-create_account-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_account\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"create_account\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/create_account.zip", "function_name": "crm-agent-eval-create_account", "handler": "crm.handlers.create_account.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "LMbon+VbW50EMwuJTkxD4djZRAwe7gF6qSn8TmoApnU=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_account\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"create_account\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/create_account.zip", "function_name": "crm-agent-eval-create_account", "handler": "crm.handlers.create_account.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "CYLNI2dIs5Yi2DjFVVJyKxjAAjAN6y1SkWBixP8bALY=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_account\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"create_account\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-create_account", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"create_account\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"create_contact\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem", "dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbContacts0"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAccounts1"}, {"actions": ["dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAuditrecords2"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedContacts0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAccounts1"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAuditrecords2"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"create_contact\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"create_contact\"].data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"create_contact\"]", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"create_contact\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"create_contact\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"create_contact\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}, {"actions": ["ssm:GetParameter"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "sid": "ReadConfigParameters"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"create_contact\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"address": "module.lambda_action[\"create_contact\"].aws_cloudwatch_log_group.this", "change": {"actions": ["create"], "after": {"name": "/aws/lambda/crm-agent-eval-create_contact", "region": "us-east-1", "retention_in_days": 365, "skip_destroy": false, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags_all": {}}, "after_unknown": {"arn": true, "deletion_protection_enabled": true, "id": true, "kms_key_id": true, "log_group_class": true, "name_prefix": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_contact\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudwatch_log_group"} {"address": "module.lambda_action[\"create_contact\"].aws_iam_role.this", "change": {"actions": ["create"], "after": {"assume_role_policy": "{\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"}}],\"Version\":\"2012-10-17\"}", "description": null, "force_detach_policies": false, "max_session_duration": 3600, "name": "crm-agent-eval-create_contact-role", "path": "/", "permissions_boundary": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null}, "after_sensitive": {"inline_policy": [], "managed_policy_arns": [], "tags_all": {}}, "after_unknown": {"arn": true, "create_date": true, "id": true, "inline_policy": true, "managed_policy_arns": true, "name_prefix": true, "tags_all": {}, "unique_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_contact\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role"} {"address": "module.lambda_action[\"create_contact\"].aws_iam_role_policy.dynamodb[0]", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-create_contact-dynamodb"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"create_contact\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} @@ -325,11 +330,11 @@ {"address": "module.lambda_action[\"create_contact\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-create_contact-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_contact\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"create_contact\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-create_contact-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_contact\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"create_contact\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-create_contact-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_contact\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"create_contact\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/create_contact.zip", "function_name": "crm-agent-eval-create_contact", "handler": "crm.handlers.create_contact.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "LMbon+VbW50EMwuJTkxD4djZRAwe7gF6qSn8TmoApnU=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_contact\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"create_contact\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/create_contact.zip", "function_name": "crm-agent-eval-create_contact", "handler": "crm.handlers.create_contact.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "zZQlPbCi9YrmhAv0Eo4zQdNtKxVDLrJGF+3j00JUYYY=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_contact\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"create_contact\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-create_contact", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"create_contact\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"create_note\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem", "dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbNotes0"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbOpportunities1"}, {"actions": ["dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAuditrecords2"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedNotes0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities1"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAuditrecords2"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"create_note\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"create_note\"].data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"create_note\"]", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"create_note\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"create_note\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"create_note\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}, {"actions": ["ssm:GetParameter"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "sid": "ReadConfigParameters"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"create_note\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"address": "module.lambda_action[\"create_note\"].aws_cloudwatch_log_group.this", "change": {"actions": ["create"], "after": {"name": "/aws/lambda/crm-agent-eval-create_note", "region": "us-east-1", "retention_in_days": 365, "skip_destroy": false, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags_all": {}}, "after_unknown": {"arn": true, "deletion_protection_enabled": true, "id": true, "kms_key_id": true, "log_group_class": true, "name_prefix": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_note\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudwatch_log_group"} {"address": "module.lambda_action[\"create_note\"].aws_iam_role.this", "change": {"actions": ["create"], "after": {"assume_role_policy": "{\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"}}],\"Version\":\"2012-10-17\"}", "description": null, "force_detach_policies": false, "max_session_duration": 3600, "name": "crm-agent-eval-create_note-role", "path": "/", "permissions_boundary": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null}, "after_sensitive": {"inline_policy": [], "managed_policy_arns": [], "tags_all": {}}, "after_unknown": {"arn": true, "create_date": true, "id": true, "inline_policy": true, "managed_policy_arns": true, "name_prefix": true, "tags_all": {}, "unique_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_note\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role"} {"address": "module.lambda_action[\"create_note\"].aws_iam_role_policy.dynamodb[0]", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-create_note-dynamodb"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"create_note\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} @@ -337,11 +342,11 @@ {"address": "module.lambda_action[\"create_note\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-create_note-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_note\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"create_note\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-create_note-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_note\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"create_note\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-create_note-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_note\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"create_note\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/create_note.zip", "function_name": "crm-agent-eval-create_note", "handler": "crm.handlers.create_note.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "qMhfdQAaAPrMxOGfTVlWCOeCCAryVJ4Cl2/ekmfhuOI=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_note\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"create_note\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/create_note.zip", "function_name": "crm-agent-eval-create_note", "handler": "crm.handlers.create_note.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "K1M2jvlUTQEnDHU9gvR3phHVm+wG6Dzn0HmT+7VoewE=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_note\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"create_note\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-create_note", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"create_note\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"create_opportunity\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem", "dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbOpportunities0"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAccounts1"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbContacts2"}, {"actions": ["dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAuditrecords3"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAccounts1"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedContacts2"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAuditrecords3"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"create_opportunity\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"create_opportunity\"].data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"create_opportunity\"]", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"create_opportunity\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"create_opportunity\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"create_opportunity\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}, {"actions": ["ssm:GetParameter"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "sid": "ReadConfigParameters"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"create_opportunity\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"address": "module.lambda_action[\"create_opportunity\"].aws_cloudwatch_log_group.this", "change": {"actions": ["create"], "after": {"name": "/aws/lambda/crm-agent-eval-create_opportunity", "region": "us-east-1", "retention_in_days": 365, "skip_destroy": false, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags_all": {}}, "after_unknown": {"arn": true, "deletion_protection_enabled": true, "id": true, "kms_key_id": true, "log_group_class": true, "name_prefix": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_opportunity\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudwatch_log_group"} {"address": "module.lambda_action[\"create_opportunity\"].aws_iam_role.this", "change": {"actions": ["create"], "after": {"assume_role_policy": "{\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"}}],\"Version\":\"2012-10-17\"}", "description": null, "force_detach_policies": false, "max_session_duration": 3600, "name": "crm-agent-eval-create_opportunity-role", "path": "/", "permissions_boundary": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null}, "after_sensitive": {"inline_policy": [], "managed_policy_arns": [], "tags_all": {}}, "after_unknown": {"arn": true, "create_date": true, "id": true, "inline_policy": true, "managed_policy_arns": true, "name_prefix": true, "tags_all": {}, "unique_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_opportunity\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role"} {"address": "module.lambda_action[\"create_opportunity\"].aws_iam_role_policy.dynamodb[0]", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-create_opportunity-dynamodb"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"create_opportunity\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} @@ -349,11 +354,11 @@ {"address": "module.lambda_action[\"create_opportunity\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-create_opportunity-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_opportunity\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"create_opportunity\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-create_opportunity-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_opportunity\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"create_opportunity\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-create_opportunity-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_opportunity\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"create_opportunity\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/create_opportunity.zip", "function_name": "crm-agent-eval-create_opportunity", "handler": "crm.handlers.create_opportunity.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "d5+vuAVpWyuYDMSUMNXBonwveuOjkKZCioNdErZb0sU=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_opportunity\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"create_opportunity\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/create_opportunity.zip", "function_name": "crm-agent-eval-create_opportunity", "handler": "crm.handlers.create_opportunity.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "KrDRHg0hHzx/48lwU6W8RYoVyb0zxwsyHoFdHENSq9o=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_opportunity\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"create_opportunity\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-create_opportunity", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"create_opportunity\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"draft_message\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbContacts0"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbOpportunities1"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedContacts0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities1"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"draft_message\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"draft_message\"].data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"draft_message\"]", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"draft_message\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"draft_message\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"draft_message\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}, {"actions": ["ssm:GetParameter"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "sid": "ReadConfigParameters"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"draft_message\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"address": "module.lambda_action[\"draft_message\"].aws_cloudwatch_log_group.this", "change": {"actions": ["create"], "after": {"name": "/aws/lambda/crm-agent-eval-draft_message", "region": "us-east-1", "retention_in_days": 365, "skip_destroy": false, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags_all": {}}, "after_unknown": {"arn": true, "deletion_protection_enabled": true, "id": true, "kms_key_id": true, "log_group_class": true, "name_prefix": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"draft_message\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudwatch_log_group"} {"address": "module.lambda_action[\"draft_message\"].aws_iam_role.this", "change": {"actions": ["create"], "after": {"assume_role_policy": "{\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"}}],\"Version\":\"2012-10-17\"}", "description": null, "force_detach_policies": false, "max_session_duration": 3600, "name": "crm-agent-eval-draft_message-role", "path": "/", "permissions_boundary": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null}, "after_sensitive": {"inline_policy": [], "managed_policy_arns": [], "tags_all": {}}, "after_unknown": {"arn": true, "create_date": true, "id": true, "inline_policy": true, "managed_policy_arns": true, "name_prefix": true, "tags_all": {}, "unique_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"draft_message\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role"} {"address": "module.lambda_action[\"draft_message\"].aws_iam_role_policy.dynamodb[0]", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-draft_message-dynamodb"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"draft_message\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} @@ -361,11 +366,11 @@ {"address": "module.lambda_action[\"draft_message\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-draft_message-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"draft_message\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"draft_message\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-draft_message-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"draft_message\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"draft_message\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-draft_message-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"draft_message\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"draft_message\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/draft_message.zip", "function_name": "crm-agent-eval-draft_message", "handler": "crm.handlers.draft_message.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "LMbon+VbW50EMwuJTkxD4djZRAwe7gF6qSn8TmoApnU=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"draft_message\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"draft_message\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/draft_message.zip", "function_name": "crm-agent-eval-draft_message", "handler": "crm.handlers.draft_message.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "CYLNI2dIs5Yi2DjFVVJyKxjAAjAN6y1SkWBixP8bALY=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"draft_message\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"draft_message\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-draft_message", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"draft_message\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"get_account\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAccounts0"}, {"actions": ["dynamodb:Query"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null], "sid": "DynamoDbContacts1"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAccounts0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedContacts1"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"get_account\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"get_account\"].data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"get_account\"]", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"get_account\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"get_account\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"get_account\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}, {"actions": ["ssm:GetParameter"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "sid": "ReadConfigParameters"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"get_account\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"address": "module.lambda_action[\"get_account\"].aws_cloudwatch_log_group.this", "change": {"actions": ["create"], "after": {"name": "/aws/lambda/crm-agent-eval-get_account", "region": "us-east-1", "retention_in_days": 365, "skip_destroy": false, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags_all": {}}, "after_unknown": {"arn": true, "deletion_protection_enabled": true, "id": true, "kms_key_id": true, "log_group_class": true, "name_prefix": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_account\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudwatch_log_group"} {"address": "module.lambda_action[\"get_account\"].aws_iam_role.this", "change": {"actions": ["create"], "after": {"assume_role_policy": "{\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"}}],\"Version\":\"2012-10-17\"}", "description": null, "force_detach_policies": false, "max_session_duration": 3600, "name": "crm-agent-eval-get_account-role", "path": "/", "permissions_boundary": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null}, "after_sensitive": {"inline_policy": [], "managed_policy_arns": [], "tags_all": {}}, "after_unknown": {"arn": true, "create_date": true, "id": true, "inline_policy": true, "managed_policy_arns": true, "name_prefix": true, "tags_all": {}, "unique_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_account\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role"} {"address": "module.lambda_action[\"get_account\"].aws_iam_role_policy.dynamodb[0]", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-get_account-dynamodb"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"get_account\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} @@ -373,11 +378,11 @@ {"address": "module.lambda_action[\"get_account\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-get_account-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_account\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"get_account\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-get_account-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_account\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"get_account\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-get_account-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_account\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"get_account\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/get_account.zip", "function_name": "crm-agent-eval-get_account", "handler": "crm.handlers.get_account.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "4K2MUHdXXZakOQXvky4xxPfFMWqNIFnSk4DXwEa0EJA=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_account\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"get_account\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/get_account.zip", "function_name": "crm-agent-eval-get_account", "handler": "crm.handlers.get_account.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "khqIhaLNmrH6ZxNNoHPAnykjEMkj/HlJfScNN6giICQ=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_account\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"get_account\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-get_account", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"get_account\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"get_audit_record\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAuditrecords0"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAuditrecords0"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"get_audit_record\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"get_audit_record\"].data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"get_audit_record\"]", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"get_audit_record\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"get_audit_record\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"get_audit_record\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}, {"actions": ["ssm:GetParameter"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "sid": "ReadConfigParameters"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"get_audit_record\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"address": "module.lambda_action[\"get_audit_record\"].aws_cloudwatch_log_group.this", "change": {"actions": ["create"], "after": {"name": "/aws/lambda/crm-agent-eval-get_audit_record", "region": "us-east-1", "retention_in_days": 365, "skip_destroy": false, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags_all": {}}, "after_unknown": {"arn": true, "deletion_protection_enabled": true, "id": true, "kms_key_id": true, "log_group_class": true, "name_prefix": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_audit_record\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudwatch_log_group"} {"address": "module.lambda_action[\"get_audit_record\"].aws_iam_role.this", "change": {"actions": ["create"], "after": {"assume_role_policy": "{\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"}}],\"Version\":\"2012-10-17\"}", "description": null, "force_detach_policies": false, "max_session_duration": 3600, "name": "crm-agent-eval-get_audit_record-role", "path": "/", "permissions_boundary": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null}, "after_sensitive": {"inline_policy": [], "managed_policy_arns": [], "tags_all": {}}, "after_unknown": {"arn": true, "create_date": true, "id": true, "inline_policy": true, "managed_policy_arns": true, "name_prefix": true, "tags_all": {}, "unique_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_audit_record\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role"} {"address": "module.lambda_action[\"get_audit_record\"].aws_iam_role_policy.dynamodb[0]", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-get_audit_record-dynamodb"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"get_audit_record\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} @@ -385,11 +390,11 @@ {"address": "module.lambda_action[\"get_audit_record\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-get_audit_record-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_audit_record\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"get_audit_record\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-get_audit_record-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_audit_record\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"get_audit_record\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-get_audit_record-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_audit_record\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"get_audit_record\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/get_audit_record.zip", "function_name": "crm-agent-eval-get_audit_record", "handler": "crm.handlers.get_audit_record.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "CE4JAIZxpuv6n9zLeFqy+b5HFDrmv3GxkUB9t5gVUz0=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_audit_record\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"get_audit_record\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/get_audit_record.zip", "function_name": "crm-agent-eval-get_audit_record", "handler": "crm.handlers.get_audit_record.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "CYLNI2dIs5Yi2DjFVVJyKxjAAjAN6y1SkWBixP8bALY=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_audit_record\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"get_audit_record\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-get_audit_record", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"get_audit_record\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"get_contact\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbContacts0"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedContacts0"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"get_contact\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"get_contact\"].data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"get_contact\"]", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"get_contact\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"get_contact\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"get_contact\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}, {"actions": ["ssm:GetParameter"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "sid": "ReadConfigParameters"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"get_contact\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"address": "module.lambda_action[\"get_contact\"].aws_cloudwatch_log_group.this", "change": {"actions": ["create"], "after": {"name": "/aws/lambda/crm-agent-eval-get_contact", "region": "us-east-1", "retention_in_days": 365, "skip_destroy": false, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags_all": {}}, "after_unknown": {"arn": true, "deletion_protection_enabled": true, "id": true, "kms_key_id": true, "log_group_class": true, "name_prefix": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_contact\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudwatch_log_group"} {"address": "module.lambda_action[\"get_contact\"].aws_iam_role.this", "change": {"actions": ["create"], "after": {"assume_role_policy": "{\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"}}],\"Version\":\"2012-10-17\"}", "description": null, "force_detach_policies": false, "max_session_duration": 3600, "name": "crm-agent-eval-get_contact-role", "path": "/", "permissions_boundary": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null}, "after_sensitive": {"inline_policy": [], "managed_policy_arns": [], "tags_all": {}}, "after_unknown": {"arn": true, "create_date": true, "id": true, "inline_policy": true, "managed_policy_arns": true, "name_prefix": true, "tags_all": {}, "unique_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_contact\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role"} {"address": "module.lambda_action[\"get_contact\"].aws_iam_role_policy.dynamodb[0]", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-get_contact-dynamodb"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"get_contact\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} @@ -397,11 +402,11 @@ {"address": "module.lambda_action[\"get_contact\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-get_contact-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_contact\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"get_contact\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-get_contact-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_contact\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"get_contact\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-get_contact-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_contact\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"get_contact\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/get_contact.zip", "function_name": "crm-agent-eval-get_contact", "handler": "crm.handlers.get_contact.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "4K2MUHdXXZakOQXvky4xxPfFMWqNIFnSk4DXwEa0EJA=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_contact\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"get_contact\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/get_contact.zip", "function_name": "crm-agent-eval-get_contact", "handler": "crm.handlers.get_contact.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "khqIhaLNmrH6ZxNNoHPAnykjEMkj/HlJfScNN6giICQ=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_contact\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"get_contact\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-get_contact", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"get_contact\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"get_opportunity\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbOpportunities0"}, {"actions": ["dynamodb:Query"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null], "sid": "DynamoDbActivities1"}, {"actions": ["dynamodb:Query"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null], "sid": "DynamoDbNotes2"}, {"actions": ["dynamodb:Query"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null], "sid": "DynamoDbContacts3"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedActivities1"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedNotes2"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedContacts3"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"get_opportunity\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"get_opportunity\"].data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"get_opportunity\"]", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"get_opportunity\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"get_opportunity\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"get_opportunity\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}, {"actions": ["ssm:GetParameter"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "sid": "ReadConfigParameters"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"get_opportunity\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"address": "module.lambda_action[\"get_opportunity\"].aws_cloudwatch_log_group.this", "change": {"actions": ["create"], "after": {"name": "/aws/lambda/crm-agent-eval-get_opportunity", "region": "us-east-1", "retention_in_days": 365, "skip_destroy": false, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags_all": {}}, "after_unknown": {"arn": true, "deletion_protection_enabled": true, "id": true, "kms_key_id": true, "log_group_class": true, "name_prefix": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_opportunity\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudwatch_log_group"} {"address": "module.lambda_action[\"get_opportunity\"].aws_iam_role.this", "change": {"actions": ["create"], "after": {"assume_role_policy": "{\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"}}],\"Version\":\"2012-10-17\"}", "description": null, "force_detach_policies": false, "max_session_duration": 3600, "name": "crm-agent-eval-get_opportunity-role", "path": "/", "permissions_boundary": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null}, "after_sensitive": {"inline_policy": [], "managed_policy_arns": [], "tags_all": {}}, "after_unknown": {"arn": true, "create_date": true, "id": true, "inline_policy": true, "managed_policy_arns": true, "name_prefix": true, "tags_all": {}, "unique_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_opportunity\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role"} {"address": "module.lambda_action[\"get_opportunity\"].aws_iam_role_policy.dynamodb[0]", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-get_opportunity-dynamodb"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"get_opportunity\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} @@ -409,7 +414,7 @@ {"address": "module.lambda_action[\"get_opportunity\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-get_opportunity-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_opportunity\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"get_opportunity\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-get_opportunity-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_opportunity\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"get_opportunity\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-get_opportunity-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_opportunity\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"get_opportunity\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/get_opportunity.zip", "function_name": "crm-agent-eval-get_opportunity", "handler": "crm.handlers.get_opportunity.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 40, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "4K2MUHdXXZakOQXvky4xxPfFMWqNIFnSk4DXwEa0EJA=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_opportunity\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"get_opportunity\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/get_opportunity.zip", "function_name": "crm-agent-eval-get_opportunity", "handler": "crm.handlers.get_opportunity.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 40, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "khqIhaLNmrH6ZxNNoHPAnykjEMkj/HlJfScNN6giICQ=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_opportunity\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"get_opportunity\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-get_opportunity", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"get_opportunity\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"get_page_context\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAccounts0"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbContacts1"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbOpportunities2"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbActivities3"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAccounts0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedContacts1"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities2"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedActivities3"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"get_page_context\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"get_page_context\"].data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"get_page_context\"]", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -421,11 +426,11 @@ {"address": "module.lambda_action[\"get_page_context\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-get_page_context-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_page_context\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"get_page_context\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-get_page_context-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_page_context\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"get_page_context\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-get_page_context-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_page_context\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"get_page_context\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/get_page_context.zip", "function_name": "crm-agent-eval-get_page_context", "handler": "crm.handlers.get_page_context.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "K22bl3Pigv89sbcdDIbxGRXvewvPhrBCfLE9NCzOTnA=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_page_context\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"get_page_context\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/get_page_context.zip", "function_name": "crm-agent-eval-get_page_context", "handler": "crm.handlers.get_page_context.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "qlKBdzbpAdPkNghjiYZLwPUzXsXqM/uRSWGVwxJxo+Y=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_page_context\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"get_page_context\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-get_page_context", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"get_page_context\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"list_activities\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbOpportunities0"}, {"actions": ["dynamodb:Query"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null], "sid": "DynamoDbActivities1"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedActivities1"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"list_activities\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"list_activities\"].data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"list_activities\"]", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"list_activities\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"list_activities\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"list_activities\"].data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}, {"actions": ["kms:Decrypt", "kms:Encrypt"], "condition": [{"test": "ForAllValues:StringEquals", "values": ["operation", "purpose", "rep_id", "tenant"], "variable": "kms:EncryptionContextKeys"}, {"test": "StringEquals", "values": ["crm-cursor"], "variable": "kms:EncryptionContext:purpose"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "SealPaginationCursors"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false], "condition": [{"values": [false, false, false, false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false], "condition": [{"values": [false, false, false, false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"list_activities\"]", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"list_activities\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}, {"actions": ["ssm:GetParameter"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "sid": "ReadConfigParameters"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"list_activities\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"address": "module.lambda_action[\"list_activities\"].aws_cloudwatch_log_group.this", "change": {"actions": ["create"], "after": {"name": "/aws/lambda/crm-agent-eval-list_activities", "region": "us-east-1", "retention_in_days": 365, "skip_destroy": false, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags_all": {}}, "after_unknown": {"arn": true, "deletion_protection_enabled": true, "id": true, "kms_key_id": true, "log_group_class": true, "name_prefix": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_activities\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudwatch_log_group"} {"address": "module.lambda_action[\"list_activities\"].aws_iam_role.this", "change": {"actions": ["create"], "after": {"assume_role_policy": "{\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"}}],\"Version\":\"2012-10-17\"}", "description": null, "force_detach_policies": false, "max_session_duration": 3600, "name": "crm-agent-eval-list_activities-role", "path": "/", "permissions_boundary": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null}, "after_sensitive": {"inline_policy": [], "managed_policy_arns": [], "tags_all": {}}, "after_unknown": {"arn": true, "create_date": true, "id": true, "inline_policy": true, "managed_policy_arns": true, "name_prefix": true, "tags_all": {}, "unique_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_activities\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role"} {"address": "module.lambda_action[\"list_activities\"].aws_iam_role_policy.dynamodb[0]", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-list_activities-dynamodb"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"list_activities\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} @@ -433,11 +438,11 @@ {"address": "module.lambda_action[\"list_activities\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-list_activities-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_activities\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"list_activities\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-list_activities-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_activities\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"list_activities\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-list_activities-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_activities\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"list_activities\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/list_activities.zip", "function_name": "crm-agent-eval-list_activities", "handler": "crm.handlers.list_activities.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "4K2MUHdXXZakOQXvky4xxPfFMWqNIFnSk4DXwEa0EJA=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_activities\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"list_activities\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/list_activities.zip", "function_name": "crm-agent-eval-list_activities", "handler": "crm.handlers.list_activities.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "m1U3sETyr5WeMb+jD6+beZFn8jVTzM1rErreZaO9S0E=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_activities\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"list_activities\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-list_activities", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"list_activities\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"list_audit_records\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:Query"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null], "sid": "DynamoDbAuditrecords0"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAuditrecords0"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"list_audit_records\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"list_audit_records\"].data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"list_audit_records\"]", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"list_audit_records\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"list_audit_records\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"list_audit_records\"].data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}, {"actions": ["kms:Decrypt", "kms:Encrypt"], "condition": [{"test": "ForAllValues:StringEquals", "values": ["operation", "purpose", "rep_id", "tenant"], "variable": "kms:EncryptionContextKeys"}, {"test": "StringEquals", "values": ["crm-cursor"], "variable": "kms:EncryptionContext:purpose"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "SealPaginationCursors"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false], "condition": [{"values": [false, false, false, false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false], "condition": [{"values": [false, false, false, false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"list_audit_records\"]", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"list_audit_records\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}, {"actions": ["ssm:GetParameter"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "sid": "ReadConfigParameters"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"list_audit_records\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"address": "module.lambda_action[\"list_audit_records\"].aws_cloudwatch_log_group.this", "change": {"actions": ["create"], "after": {"name": "/aws/lambda/crm-agent-eval-list_audit_records", "region": "us-east-1", "retention_in_days": 365, "skip_destroy": false, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags_all": {}}, "after_unknown": {"arn": true, "deletion_protection_enabled": true, "id": true, "kms_key_id": true, "log_group_class": true, "name_prefix": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_audit_records\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudwatch_log_group"} {"address": "module.lambda_action[\"list_audit_records\"].aws_iam_role.this", "change": {"actions": ["create"], "after": {"assume_role_policy": "{\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"}}],\"Version\":\"2012-10-17\"}", "description": null, "force_detach_policies": false, "max_session_duration": 3600, "name": "crm-agent-eval-list_audit_records-role", "path": "/", "permissions_boundary": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null}, "after_sensitive": {"inline_policy": [], "managed_policy_arns": [], "tags_all": {}}, "after_unknown": {"arn": true, "create_date": true, "id": true, "inline_policy": true, "managed_policy_arns": true, "name_prefix": true, "tags_all": {}, "unique_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_audit_records\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role"} {"address": "module.lambda_action[\"list_audit_records\"].aws_iam_role_policy.dynamodb[0]", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-list_audit_records-dynamodb"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"list_audit_records\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} @@ -445,11 +450,11 @@ {"address": "module.lambda_action[\"list_audit_records\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-list_audit_records-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_audit_records\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"list_audit_records\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-list_audit_records-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_audit_records\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"list_audit_records\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-list_audit_records-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_audit_records\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"list_audit_records\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/list_audit_records.zip", "function_name": "crm-agent-eval-list_audit_records", "handler": "crm.handlers.list_audit_records.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "CE4JAIZxpuv6n9zLeFqy+b5HFDrmv3GxkUB9t5gVUz0=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_audit_records\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"list_audit_records\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/list_audit_records.zip", "function_name": "crm-agent-eval-list_audit_records", "handler": "crm.handlers.list_audit_records.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "jFR7GWDE1+/370cV8KLqdg2/2ZZqv/pTDPKWbxW1DXc=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_audit_records\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"list_audit_records\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-list_audit_records", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"list_audit_records\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"list_proposals\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:BatchGetItem", "dynamodb:Query"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null], "sid": "DynamoDbProposals0"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedProposals0"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"list_proposals\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"list_proposals\"].data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"list_proposals\"]", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"list_proposals\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"list_proposals\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"list_proposals\"].data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}, {"actions": ["kms:Decrypt", "kms:Encrypt"], "condition": [{"test": "ForAllValues:StringEquals", "values": ["operation", "purpose", "rep_id", "tenant"], "variable": "kms:EncryptionContextKeys"}, {"test": "StringEquals", "values": ["crm-cursor"], "variable": "kms:EncryptionContext:purpose"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "SealPaginationCursors"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false], "condition": [{"values": [false, false, false, false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false], "condition": [{"values": [false, false, false, false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"list_proposals\"]", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"list_proposals\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}, {"actions": ["ssm:GetParameter"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "sid": "ReadConfigParameters"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"list_proposals\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"address": "module.lambda_action[\"list_proposals\"].aws_cloudwatch_log_group.this", "change": {"actions": ["create"], "after": {"name": "/aws/lambda/crm-agent-eval-list_proposals", "region": "us-east-1", "retention_in_days": 365, "skip_destroy": false, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags_all": {}}, "after_unknown": {"arn": true, "deletion_protection_enabled": true, "id": true, "kms_key_id": true, "log_group_class": true, "name_prefix": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_proposals\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudwatch_log_group"} {"address": "module.lambda_action[\"list_proposals\"].aws_iam_role.this", "change": {"actions": ["create"], "after": {"assume_role_policy": "{\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"}}],\"Version\":\"2012-10-17\"}", "description": null, "force_detach_policies": false, "max_session_duration": 3600, "name": "crm-agent-eval-list_proposals-role", "path": "/", "permissions_boundary": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null}, "after_sensitive": {"inline_policy": [], "managed_policy_arns": [], "tags_all": {}}, "after_unknown": {"arn": true, "create_date": true, "id": true, "inline_policy": true, "managed_policy_arns": true, "name_prefix": true, "tags_all": {}, "unique_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_proposals\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role"} {"address": "module.lambda_action[\"list_proposals\"].aws_iam_role_policy.dynamodb[0]", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-list_proposals-dynamodb"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"list_proposals\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} @@ -457,11 +462,11 @@ {"address": "module.lambda_action[\"list_proposals\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-list_proposals-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_proposals\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"list_proposals\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-list_proposals-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_proposals\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"list_proposals\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-list_proposals-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_proposals\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"list_proposals\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/list_proposals.zip", "function_name": "crm-agent-eval-list_proposals", "handler": "crm.handlers.list_proposals.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "CE4JAIZxpuv6n9zLeFqy+b5HFDrmv3GxkUB9t5gVUz0=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_proposals\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"list_proposals\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/list_proposals.zip", "function_name": "crm-agent-eval-list_proposals", "handler": "crm.handlers.list_proposals.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "m1U3sETyr5WeMb+jD6+beZFn8jVTzM1rErreZaO9S0E=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_proposals\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"list_proposals\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-list_proposals", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"list_proposals\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"log_activity\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbActivities0"}, {"actions": ["dynamodb:GetItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbOpportunities1"}, {"actions": ["dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAuditrecords2"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedActivities0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities1"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAuditrecords2"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"log_activity\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"log_activity\"].data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"log_activity\"]", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"log_activity\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"log_activity\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"log_activity\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}, {"actions": ["ssm:GetParameter"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "sid": "ReadConfigParameters"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"log_activity\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"address": "module.lambda_action[\"log_activity\"].aws_cloudwatch_log_group.this", "change": {"actions": ["create"], "after": {"name": "/aws/lambda/crm-agent-eval-log_activity", "region": "us-east-1", "retention_in_days": 365, "skip_destroy": false, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags_all": {}}, "after_unknown": {"arn": true, "deletion_protection_enabled": true, "id": true, "kms_key_id": true, "log_group_class": true, "name_prefix": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"log_activity\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudwatch_log_group"} {"address": "module.lambda_action[\"log_activity\"].aws_iam_role.this", "change": {"actions": ["create"], "after": {"assume_role_policy": "{\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"}}],\"Version\":\"2012-10-17\"}", "description": null, "force_detach_policies": false, "max_session_duration": 3600, "name": "crm-agent-eval-log_activity-role", "path": "/", "permissions_boundary": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null}, "after_sensitive": {"inline_policy": [], "managed_policy_arns": [], "tags_all": {}}, "after_unknown": {"arn": true, "create_date": true, "id": true, "inline_policy": true, "managed_policy_arns": true, "name_prefix": true, "tags_all": {}, "unique_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"log_activity\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role"} {"address": "module.lambda_action[\"log_activity\"].aws_iam_role_policy.dynamodb[0]", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-log_activity-dynamodb"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"log_activity\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} @@ -469,11 +474,11 @@ {"address": "module.lambda_action[\"log_activity\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-log_activity-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"log_activity\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"log_activity\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-log_activity-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"log_activity\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"log_activity\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-log_activity-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"log_activity\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"log_activity\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/log_activity.zip", "function_name": "crm-agent-eval-log_activity", "handler": "crm.handlers.log_activity.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "d5+vuAVpWyuYDMSUMNXBonwveuOjkKZCioNdErZb0sU=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"log_activity\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"log_activity\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/log_activity.zip", "function_name": "crm-agent-eval-log_activity", "handler": "crm.handlers.log_activity.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "KrDRHg0hHzx/48lwU6W8RYoVyb0zxwsyHoFdHENSq9o=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"log_activity\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"log_activity\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-log_activity", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"log_activity\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"pipeline_aggregate\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem", "dynamodb:Query"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null], "sid": "DynamoDbOpportunities0"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities0"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"pipeline_aggregate\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"pipeline_aggregate\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:BatchGetItem", "dynamodb:Query"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null], "sid": "DynamoDbOpportunities0"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities0"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"pipeline_aggregate\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"pipeline_aggregate\"].data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"pipeline_aggregate\"]", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"pipeline_aggregate\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"pipeline_aggregate\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"pipeline_aggregate\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}, {"actions": ["ssm:GetParameter"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "sid": "ReadConfigParameters"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"pipeline_aggregate\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"address": "module.lambda_action[\"pipeline_aggregate\"].aws_cloudwatch_log_group.this", "change": {"actions": ["create"], "after": {"name": "/aws/lambda/crm-agent-eval-pipeline_aggregate", "region": "us-east-1", "retention_in_days": 365, "skip_destroy": false, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags_all": {}}, "after_unknown": {"arn": true, "deletion_protection_enabled": true, "id": true, "kms_key_id": true, "log_group_class": true, "name_prefix": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"pipeline_aggregate\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudwatch_log_group"} {"address": "module.lambda_action[\"pipeline_aggregate\"].aws_iam_role.this", "change": {"actions": ["create"], "after": {"assume_role_policy": "{\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"}}],\"Version\":\"2012-10-17\"}", "description": null, "force_detach_policies": false, "max_session_duration": 3600, "name": "crm-agent-eval-pipeline_aggregate-role", "path": "/", "permissions_boundary": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null}, "after_sensitive": {"inline_policy": [], "managed_policy_arns": [], "tags_all": {}}, "after_unknown": {"arn": true, "create_date": true, "id": true, "inline_policy": true, "managed_policy_arns": true, "name_prefix": true, "tags_all": {}, "unique_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"pipeline_aggregate\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role"} {"address": "module.lambda_action[\"pipeline_aggregate\"].aws_iam_role_policy.dynamodb[0]", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-pipeline_aggregate-dynamodb"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"pipeline_aggregate\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} @@ -481,11 +486,11 @@ {"address": "module.lambda_action[\"pipeline_aggregate\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-pipeline_aggregate-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"pipeline_aggregate\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"pipeline_aggregate\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-pipeline_aggregate-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"pipeline_aggregate\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"pipeline_aggregate\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-pipeline_aggregate-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"pipeline_aggregate\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"pipeline_aggregate\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/pipeline_aggregate.zip", "function_name": "crm-agent-eval-pipeline_aggregate", "handler": "crm.handlers.pipeline_aggregate.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 40, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "CE4JAIZxpuv6n9zLeFqy+b5HFDrmv3GxkUB9t5gVUz0=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"pipeline_aggregate\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"pipeline_aggregate\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/pipeline_aggregate.zip", "function_name": "crm-agent-eval-pipeline_aggregate", "handler": "crm.handlers.pipeline_aggregate.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 40, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "m1U3sETyr5WeMb+jD6+beZFn8jVTzM1rErreZaO9S0E=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"pipeline_aggregate\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"pipeline_aggregate\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-pipeline_aggregate", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"pipeline_aggregate\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"rebase_proposal\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbProposals0"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAccounts1"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbContacts2"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbOpportunities3"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbActivities4"}, {"actions": ["dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAuditrecords5"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedProposals0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAccounts1"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedContacts2"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities3"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedActivities4"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAuditrecords5"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"rebase_proposal\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"rebase_proposal\"].data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"rebase_proposal\"]", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"rebase_proposal\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"rebase_proposal\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"rebase_proposal\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}, {"actions": ["ssm:GetParameter"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "sid": "ReadConfigParameters"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"rebase_proposal\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"address": "module.lambda_action[\"rebase_proposal\"].aws_cloudwatch_log_group.this", "change": {"actions": ["create"], "after": {"name": "/aws/lambda/crm-agent-eval-rebase_proposal", "region": "us-east-1", "retention_in_days": 365, "skip_destroy": false, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags_all": {}}, "after_unknown": {"arn": true, "deletion_protection_enabled": true, "id": true, "kms_key_id": true, "log_group_class": true, "name_prefix": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"rebase_proposal\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudwatch_log_group"} {"address": "module.lambda_action[\"rebase_proposal\"].aws_iam_role.this", "change": {"actions": ["create"], "after": {"assume_role_policy": "{\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"}}],\"Version\":\"2012-10-17\"}", "description": null, "force_detach_policies": false, "max_session_duration": 3600, "name": "crm-agent-eval-rebase_proposal-role", "path": "/", "permissions_boundary": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null}, "after_sensitive": {"inline_policy": [], "managed_policy_arns": [], "tags_all": {}}, "after_unknown": {"arn": true, "create_date": true, "id": true, "inline_policy": true, "managed_policy_arns": true, "name_prefix": true, "tags_all": {}, "unique_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"rebase_proposal\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role"} {"address": "module.lambda_action[\"rebase_proposal\"].aws_iam_role_policy.dynamodb[0]", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-rebase_proposal-dynamodb"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"rebase_proposal\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} @@ -493,11 +498,11 @@ {"address": "module.lambda_action[\"rebase_proposal\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-rebase_proposal-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"rebase_proposal\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"rebase_proposal\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-rebase_proposal-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"rebase_proposal\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"rebase_proposal\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-rebase_proposal-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"rebase_proposal\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"rebase_proposal\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/rebase_proposal.zip", "function_name": "crm-agent-eval-rebase_proposal", "handler": "crm.handlers.rebase_proposal.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "3vTY77S5IeXHiWCVxr5hu9Cplgf7edu9VqcBarnx8uU=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"rebase_proposal\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"rebase_proposal\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/rebase_proposal.zip", "function_name": "crm-agent-eval-rebase_proposal", "handler": "crm.handlers.rebase_proposal.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "qlKBdzbpAdPkNghjiYZLwPUzXsXqM/uRSWGVwxJxo+Y=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"rebase_proposal\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"rebase_proposal\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-rebase_proposal", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"rebase_proposal\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"reject_proposal\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbProposals0"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAccounts1"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbContacts2"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbOpportunities3"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbActivities4"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedProposals0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAccounts1"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedContacts2"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities3"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedActivities4"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"reject_proposal\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"reject_proposal\"].data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"reject_proposal\"]", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"reject_proposal\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"reject_proposal\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"reject_proposal\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}, {"actions": ["ssm:GetParameter"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "sid": "ReadConfigParameters"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"reject_proposal\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"address": "module.lambda_action[\"reject_proposal\"].aws_cloudwatch_log_group.this", "change": {"actions": ["create"], "after": {"name": "/aws/lambda/crm-agent-eval-reject_proposal", "region": "us-east-1", "retention_in_days": 365, "skip_destroy": false, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags_all": {}}, "after_unknown": {"arn": true, "deletion_protection_enabled": true, "id": true, "kms_key_id": true, "log_group_class": true, "name_prefix": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"reject_proposal\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudwatch_log_group"} {"address": "module.lambda_action[\"reject_proposal\"].aws_iam_role.this", "change": {"actions": ["create"], "after": {"assume_role_policy": "{\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"}}],\"Version\":\"2012-10-17\"}", "description": null, "force_detach_policies": false, "max_session_duration": 3600, "name": "crm-agent-eval-reject_proposal-role", "path": "/", "permissions_boundary": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null}, "after_sensitive": {"inline_policy": [], "managed_policy_arns": [], "tags_all": {}}, "after_unknown": {"arn": true, "create_date": true, "id": true, "inline_policy": true, "managed_policy_arns": true, "name_prefix": true, "tags_all": {}, "unique_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"reject_proposal\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role"} {"address": "module.lambda_action[\"reject_proposal\"].aws_iam_role_policy.dynamodb[0]", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-reject_proposal-dynamodb"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"reject_proposal\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} @@ -505,11 +510,11 @@ {"address": "module.lambda_action[\"reject_proposal\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-reject_proposal-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"reject_proposal\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"reject_proposal\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-reject_proposal-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"reject_proposal\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"reject_proposal\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-reject_proposal-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"reject_proposal\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"reject_proposal\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/reject_proposal.zip", "function_name": "crm-agent-eval-reject_proposal", "handler": "crm.handlers.reject_proposal.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "3vTY77S5IeXHiWCVxr5hu9Cplgf7edu9VqcBarnx8uU=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"reject_proposal\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"reject_proposal\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/reject_proposal.zip", "function_name": "crm-agent-eval-reject_proposal", "handler": "crm.handlers.reject_proposal.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "3lo1AmUbUyrqwK1liioUBc6AlTUyhu0aBcYw8iT1Bj8=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"reject_proposal\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"reject_proposal\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-reject_proposal", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"reject_proposal\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"revert_audit_record\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAuditrecords0"}, {"actions": ["dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAccounts1"}, {"actions": ["dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbContacts2"}, {"actions": ["dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbOpportunities3"}, {"actions": ["dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbActivities4"}, {"actions": ["dynamodb:Query"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbContacts5"}, {"actions": ["dynamodb:Query"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbOpportunities6"}, {"actions": ["dynamodb:Query"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "DynamoDbActivities7"}, {"actions": ["dynamodb:Query"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbNotes8"}, {"actions": ["dynamodb:DeleteItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbNotes9"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAuditrecords0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:Query"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAccounts1"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedContacts2"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities3"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedActivities4"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedNotes5"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"revert_audit_record\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"revert_audit_record\"].data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"revert_audit_record\"]", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"revert_audit_record\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"revert_audit_record\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"revert_audit_record\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}, {"actions": ["ssm:GetParameter"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "sid": "ReadConfigParameters"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"revert_audit_record\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"address": "module.lambda_action[\"revert_audit_record\"].aws_cloudwatch_log_group.this", "change": {"actions": ["create"], "after": {"name": "/aws/lambda/crm-agent-eval-revert_audit_record", "region": "us-east-1", "retention_in_days": 365, "skip_destroy": false, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags_all": {}}, "after_unknown": {"arn": true, "deletion_protection_enabled": true, "id": true, "kms_key_id": true, "log_group_class": true, "name_prefix": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"revert_audit_record\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudwatch_log_group"} {"address": "module.lambda_action[\"revert_audit_record\"].aws_iam_role.this", "change": {"actions": ["create"], "after": {"assume_role_policy": "{\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"}}],\"Version\":\"2012-10-17\"}", "description": null, "force_detach_policies": false, "max_session_duration": 3600, "name": "crm-agent-eval-revert_audit_record-role", "path": "/", "permissions_boundary": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null}, "after_sensitive": {"inline_policy": [], "managed_policy_arns": [], "tags_all": {}}, "after_unknown": {"arn": true, "create_date": true, "id": true, "inline_policy": true, "managed_policy_arns": true, "name_prefix": true, "tags_all": {}, "unique_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"revert_audit_record\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role"} {"address": "module.lambda_action[\"revert_audit_record\"].aws_iam_role_policy.dynamodb[0]", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-revert_audit_record-dynamodb"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"revert_audit_record\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} @@ -517,11 +522,11 @@ {"address": "module.lambda_action[\"revert_audit_record\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-revert_audit_record-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"revert_audit_record\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"revert_audit_record\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-revert_audit_record-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"revert_audit_record\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"revert_audit_record\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-revert_audit_record-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"revert_audit_record\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"revert_audit_record\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/revert_audit_record.zip", "function_name": "crm-agent-eval-revert_audit_record", "handler": "crm.handlers.revert_audit_record.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "7L4CwoWwBr3IKCfAyjj0/5BI6kr6ZjhUESQS/kUhFgE=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"revert_audit_record\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"revert_audit_record\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/revert_audit_record.zip", "function_name": "crm-agent-eval-revert_audit_record", "handler": "crm.handlers.revert_audit_record.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "qlKBdzbpAdPkNghjiYZLwPUzXsXqM/uRSWGVwxJxo+Y=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"revert_audit_record\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"revert_audit_record\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-revert_audit_record", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"revert_audit_record\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"search_accounts\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:Query"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null], "sid": "DynamoDbAccounts0"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAccounts0"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"search_accounts\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"search_accounts\"].data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"search_accounts\"]", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"search_accounts\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"search_accounts\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"search_accounts\"].data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}, {"actions": ["kms:Decrypt", "kms:Encrypt"], "condition": [{"test": "ForAllValues:StringEquals", "values": ["operation", "purpose", "rep_id", "tenant"], "variable": "kms:EncryptionContextKeys"}, {"test": "StringEquals", "values": ["crm-cursor"], "variable": "kms:EncryptionContext:purpose"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "SealPaginationCursors"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false], "condition": [{"values": [false, false, false, false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false], "condition": [{"values": [false, false, false, false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"search_accounts\"]", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"search_accounts\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}, {"actions": ["ssm:GetParameter"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "sid": "ReadConfigParameters"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"search_accounts\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"address": "module.lambda_action[\"search_accounts\"].aws_cloudwatch_log_group.this", "change": {"actions": ["create"], "after": {"name": "/aws/lambda/crm-agent-eval-search_accounts", "region": "us-east-1", "retention_in_days": 365, "skip_destroy": false, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags_all": {}}, "after_unknown": {"arn": true, "deletion_protection_enabled": true, "id": true, "kms_key_id": true, "log_group_class": true, "name_prefix": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"search_accounts\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudwatch_log_group"} {"address": "module.lambda_action[\"search_accounts\"].aws_iam_role.this", "change": {"actions": ["create"], "after": {"assume_role_policy": "{\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"}}],\"Version\":\"2012-10-17\"}", "description": null, "force_detach_policies": false, "max_session_duration": 3600, "name": "crm-agent-eval-search_accounts-role", "path": "/", "permissions_boundary": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null}, "after_sensitive": {"inline_policy": [], "managed_policy_arns": [], "tags_all": {}}, "after_unknown": {"arn": true, "create_date": true, "id": true, "inline_policy": true, "managed_policy_arns": true, "name_prefix": true, "tags_all": {}, "unique_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"search_accounts\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role"} {"address": "module.lambda_action[\"search_accounts\"].aws_iam_role_policy.dynamodb[0]", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-search_accounts-dynamodb"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"search_accounts\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} @@ -529,11 +534,11 @@ {"address": "module.lambda_action[\"search_accounts\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-search_accounts-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"search_accounts\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"search_accounts\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-search_accounts-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"search_accounts\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"search_accounts\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-search_accounts-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"search_accounts\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"search_accounts\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/search_accounts.zip", "function_name": "crm-agent-eval-search_accounts", "handler": "crm.handlers.search_accounts.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "IWzSloCXlCku8XdrlsyPien9+8Qy7YA0l9XKk397WVw=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"search_accounts\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"search_accounts\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/search_accounts.zip", "function_name": "crm-agent-eval-search_accounts", "handler": "crm.handlers.search_accounts.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "khqIhaLNmrH6ZxNNoHPAnykjEMkj/HlJfScNN6giICQ=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"search_accounts\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"search_accounts\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-search_accounts", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"search_accounts\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"search_opportunities\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:Query"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null], "sid": "DynamoDbOpportunities0"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities0"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"search_opportunities\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"search_opportunities\"].data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"search_opportunities\"]", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"search_opportunities\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"search_opportunities\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"search_opportunities\"].data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}, {"actions": ["kms:Decrypt", "kms:Encrypt"], "condition": [{"test": "ForAllValues:StringEquals", "values": ["operation", "purpose", "rep_id", "tenant"], "variable": "kms:EncryptionContextKeys"}, {"test": "StringEquals", "values": ["crm-cursor"], "variable": "kms:EncryptionContext:purpose"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "SealPaginationCursors"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false], "condition": [{"values": [false, false, false, false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false], "condition": [{"values": [false, false, false, false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"search_opportunities\"]", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"search_opportunities\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}, {"actions": ["ssm:GetParameter"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "sid": "ReadConfigParameters"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"search_opportunities\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"address": "module.lambda_action[\"search_opportunities\"].aws_cloudwatch_log_group.this", "change": {"actions": ["create"], "after": {"name": "/aws/lambda/crm-agent-eval-search_opportunities", "region": "us-east-1", "retention_in_days": 365, "skip_destroy": false, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags_all": {}}, "after_unknown": {"arn": true, "deletion_protection_enabled": true, "id": true, "kms_key_id": true, "log_group_class": true, "name_prefix": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"search_opportunities\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudwatch_log_group"} {"address": "module.lambda_action[\"search_opportunities\"].aws_iam_role.this", "change": {"actions": ["create"], "after": {"assume_role_policy": "{\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"}}],\"Version\":\"2012-10-17\"}", "description": null, "force_detach_policies": false, "max_session_duration": 3600, "name": "crm-agent-eval-search_opportunities-role", "path": "/", "permissions_boundary": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null}, "after_sensitive": {"inline_policy": [], "managed_policy_arns": [], "tags_all": {}}, "after_unknown": {"arn": true, "create_date": true, "id": true, "inline_policy": true, "managed_policy_arns": true, "name_prefix": true, "tags_all": {}, "unique_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"search_opportunities\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role"} {"address": "module.lambda_action[\"search_opportunities\"].aws_iam_role_policy.dynamodb[0]", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-search_opportunities-dynamodb"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"search_opportunities\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} @@ -541,11 +546,11 @@ {"address": "module.lambda_action[\"search_opportunities\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-search_opportunities-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"search_opportunities\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"search_opportunities\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-search_opportunities-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"search_opportunities\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"search_opportunities\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-search_opportunities-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"search_opportunities\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"search_opportunities\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/search_opportunities.zip", "function_name": "crm-agent-eval-search_opportunities", "handler": "crm.handlers.search_opportunities.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 40, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "IWzSloCXlCku8XdrlsyPien9+8Qy7YA0l9XKk397WVw=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"search_opportunities\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"search_opportunities\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/search_opportunities.zip", "function_name": "crm-agent-eval-search_opportunities", "handler": "crm.handlers.search_opportunities.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 40, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "NzpTxpiRO0VWVsuzM7Ls9DyRsVC/ocyZTCAnESYFJo0=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"search_opportunities\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"search_opportunities\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-search_opportunities", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"search_opportunities\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"submit_proposal\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem", "dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbProposals0"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAccounts1"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbContacts2"}, {"actions": ["dynamodb:GetItem", "dynamodb:Query"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null], "sid": "DynamoDbOpportunities3"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbActivities4"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedProposals0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAccounts1"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedContacts2"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities3"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedActivities4"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"submit_proposal\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"submit_proposal\"].data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"submit_proposal\"]", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"submit_proposal\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"submit_proposal\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"submit_proposal\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}, {"actions": ["ssm:GetParameter"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "sid": "ReadConfigParameters"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"submit_proposal\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"address": "module.lambda_action[\"submit_proposal\"].aws_cloudwatch_log_group.this", "change": {"actions": ["create"], "after": {"name": "/aws/lambda/crm-agent-eval-submit_proposal", "region": "us-east-1", "retention_in_days": 365, "skip_destroy": false, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags_all": {}}, "after_unknown": {"arn": true, "deletion_protection_enabled": true, "id": true, "kms_key_id": true, "log_group_class": true, "name_prefix": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"submit_proposal\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudwatch_log_group"} {"address": "module.lambda_action[\"submit_proposal\"].aws_iam_role.this", "change": {"actions": ["create"], "after": {"assume_role_policy": "{\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"}}],\"Version\":\"2012-10-17\"}", "description": null, "force_detach_policies": false, "max_session_duration": 3600, "name": "crm-agent-eval-submit_proposal-role", "path": "/", "permissions_boundary": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null}, "after_sensitive": {"inline_policy": [], "managed_policy_arns": [], "tags_all": {}}, "after_unknown": {"arn": true, "create_date": true, "id": true, "inline_policy": true, "managed_policy_arns": true, "name_prefix": true, "tags_all": {}, "unique_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"submit_proposal\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role"} {"address": "module.lambda_action[\"submit_proposal\"].aws_iam_role_policy.dynamodb[0]", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-submit_proposal-dynamodb"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"submit_proposal\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} @@ -553,11 +558,11 @@ {"address": "module.lambda_action[\"submit_proposal\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-submit_proposal-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"submit_proposal\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"submit_proposal\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-submit_proposal-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"submit_proposal\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"submit_proposal\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-submit_proposal-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"submit_proposal\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"submit_proposal\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/submit_proposal.zip", "function_name": "crm-agent-eval-submit_proposal", "handler": "crm.handlers.submit_proposal.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "3vTY77S5IeXHiWCVxr5hu9Cplgf7edu9VqcBarnx8uU=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"submit_proposal\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"submit_proposal\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/submit_proposal.zip", "function_name": "crm-agent-eval-submit_proposal", "handler": "crm.handlers.submit_proposal.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "K1M2jvlUTQEnDHU9gvR3phHVm+wG6Dzn0HmT+7VoewE=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"submit_proposal\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"submit_proposal\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-submit_proposal", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"submit_proposal\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"update_account\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAccounts0"}, {"actions": ["dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAuditrecords1"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:Query"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAccounts0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAuditrecords1"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"update_account\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"update_account\"].data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"update_account\"]", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"update_account\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"update_account\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"update_account\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}, {"actions": ["ssm:GetParameter"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "sid": "ReadConfigParameters"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"update_account\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"address": "module.lambda_action[\"update_account\"].aws_cloudwatch_log_group.this", "change": {"actions": ["create"], "after": {"name": "/aws/lambda/crm-agent-eval-update_account", "region": "us-east-1", "retention_in_days": 365, "skip_destroy": false, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags_all": {}}, "after_unknown": {"arn": true, "deletion_protection_enabled": true, "id": true, "kms_key_id": true, "log_group_class": true, "name_prefix": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_account\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudwatch_log_group"} {"address": "module.lambda_action[\"update_account\"].aws_iam_role.this", "change": {"actions": ["create"], "after": {"assume_role_policy": "{\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"}}],\"Version\":\"2012-10-17\"}", "description": null, "force_detach_policies": false, "max_session_duration": 3600, "name": "crm-agent-eval-update_account-role", "path": "/", "permissions_boundary": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null}, "after_sensitive": {"inline_policy": [], "managed_policy_arns": [], "tags_all": {}}, "after_unknown": {"arn": true, "create_date": true, "id": true, "inline_policy": true, "managed_policy_arns": true, "name_prefix": true, "tags_all": {}, "unique_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_account\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role"} {"address": "module.lambda_action[\"update_account\"].aws_iam_role_policy.dynamodb[0]", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-update_account-dynamodb"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"update_account\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} @@ -565,11 +570,11 @@ {"address": "module.lambda_action[\"update_account\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-update_account-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_account\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"update_account\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-update_account-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_account\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"update_account\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-update_account-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_account\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"update_account\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/update_account.zip", "function_name": "crm-agent-eval-update_account", "handler": "crm.handlers.update_account.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "LMbon+VbW50EMwuJTkxD4djZRAwe7gF6qSn8TmoApnU=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_account\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"update_account\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/update_account.zip", "function_name": "crm-agent-eval-update_account", "handler": "crm.handlers.update_account.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "zZQlPbCi9YrmhAv0Eo4zQdNtKxVDLrJGF+3j00JUYYY=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_account\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"update_account\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-update_account", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"update_account\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"update_activity\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbActivities0"}, {"actions": ["dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAuditrecords1"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:Query"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedActivities0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAuditrecords1"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"update_activity\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"update_activity\"].data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"update_activity\"]", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"update_activity\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"update_activity\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"update_activity\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}, {"actions": ["ssm:GetParameter"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "sid": "ReadConfigParameters"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"update_activity\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"address": "module.lambda_action[\"update_activity\"].aws_cloudwatch_log_group.this", "change": {"actions": ["create"], "after": {"name": "/aws/lambda/crm-agent-eval-update_activity", "region": "us-east-1", "retention_in_days": 365, "skip_destroy": false, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags_all": {}}, "after_unknown": {"arn": true, "deletion_protection_enabled": true, "id": true, "kms_key_id": true, "log_group_class": true, "name_prefix": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_activity\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudwatch_log_group"} {"address": "module.lambda_action[\"update_activity\"].aws_iam_role.this", "change": {"actions": ["create"], "after": {"assume_role_policy": "{\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"}}],\"Version\":\"2012-10-17\"}", "description": null, "force_detach_policies": false, "max_session_duration": 3600, "name": "crm-agent-eval-update_activity-role", "path": "/", "permissions_boundary": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null}, "after_sensitive": {"inline_policy": [], "managed_policy_arns": [], "tags_all": {}}, "after_unknown": {"arn": true, "create_date": true, "id": true, "inline_policy": true, "managed_policy_arns": true, "name_prefix": true, "tags_all": {}, "unique_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_activity\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role"} {"address": "module.lambda_action[\"update_activity\"].aws_iam_role_policy.dynamodb[0]", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-update_activity-dynamodb"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"update_activity\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} @@ -577,11 +582,11 @@ {"address": "module.lambda_action[\"update_activity\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-update_activity-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_activity\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"update_activity\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-update_activity-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_activity\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"update_activity\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-update_activity-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_activity\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"update_activity\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/update_activity.zip", "function_name": "crm-agent-eval-update_activity", "handler": "crm.handlers.update_activity.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "d5+vuAVpWyuYDMSUMNXBonwveuOjkKZCioNdErZb0sU=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_activity\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"update_activity\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/update_activity.zip", "function_name": "crm-agent-eval-update_activity", "handler": "crm.handlers.update_activity.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "KrDRHg0hHzx/48lwU6W8RYoVyb0zxwsyHoFdHENSq9o=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_activity\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"update_activity\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-update_activity", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"update_activity\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"update_contact\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbContacts0"}, {"actions": ["dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAuditrecords1"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:Query"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedContacts0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAuditrecords1"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"update_contact\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"update_contact\"].data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"update_contact\"]", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"update_contact\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"update_contact\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"update_contact\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}, {"actions": ["ssm:GetParameter"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "sid": "ReadConfigParameters"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"update_contact\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"address": "module.lambda_action[\"update_contact\"].aws_cloudwatch_log_group.this", "change": {"actions": ["create"], "after": {"name": "/aws/lambda/crm-agent-eval-update_contact", "region": "us-east-1", "retention_in_days": 365, "skip_destroy": false, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags_all": {}}, "after_unknown": {"arn": true, "deletion_protection_enabled": true, "id": true, "kms_key_id": true, "log_group_class": true, "name_prefix": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_contact\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudwatch_log_group"} {"address": "module.lambda_action[\"update_contact\"].aws_iam_role.this", "change": {"actions": ["create"], "after": {"assume_role_policy": "{\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"}}],\"Version\":\"2012-10-17\"}", "description": null, "force_detach_policies": false, "max_session_duration": 3600, "name": "crm-agent-eval-update_contact-role", "path": "/", "permissions_boundary": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null}, "after_sensitive": {"inline_policy": [], "managed_policy_arns": [], "tags_all": {}}, "after_unknown": {"arn": true, "create_date": true, "id": true, "inline_policy": true, "managed_policy_arns": true, "name_prefix": true, "tags_all": {}, "unique_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_contact\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role"} {"address": "module.lambda_action[\"update_contact\"].aws_iam_role_policy.dynamodb[0]", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-update_contact-dynamodb"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"update_contact\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} @@ -589,11 +594,11 @@ {"address": "module.lambda_action[\"update_contact\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-update_contact-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_contact\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"update_contact\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-update_contact-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_contact\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"update_contact\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-update_contact-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_contact\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"update_contact\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/update_contact.zip", "function_name": "crm-agent-eval-update_contact", "handler": "crm.handlers.update_contact.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "LMbon+VbW50EMwuJTkxD4djZRAwe7gF6qSn8TmoApnU=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_contact\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"update_contact\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/update_contact.zip", "function_name": "crm-agent-eval-update_contact", "handler": "crm.handlers.update_contact.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "zZQlPbCi9YrmhAv0Eo4zQdNtKxVDLrJGF+3j00JUYYY=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_contact\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"update_contact\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-update_contact", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"update_contact\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"update_opportunity\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbOpportunities0"}, {"actions": ["dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAuditrecords1"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:Query"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAuditrecords1"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"update_opportunity\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"update_opportunity\"].data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"update_opportunity\"]", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"update_opportunity\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"update_opportunity\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"update_opportunity\"].data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}, {"actions": ["ssm:GetParameter"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "sid": "ReadConfigParameters"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action[\"update_opportunity\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"address": "module.lambda_action[\"update_opportunity\"].aws_cloudwatch_log_group.this", "change": {"actions": ["create"], "after": {"name": "/aws/lambda/crm-agent-eval-update_opportunity", "region": "us-east-1", "retention_in_days": 365, "skip_destroy": false, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags_all": {}}, "after_unknown": {"arn": true, "deletion_protection_enabled": true, "id": true, "kms_key_id": true, "log_group_class": true, "name_prefix": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_opportunity\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudwatch_log_group"} {"address": "module.lambda_action[\"update_opportunity\"].aws_iam_role.this", "change": {"actions": ["create"], "after": {"assume_role_policy": "{\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"}}],\"Version\":\"2012-10-17\"}", "description": null, "force_detach_policies": false, "max_session_duration": 3600, "name": "crm-agent-eval-update_opportunity-role", "path": "/", "permissions_boundary": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null}, "after_sensitive": {"inline_policy": [], "managed_policy_arns": [], "tags_all": {}}, "after_unknown": {"arn": true, "create_date": true, "id": true, "inline_policy": true, "managed_policy_arns": true, "name_prefix": true, "tags_all": {}, "unique_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_opportunity\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role"} {"address": "module.lambda_action[\"update_opportunity\"].aws_iam_role_policy.dynamodb[0]", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-update_opportunity-dynamodb"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"update_opportunity\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} @@ -601,17 +606,17 @@ {"address": "module.lambda_action[\"update_opportunity\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-update_opportunity-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_opportunity\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"update_opportunity\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-update_opportunity-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_opportunity\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"update_opportunity\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-update_opportunity-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_opportunity\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"update_opportunity\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/update_opportunity.zip", "function_name": "crm-agent-eval-update_opportunity", "handler": "crm.handlers.update_opportunity.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "d5+vuAVpWyuYDMSUMNXBonwveuOjkKZCioNdErZb0sU=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_opportunity\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"update_opportunity\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/update_opportunity.zip", "function_name": "crm-agent-eval-update_opportunity", "handler": "crm.handlers.update_opportunity.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "KrDRHg0hHzx/48lwU6W8RYoVyb0zxwsyHoFdHENSq9o=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_opportunity\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"update_opportunity\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-update_opportunity", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"update_opportunity\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_capabilities.data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_capabilities", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action_capabilities.data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action_capabilities", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action_capabilities.data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}, {"actions": ["ssm:GetParameter"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "sid": "ReadConfigParameters"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action_capabilities", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"address": "module.lambda_action_capabilities.aws_cloudwatch_log_group.this", "change": {"actions": ["create"], "after": {"name": "/aws/lambda/crm-agent-eval-capabilities", "region": "us-east-1", "retention_in_days": 365, "skip_destroy": false, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags_all": {}}, "after_unknown": {"arn": true, "deletion_protection_enabled": true, "id": true, "kms_key_id": true, "log_group_class": true, "name_prefix": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_capabilities", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudwatch_log_group"} {"address": "module.lambda_action_capabilities.aws_iam_role.this", "change": {"actions": ["create"], "after": {"assume_role_policy": "{\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"}}],\"Version\":\"2012-10-17\"}", "description": null, "force_detach_policies": false, "max_session_duration": 3600, "name": "crm-agent-eval-capabilities-role", "path": "/", "permissions_boundary": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null}, "after_sensitive": {"inline_policy": [], "managed_policy_arns": [], "tags_all": {}}, "after_unknown": {"arn": true, "create_date": true, "id": true, "inline_policy": true, "managed_policy_arns": true, "name_prefix": true, "tags_all": {}, "unique_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_capabilities", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role"} {"address": "module.lambda_action_capabilities.aws_iam_role_policy.dynamodb[0]", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-capabilities-dynamodb"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action_capabilities", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action_capabilities.aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-capabilities-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_capabilities", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action_capabilities.aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-capabilities-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_capabilities", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action_capabilities.aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-capabilities-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_capabilities", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action_capabilities.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"PYTHONPATH": "/var/task/src"}}], "file_system_config": [], "filename": "build/lambda/eval_trigger.zip", "function_name": "crm-agent-eval-capabilities", "handler": "crm.handlers.capabilities.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 10, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "jVVrFK3a83mMLwTR5M3U3+MxIQIF9MjjaFoGULsm24Q=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 10, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_capabilities", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action_capabilities.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "PYTHONPATH": "/var/task/src"}}], "file_system_config": [], "filename": "build/lambda/eval_trigger.zip", "function_name": "crm-agent-eval-capabilities", "handler": "crm.handlers.capabilities.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 10, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "PGegeHLWKTtOu4utf1NEo5vv2ziBSrHBfLzfhrVF0G0=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 10, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_capabilities", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_chat_interceptor.data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem"], "condition": [{"test": "ForAllValues:StringEquals", "values": ["svc-mcp-gateway"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbReps0"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedReps0"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_chat_interceptor", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_chat_interceptor.data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_chat_interceptor", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_chat_interceptor.data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action_chat_interceptor", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -622,7 +627,7 @@ {"address": "module.lambda_action_chat_interceptor.aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-chat-identity-interceptor-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_chat_interceptor", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action_chat_interceptor.aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-chat-identity-interceptor-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_chat_interceptor", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action_chat_interceptor.aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-chat-identity-interceptor-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_chat_interceptor", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action_chat_interceptor.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/identity_interceptor.zip", "function_name": "crm-agent-eval-chat-identity-interceptor", "handler": "gateway.identity_interceptor.lambda_handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 5, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "jcdQK71T6l1SVPj6EaYAGqyGcnPl/qZN94e41O2AqgE=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 10, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_chat_interceptor", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action_chat_interceptor.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/identity_interceptor.zip", "function_name": "crm-agent-eval-chat-identity-interceptor", "handler": "gateway.identity_interceptor.lambda_handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 5, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "VhkBfRfQka2+KMOqjmirOQ0vjwiCXJzmXCAYC1vgPJk=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 10, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_chat_interceptor", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action_chat_interceptor.aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-chat-identity-interceptor", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action_chat_interceptor", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_chat_target.data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem"], "condition": [{"test": "ForAllValues:StringLike", "values": ["usersettings#*", "conversation#*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbReps0"}, {"actions": ["dynamodb:PutItem"], "condition": [{"test": "ForAllValues:StringLike", "values": ["conversation#*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbReps1"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedReps0"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_chat_target", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_chat_target.data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_chat_target", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -634,11 +639,11 @@ {"address": "module.lambda_action_chat_target.aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-chat-target-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_chat_target", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action_chat_target.aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-chat-target-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_chat_target", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action_chat_target.aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-chat-target-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_chat_target", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action_chat_target.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/chat_target.zip", "function_name": "crm-agent-eval-chat-target", "handler": "gateway.chat_target.lambda_handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 512, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 5, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "Jbzrfngj5zsbc3xcB9RQok/O37YJ5h8uXshF+MKlYG0=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 660, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_chat_target", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action_chat_target.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/chat_target.zip", "function_name": "crm-agent-eval-chat-target", "handler": "gateway.chat_target.lambda_handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 512, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 5, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "ziGvbapEm1K7SXTkofVnJXvFs8mMrBhTeSNVYV/DtsQ=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 660, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_chat_target", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action_chat_target.aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-chat-target", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action_chat_target", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_eval_trigger.data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:BatchGetItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [{"test": "ForAllValues:StringLike", "values": ["job#*", "lock#sweep", "livequota#*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbEvalruns0"}, {"actions": ["dynamodb:DeleteItem"], "condition": [{"test": "ForAllValues:StringEquals", "values": ["lock#sweep"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbEvalruns1"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringEquals", "values": ["job"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbEvalruns2"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchWriteItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedEvalruns0"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false, false], "condition": [{"values": [false, false, false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false, false], "condition": [{"values": [false, false, false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_eval_trigger", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_eval_trigger.data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_eval_trigger", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action_eval_trigger.data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action_eval_trigger", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action_eval_trigger.data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}, {"actions": ["ssm:GetParameter"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "sid": "ReadConfigParameters"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action_eval_trigger", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"address": "module.lambda_action_eval_trigger.aws_cloudwatch_log_group.this", "change": {"actions": ["create"], "after": {"name": "/aws/lambda/crm-agent-eval-eval-trigger", "region": "us-east-1", "retention_in_days": 365, "skip_destroy": false, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags_all": {}}, "after_unknown": {"arn": true, "deletion_protection_enabled": true, "id": true, "kms_key_id": true, "log_group_class": true, "name_prefix": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_eval_trigger", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudwatch_log_group"} {"address": "module.lambda_action_eval_trigger.aws_iam_role.this", "change": {"actions": ["create"], "after": {"assume_role_policy": "{\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"}}],\"Version\":\"2012-10-17\"}", "description": null, "force_detach_policies": false, "max_session_duration": 3600, "name": "crm-agent-eval-eval-trigger-role", "path": "/", "permissions_boundary": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null}, "after_sensitive": {"inline_policy": [], "managed_policy_arns": [], "tags_all": {}}, "after_unknown": {"arn": true, "create_date": true, "id": true, "inline_policy": true, "managed_policy_arns": true, "name_prefix": true, "tags_all": {}, "unique_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_eval_trigger", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role"} {"address": "module.lambda_action_eval_trigger.aws_iam_role_policy.dynamodb[0]", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-eval-trigger-dynamodb"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action_eval_trigger", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} @@ -646,7 +651,7 @@ {"address": "module.lambda_action_eval_trigger.aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-eval-trigger-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_eval_trigger", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action_eval_trigger.aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-eval-trigger-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_eval_trigger", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action_eval_trigger.aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-eval-trigger-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_eval_trigger", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action_eval_trigger.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/eval_trigger.zip", "function_name": "crm-agent-eval-eval-trigger", "handler": "crm.handlers.eval_trigger.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 512, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 5, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "jVVrFK3a83mMLwTR5M3U3+MxIQIF9MjjaFoGULsm24Q=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_eval_trigger", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action_eval_trigger.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/eval_trigger.zip", "function_name": "crm-agent-eval-eval-trigger", "handler": "crm.handlers.eval_trigger.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 512, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 5, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "PGegeHLWKTtOu4utf1NEo5vv2ziBSrHBfLzfhrVF0G0=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_eval_trigger", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_interceptor.data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem"], "condition": [{"test": "ForAllValues:StringEquals", "values": ["svc-mcp-gateway"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbReps0"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedReps0"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_interceptor", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_interceptor.data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_interceptor", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_interceptor.data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action_interceptor", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -657,7 +662,7 @@ {"address": "module.lambda_action_interceptor.aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-identity-interceptor-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_interceptor", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action_interceptor.aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-identity-interceptor-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_interceptor", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action_interceptor.aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-identity-interceptor-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_interceptor", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action_interceptor.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/identity_interceptor.zip", "function_name": "crm-agent-eval-identity-interceptor", "handler": "gateway.identity_interceptor.lambda_handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "jcdQK71T6l1SVPj6EaYAGqyGcnPl/qZN94e41O2AqgE=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 10, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_interceptor", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action_interceptor.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/identity_interceptor.zip", "function_name": "crm-agent-eval-identity-interceptor", "handler": "gateway.identity_interceptor.lambda_handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "VhkBfRfQka2+KMOqjmirOQ0vjwiCXJzmXCAYC1vgPJk=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 10, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_interceptor", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action_interceptor.aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-identity-interceptor", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action_interceptor", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_pre_token_generation.data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbReps0"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedReps0"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_pre_token_generation", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_pre_token_generation.data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_pre_token_generation", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -669,7 +674,7 @@ {"address": "module.lambda_action_pre_token_generation.aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-pre-token-generation-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_pre_token_generation", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action_pre_token_generation.aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-pre-token-generation-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_pre_token_generation", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action_pre_token_generation.aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-pre-token-generation-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_pre_token_generation", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action_pre_token_generation.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CHAT_SCOPE": "supervisor/chat", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/pre_token_generation.zip", "function_name": "crm-agent-eval-pre-token-generation", "handler": "crm.auth.pre_token_generation.lambda_handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 128, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "bMoKjfNPng7WnBJo+L9o4fmJdYjlY79NmP92cimNEx4=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 10, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_pre_token_generation", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action_pre_token_generation.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CHAT_SCOPE": "supervisor/chat", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/pre_token_generation.zip", "function_name": "crm-agent-eval-pre-token-generation", "handler": "crm.auth.pre_token_generation.lambda_handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 128, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "qknz1GMFa11BdhU38tBZar12WShvs17NXsie3tV9ILs=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 10, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_pre_token_generation", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action_pre_token_generation.aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-pre-token-generation", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action_pre_token_generation", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_sweep_control.data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem", "dynamodb:UpdateItem"], "condition": [{"test": "ForAllValues:StringLike", "values": ["job#*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbEvalruns0"}, {"actions": ["dynamodb:GetItem", "dynamodb:PutItem"], "condition": [{"test": "ForAllValues:StringLike", "values": ["????????????????????????????????"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbEvalruns1"}, {"actions": ["dynamodb:BatchWriteItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbProposals10"}, {"actions": ["dynamodb:BatchWriteItem"], "condition": [{"test": "ForAllValues:StringLike", "values": ["eval-*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbReps11"}, {"actions": ["dynamodb:BatchWriteItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbUsagerecords12"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringLike", "values": ["eval-*", "canary"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbAccounts13"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringLike", "values": ["eval-*", "canary"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbContacts14"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringLike", "values": ["eval-*", "canary"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbOpportunities15"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringLike", "values": ["eval-*", "canary"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbActivities16"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringLike", "values": ["eval-*", "canary"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbNotes17"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringLike", "values": ["eval-*", "canary"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbAuditrecords18"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringLike", "values": ["eval-*", "canary"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbProposals19"}, {"actions": ["dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:UpdateItem"], "condition": [{"test": "ForAllValues:StringEquals", "values": ["lock#sweep"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbEvalruns2"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringLike", "values": ["eval-*", "canary"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbReps20"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringLike", "values": ["eval-*", "canary"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbUsagerecords21"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringEquals", "values": ["demo"], "variable": "dynamodb:LeadingKeys"}, {"test": "StringEquals", "values": ["COUNT"], "variable": "dynamodb:Select"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbAccounts22"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringEquals", "values": ["demo"], "variable": "dynamodb:LeadingKeys"}, {"test": "StringEquals", "values": ["COUNT"], "variable": "dynamodb:Select"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbContacts23"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringEquals", "values": ["demo"], "variable": "dynamodb:LeadingKeys"}, {"test": "StringEquals", "values": ["COUNT"], "variable": "dynamodb:Select"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbOpportunities24"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringEquals", "values": ["demo"], "variable": "dynamodb:LeadingKeys"}, {"test": "StringEquals", "values": ["COUNT"], "variable": "dynamodb:Select"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbActivities25"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringEquals", "values": ["demo"], "variable": "dynamodb:LeadingKeys"}, {"test": "StringEquals", "values": ["COUNT"], "variable": "dynamodb:Select"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbNotes26"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringEquals", "values": ["demo"], "variable": "dynamodb:LeadingKeys"}, {"test": "StringEquals", "values": ["COUNT"], "variable": "dynamodb:Select"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbAuditrecords27"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringEquals", "values": ["demo"], "variable": "dynamodb:LeadingKeys"}, {"test": "StringEquals", "values": ["COUNT"], "variable": "dynamodb:Select"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbProposals28"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringEquals", "values": ["demo"], "variable": "dynamodb:LeadingKeys"}, {"test": "StringEquals", "values": ["COUNT"], "variable": "dynamodb:Select"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbReps29"}, {"actions": ["dynamodb:GetItem", "dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbEvalresults3"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringEquals", "values": ["demo"], "variable": "dynamodb:LeadingKeys"}, {"test": "StringEquals", "values": ["COUNT"], "variable": "dynamodb:Select"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbUsagerecords30"}, {"actions": ["dynamodb:BatchWriteItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAccounts4"}, {"actions": ["dynamodb:BatchWriteItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbContacts5"}, {"actions": ["dynamodb:BatchWriteItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbOpportunities6"}, {"actions": ["dynamodb:BatchWriteItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbActivities7"}, {"actions": ["dynamodb:BatchWriteItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbNotes8"}, {"actions": ["dynamodb:BatchWriteItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAuditrecords9"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:Query"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedEvalruns0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedEvalresults1"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedUsagerecords10"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAccounts2"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedContacts3"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities4"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedActivities5"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedNotes6"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAuditrecords7"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedProposals8"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedReps9"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false, false, false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false, false, false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_sweep_control", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_sweep_control.data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_sweep_control", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -686,7 +691,7 @@ {"address": "module.lambda_action_sweep_control.aws_iam_role_policy_attachment.dynamodb_allow[1]", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-sweep-control-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "index": 1, "mode": "managed", "module_address": "module.lambda_action_sweep_control", "name": "dynamodb_allow", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} {"address": "module.lambda_action_sweep_control.aws_iam_role_policy_attachment.dynamodb_deny[0]", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-sweep-control-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action_sweep_control", "name": "dynamodb_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} {"address": "module.lambda_action_sweep_control.aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-sweep-control-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_sweep_control", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action_sweep_control.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/eval_trigger.zip", "function_name": "crm-agent-eval-sweep-control", "handler": "eval.sfn_handlers.sweep_control_handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 1024, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 2, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "jVVrFK3a83mMLwTR5M3U3+MxIQIF9MjjaFoGULsm24Q=", "source_kms_key_arn": null, "tags": {"data-classification": "confidential"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 120, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags": {}, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags": {}, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_sweep_control", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action_sweep_control.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/eval_trigger.zip", "function_name": "crm-agent-eval-sweep-control", "handler": "eval.sfn_handlers.sweep_control_handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 1024, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 2, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "PGegeHLWKTtOu4utf1NEo5vv2ziBSrHBfLzfhrVF0G0=", "source_kms_key_arn": null, "tags": {"data-classification": "confidential"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 120, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags": {}, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags": {}, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_sweep_control", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_sweep_task.data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem", "dynamodb:UpdateItem"], "condition": [{"test": "ForAllValues:StringLike", "values": ["job#*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbEvalruns0"}, {"actions": ["dynamodb:GetItem", "dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbEvalresults1"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringLike", "values": ["eval-*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbOpportunities10"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringLike", "values": ["eval-*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbActivities11"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringLike", "values": ["eval-*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbNotes12"}, {"actions": ["dynamodb:GetItem"], "condition": [{"test": "ForAllValues:StringLike", "values": ["acct-eval-*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAccounts2"}, {"actions": ["dynamodb:GetItem"], "condition": [{"test": "ForAllValues:StringLike", "values": ["cont-eval-*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbContacts3"}, {"actions": ["dynamodb:GetItem"], "condition": [{"test": "ForAllValues:StringLike", "values": ["opp-eval-*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbOpportunities4"}, {"actions": ["dynamodb:GetItem"], "condition": [{"test": "ForAllValues:StringLike", "values": ["act-eval-*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbActivities5"}, {"actions": ["dynamodb:GetItem"], "condition": [{"test": "ForAllValues:StringLike", "values": ["note-eval-*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbNotes6"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbProposals7"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringLike", "values": ["eval-*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAccounts8"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringLike", "values": ["eval-*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbContacts9"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedEvalruns0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedEvalresults1"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAccounts2"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedContacts3"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities4"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedActivities5"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedNotes6"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedProposals7"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_sweep_task", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_sweep_task.data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_sweep_task", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_sweep_task.data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action_sweep_task", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -700,10 +705,10 @@ {"address": "module.lambda_action_sweep_task.aws_iam_role_policy_attachment.dynamodb_allow[0]", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-sweep-task-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action_sweep_task", "name": "dynamodb_allow", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} {"address": "module.lambda_action_sweep_task.aws_iam_role_policy_attachment.dynamodb_deny[0]", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-sweep-task-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action_sweep_task", "name": "dynamodb_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} {"address": "module.lambda_action_sweep_task.aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-sweep-task-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_sweep_task", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action_sweep_task.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/eval_trigger.zip", "function_name": "crm-agent-eval-sweep-task", "handler": "eval.sfn_handlers.sweep_task_handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 1024, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 1, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "jVVrFK3a83mMLwTR5M3U3+MxIQIF9MjjaFoGULsm24Q=", "source_kms_key_arn": null, "tags": {"data-classification": "confidential"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 300, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags": {}, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags": {}, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_sweep_task", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action_sweep_task.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/eval_trigger.zip", "function_name": "crm-agent-eval-sweep-task", "handler": "eval.sfn_handlers.sweep_task_handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 1024, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 1, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "PGegeHLWKTtOu4utf1NEo5vv2ziBSrHBfLzfhrVF0G0=", "source_kms_key_arn": null, "tags": {"data-classification": "confidential"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 300, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags": {}, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags": {}, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_sweep_task", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_user_settings.data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem"], "condition": [{"test": "ForAllValues:StringLike", "values": ["usersettings#*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbReps0"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedReps0"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_user_settings", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_user_settings.data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_user_settings", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"action_reason": "read_because_config_unknown", "address": "module.lambda_action_user_settings.data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action_user_settings", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "module.lambda_action_user_settings.data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}, {"actions": ["ssm:GetParameter"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "sid": "ReadConfigParameters"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action_user_settings", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"address": "module.lambda_action_user_settings.aws_cloudwatch_log_group.this", "change": {"actions": ["create"], "after": {"name": "/aws/lambda/crm-agent-eval-user-settings", "region": "us-east-1", "retention_in_days": 365, "skip_destroy": false, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags_all": {}}, "after_unknown": {"arn": true, "deletion_protection_enabled": true, "id": true, "kms_key_id": true, "log_group_class": true, "name_prefix": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_user_settings", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudwatch_log_group"} {"address": "module.lambda_action_user_settings.aws_iam_role.this", "change": {"actions": ["create"], "after": {"assume_role_policy": "{\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"}}],\"Version\":\"2012-10-17\"}", "description": null, "force_detach_policies": false, "max_session_duration": 3600, "name": "crm-agent-eval-user-settings-role", "path": "/", "permissions_boundary": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null}, "after_sensitive": {"inline_policy": [], "managed_policy_arns": [], "tags_all": {}}, "after_unknown": {"arn": true, "create_date": true, "id": true, "inline_policy": true, "managed_policy_arns": true, "name_prefix": true, "tags_all": {}, "unique_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_user_settings", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role"} {"address": "module.lambda_action_user_settings.aws_iam_role_policy.dynamodb[0]", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-user-settings-dynamodb"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action_user_settings", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} @@ -711,7 +716,7 @@ {"address": "module.lambda_action_user_settings.aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-user-settings-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_user_settings", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action_user_settings.aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-user-settings-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_user_settings", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action_user_settings.aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-user-settings-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_user_settings", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action_user_settings.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_TABLE_PREFIX": "crm-agent-eval", "PYTHONPATH": "/var/task/src"}}], "file_system_config": [], "filename": "build/lambda/eval_trigger.zip", "function_name": "crm-agent-eval-user-settings", "handler": "crm.handlers.user_settings.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 5, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "jVVrFK3a83mMLwTR5M3U3+MxIQIF9MjjaFoGULsm24Q=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 10, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_user_settings", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action_user_settings.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval", "PYTHONPATH": "/var/task/src"}}], "file_system_config": [], "filename": "build/lambda/eval_trigger.zip", "function_name": "crm-agent-eval-user-settings", "handler": "crm.handlers.user_settings.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 5, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "PGegeHLWKTtOu4utf1NEo5vv2ziBSrHBfLzfhrVF0G0=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 10, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_user_settings", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"action_reason": "read_because_config_unknown", "address": "module.mcp_chat_gateway.data.aws_iam_policy_document.gateway_permissions", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["lambda:InvokeFunction"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "InvokeChatTarget"}, {"actions": ["lambda:InvokeFunction"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "InvokeInterceptor"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.mcp_chat_gateway", "name": "gateway_permissions", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"address": "module.mcp_chat_gateway.aws_bedrockagentcore_gateway.this", "change": {"actions": ["create"], "after": {"authorizer_configuration": [{"custom_jwt_authorizer": [{"allowed_audience": null, "allowed_clients": [null, null, null], "allowed_scopes": [null], "allowed_workload_configuration": [], "custom_claim": [], "private_endpoint": [], "private_endpoint_overrides": []}]}], "authorizer_type": "CUSTOM_JWT", "description": null, "exception_level": null, "interceptor_configuration": [{"input_configuration": [{"pass_request_headers": true}], "interception_points": ["REQUEST"], "interceptor": [{"lambda": [{}]}]}], "kms_key_arn": null, "name": "crm-agent-eval-chat-gateway", "policy_engine_configuration": [], "protocol_configuration": [{"mcp": [{"instructions": null, "search_type": null, "session_configuration": [], "streaming_configuration": [], "supported_versions": ["2025-03-26", "2025-06-18", "2025-11-25"]}]}], "protocol_type": "MCP", "region": "us-east-1", "tags": {"data-classification": "confidential"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "timeouts": null}, "after_sensitive": {"authorizer_configuration": [{"custom_jwt_authorizer": [{"allowed_clients": [false, false, false], "allowed_scopes": [false], "allowed_workload_configuration": [], "custom_claim": [], "private_endpoint": [], "private_endpoint_overrides": []}]}], "interceptor_configuration": [{"input_configuration": [{}], "interception_points": [false], "interceptor": [{"lambda": [{}]}]}], "policy_engine_configuration": [], "protocol_configuration": [{"mcp": [{"session_configuration": [], "streaming_configuration": [], "supported_versions": [false, false, false]}]}], "tags": {}, "tags_all": {}, "workload_identity_details": []}, "after_unknown": {"authorizer_configuration": [{"custom_jwt_authorizer": [{"allowed_clients": [true, true, true], "allowed_scopes": [true], "allowed_workload_configuration": [], "custom_claim": [], "discovery_url": true, "private_endpoint": [], "private_endpoint_overrides": []}]}], "gateway_arn": true, "gateway_id": true, "gateway_url": true, "interceptor_configuration": [{"input_configuration": [{}], "interception_points": [false], "interceptor": [{"lambda": [{"arn": true}]}]}], "policy_engine_configuration": [], "protocol_configuration": [{"mcp": [{"session_configuration": [], "streaming_configuration": [], "supported_versions": [false, false, false]}]}], "role_arn": true, "tags": {}, "tags_all": {}, "workload_identity_details": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.mcp_chat_gateway", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_bedrockagentcore_gateway"} {"address": "module.mcp_chat_gateway.aws_bedrockagentcore_gateway_target.chat", "change": {"actions": ["create"], "after": {"credential_provider_configuration": [{"api_key": [], "caller_iam_credentials": [], "gateway_iam_role": [{"region": null, "service": null}], "jwt_passthrough": [], "oauth": []}], "description": "Gateway target for chat_with_supervisor, backed by the chat_target Lambda.", "metadata_configuration": [], "name": "chat-with-supervisor", "private_endpoint": [], "region": "us-east-1", "target_configuration": [{"http": [], "inference": [], "mcp": [{"api_gateway": [], "connector": [], "lambda": [{"tool_schema": [{"inline_payload": [{"description": "Send one message to the CRM supervisor agent and receive its answer. Pass the returned conversation_id on later calls to continue the same conversation.", "input_schema": [{"description": null, "items": [], "property": [{"description": "A conversation_id returned by an earlier call; omit to start a new conversation.", "items": [], "name": "conversation_id", "property": [], "required": false, "type": "string"}, {"description": "The message to send, 1 to 8000 characters.", "items": [], "name": "message", "property": [], "required": true, "type": "string"}], "type": "object"}], "name": "chat_with_supervisor", "output_schema": []}], "s3": []}]}], "mcp_server": [], "open_api_schema": [], "smithy_model": []}]}], "timeouts": null}, "after_sensitive": {"credential_provider_configuration": [{"api_key": [], "caller_iam_credentials": [], "gateway_iam_role": [{}], "jwt_passthrough": [], "oauth": []}], "metadata_configuration": [], "private_endpoint": [], "target_configuration": [{"http": [], "inference": [], "mcp": [{"api_gateway": [], "connector": [], "lambda": [{"tool_schema": [{"inline_payload": [{"input_schema": [{"items": [], "property": [{"items": [], "property": []}, {"items": [], "property": []}]}], "output_schema": []}], "s3": []}]}], "mcp_server": [], "open_api_schema": [], "smithy_model": []}]}]}, "after_unknown": {"credential_provider_configuration": [{"api_key": [], "caller_iam_credentials": [], "gateway_iam_role": [{}], "jwt_passthrough": [], "oauth": []}], "gateway_identifier": true, "metadata_configuration": [], "private_endpoint": [], "target_configuration": [{"http": [], "inference": [], "mcp": [{"api_gateway": [], "connector": [], "lambda": [{"lambda_arn": true, "tool_schema": [{"inline_payload": [{"input_schema": [{"items": [], "property": [{"items": [], "property": []}, {"items": [], "property": []}]}], "output_schema": []}], "s3": []}]}], "mcp_server": [], "open_api_schema": [], "smithy_model": []}]}], "target_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.mcp_chat_gateway", "name": "chat", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_bedrockagentcore_gateway_target"} diff --git a/tests/integration/test_approval_regression.py b/tests/integration/test_approval_regression.py index fb63127..d8a8b0e 100644 --- a/tests/integration/test_approval_regression.py +++ b/tests/integration/test_approval_regression.py @@ -1,5 +1,5 @@ # SPDX-License-Identifier: MIT -"""Field-level approval against DynamoDB Local: an unrelated later write and the TOCTOU race. +"""Field-level approval against DynamoDB Local: unrelated writes, the TOCTOU race, stage moves. Every call goes through the real handlers and the prefixed `dynamodb_local_store` fixture, so the condition expressions, derived-attribute rewrites and transaction cancellation are evaluated by the @@ -14,7 +14,7 @@ import pytest from crm.envelope import IDENTITY_KEY, identity_event -from crm.handlers import approve_proposal, log_activity, submit_proposal +from crm.handlers import approve_proposal, log_activity, rebase_proposal, submit_proposal from crm.store.store import Store _TENANT = "demo" @@ -204,3 +204,60 @@ def test_a_racing_change_to_an_untouched_derived_source_cancels_it(store: Store) assert result["statusCode"] == 409 target = _get(store, "opp-derived") assert target["stage_close_date"] == "Discovery#2026-09-30" + + +def _rebase(store: Store, proposal_id: str) -> Any: + return rebase_proposal.handler( + _event({"proposal_id": proposal_id, "transaction_key": _key()}), store=store + ) + + +def test_rebase_then_approve_cannot_reopen_a_closed_opportunity(store: Store) -> None: + _seed(store, "opp-reopen") + store.put_item("opportunities", {**_get(store, "opp-reopen"), "stage": "Negotiation"}) + proposal_id = _submit(store, "opp-reopen", {"stage": "Qualification"}) + store.put_item("opportunities", {**_get(store, "opp-reopen"), "stage": "Closed Won"}) + + rebased = _rebase(store, proposal_id) + assert rebased["statusCode"] == 400, rebased + assert rebased["error"]["source"] == "after_payload.stage" + + approved = _approve(store, proposal_id) + assert approved["statusCode"] == 409, approved + assert _get(store, "opp-reopen")["stage"] == "Closed Won" + proposal = store.get_item("proposals", {"proposal_id": proposal_id}) + assert proposal is not None and proposal["status"] == "pending" + + +def test_approve_refuses_a_reopen_even_when_the_snapshot_matches(store: Store) -> None: + """The stage check at approve holds without the rebase check, as for a pre-existing rebase.""" + _seed(store, "opp-snapshot") + store.put_item("opportunities", {**_get(store, "opp-snapshot"), "stage": "Negotiation"}) + proposal_id = _submit(store, "opp-snapshot", {"stage": "Qualification"}) + store.put_item("opportunities", {**_get(store, "opp-snapshot"), "stage": "Closed Won"}) + proposal = store.get_item("proposals", {"proposal_id": proposal_id}) + assert proposal is not None + store.put_item("proposals", {**proposal, "before_snapshot": _get(store, "opp-snapshot")}) + + approved = _approve(store, proposal_id) + + assert approved["statusCode"] == 400, approved + assert approved["error"]["source"] == "after_payload.stage" + assert _get(store, "opp-snapshot")["stage"] == "Closed Won" + + +def test_a_regression_after_rebase_is_approved(store: Store) -> None: + """Refused at approve after a racing move, rebased, then approved as a regression.""" + _seed(store, "opp-regress") + proposal_id = _submit(store, "opp-regress", {"stage": "Qualification"}) + store.put_item("opportunities", {**_get(store, "opp-regress"), "stage": "Negotiation"}) + + refused = _approve(store, proposal_id) + assert refused["statusCode"] == 409 + assert refused["error"]["reason"] == "fields_changed" + assert _rebase(store, proposal_id)["statusCode"] == 200 + + approved = _approve(store, proposal_id) + + assert approved["statusCode"] == 200, approved + assert _get(store, "opp-regress")["stage"] == "Qualification" diff --git a/tests/integration/test_listing_scope_ddb.py b/tests/integration/test_listing_scope_ddb.py index e56e5f8..eb381cc 100644 --- a/tests/integration/test_listing_scope_ddb.py +++ b/tests/integration/test_listing_scope_ddb.py @@ -32,6 +32,7 @@ from crm.store.provisioning import create_all_tables from crm.store.store import Store from eval.tenancy import allocate_run_id, seed_tenant, tenant_for_run +from tests.conftest import TEST_API_CLIENT_ID from tests.integration.conftest import _ENDPOINT_URL, _LOCAL_ENGINE_CRED, _drop_prefixed_tables _REP = "rep-listing-scope" @@ -99,7 +100,12 @@ def _event( "version": "2.0", "routeKey": "POST /tools/listing", "rawPath": "/tools/listing", - "requestContext": {"requestId": "req-1", "authorizer": {"jwt": {"claims": claims}}}, + "requestContext": { + "requestId": "req-1", + "authorizer": { + "jwt": {"claims": {**claims, "token_use": "id", "aud": TEST_API_CLIENT_ID}} + }, + }, "body": json.dumps(args), "isBase64Encoded": False, } diff --git a/tests/integration/test_openai_multiround.py b/tests/integration/test_openai_multiround.py index 567dc5e..84ebd8c 100644 --- a/tests/integration/test_openai_multiround.py +++ b/tests/integration/test_openai_multiround.py @@ -21,13 +21,23 @@ from providers.capabilities import load_capability_matrix from providers.openai_adapter import OpenAIAdapter from providers.tier_tuning import WIRE_SCHEMA_VERSION +from tests.conftest import TEST_API_CLIENT_ID _CALL_ID = "call_abc123" _APIGW_PAYLOAD: dict[str, Any] = { "requestContext": { "requestId": "req-openai-1", - "authorizer": {"jwt": {"claims": {"custom:rep_id": "rep-1", "custom:book": "acc-1"}}}, + "authorizer": { + "jwt": { + "claims": { + "custom:rep_id": "rep-1", + "custom:book": "acc-1", + "token_use": "id", + "aud": TEST_API_CLIENT_ID, + } + } + }, }, "prompt": "Tell me about Acme.", "session_id": "sess-openai-multiround", diff --git a/tests/integration/test_prompt_cap_contract.py b/tests/integration/test_prompt_cap_contract.py new file mode 100644 index 0000000..e3a2f0a --- /dev/null +++ b/tests/integration/test_prompt_cap_contract.py @@ -0,0 +1,188 @@ +# SPDX-License-Identifier: MIT +"""The chat prompt cap is one number on every path a chat message takes. + +Reads the cap from the source of each of its three owners: the relay (`src/relay/src/requests.ts` +`PROMPT_MAX_CHARS`), the Runtime (`src/agents/runtime_entrypoint.py` `PROMPT_MAX_CHARS`) and the +chat Gateway target (`src/gateway/chat_target.py` `MESSAGE_MAX_CHARS`). Each is read as text, so +a renamed or removed constant fails rather than skips. + +Both enforcing sides then judge the same prompts, including astral characters: the real relay +`requests.ts`, bundled with the frontend's pinned esbuild and run under node, and the real +`decode_invocation` on the agent channel the relay forwards. Those cases need `node` and +`frontend/node_modules`; without them they skip, unless `CRM_REQUIRE_TS_CONTRACTS=1`, which turns +the skip into a failure. +""" + +from __future__ import annotations + +import ast +import json +import os +import re +import shutil +from collections.abc import Iterator +from pathlib import Path + +import pytest +from scripts import proc_run + +from agents.runtime_entrypoint import decode_invocation +from crm.envelope import AGENT_IDENTITY_KEY, CLAIM_REP_ID, CLAIM_TENANT +from crm.errors import ValidationFailed +from providers.capabilities import load_capability_matrix + +REPO_ROOT = Path(__file__).resolve().parents[2] + +RELAY_SOURCE = REPO_ROOT / "src" / "relay" / "src" / "requests.ts" +RUNTIME_SOURCE = REPO_ROOT / "src" / "agents" / "runtime_entrypoint.py" +CHAT_TARGET_SOURCE = REPO_ROOT / "src" / "gateway" / "chat_target.py" + +FRONTEND = REPO_ROOT / "frontend" +ESBUILD = FRONTEND / "node_modules" / ".bin" / "esbuild" +REQUIRE_ENV_VAR = "CRM_REQUIRE_TS_CONTRACTS" + +_TS_CONSTANT = re.compile(r"^export const PROMPT_MAX_CHARS(?:: number)? = (\d[\d_]*);$", re.M) + + +def relay_cap(source: str) -> int: + """Return the relay's `PROMPT_MAX_CHARS`, failing unless it is declared exactly once.""" + matches = _TS_CONSTANT.findall(source) + assert len(matches) == 1, f"expected one PROMPT_MAX_CHARS declaration, found {len(matches)}" + return int(matches[0].replace("_", "")) + + +def python_cap(source: str, name: str) -> int: + """Return the integer literal module-level `name` is assigned, failing unless there is one.""" + values: list[int] = [] + for node in ast.parse(source).body: + target: ast.expr | None = None + value: ast.expr | None = None + if isinstance(node, ast.AnnAssign): + target, value = node.target, node.value + elif isinstance(node, ast.Assign) and len(node.targets) == 1: + target, value = node.targets[0], node.value + if isinstance(target, ast.Name) and target.id == name and isinstance(value, ast.Constant): + assert isinstance(value.value, int) and not isinstance(value.value, bool) + values.append(value.value) + assert len(values) == 1, f"expected one integer assignment to {name}, found {len(values)}" + return values[0] + + +def test_relay_runtime_and_chat_target_caps_are_equal() -> None: + caps = { + "relay": relay_cap(RELAY_SOURCE.read_text()), + "runtime": python_cap(RUNTIME_SOURCE.read_text(), "PROMPT_MAX_CHARS"), + "chat_target": python_cap(CHAT_TARGET_SOURCE.read_text(), "MESSAGE_MAX_CHARS"), + } + assert len(set(caps.values())) == 1, caps + + +def test_the_runtime_constant_read_from_source_is_the_one_it_enforces() -> None: + from agents.runtime_entrypoint import PROMPT_MAX_CHARS + from gateway.chat_target import MESSAGE_MAX_CHARS + + assert python_cap(RUNTIME_SOURCE.read_text(), "PROMPT_MAX_CHARS") == PROMPT_MAX_CHARS + assert python_cap(CHAT_TARGET_SOURCE.read_text(), "MESSAGE_MAX_CHARS") == MESSAGE_MAX_CHARS + + +@pytest.mark.parametrize( + "source", + [ + "export const PROMPT_MAX_CHARS = 8000;\nexport const PROMPT_MAX_CHARS = 8000;\n", + "const PROMPT_MAX_CHARS = 8000;\n", + "", + ], +) +def test_the_relay_reader_refuses_a_missing_or_duplicated_declaration(source: str) -> None: + with pytest.raises(AssertionError): + relay_cap(source) + + +def test_the_python_reader_refuses_a_non_literal_assignment() -> None: + with pytest.raises(AssertionError): + python_cap("PROMPT_MAX_CHARS = 4000 * 2\n", "PROMPT_MAX_CHARS") + + +#: Prompt -> whether a turn carrying it is accepted. Astral characters are one UTF-16 surrogate pair +#: each, so a cap counted in UTF-16 units would refuse the second case. +_PROMPTS: tuple[tuple[str, bool], ...] = ( + ("x" * 8000, True), + ("\U0001f600" * 8000, True), + ("x" * 8001, False), + ("\U0001f600" * 8000 + "x", False), + ("\U0001f600" * 4001, True), +) + +_DRIVER = """ +const mod = await import(process.argv[2]); +const prompts = JSON.parse(await new Promise((resolve) => { + let text = ""; + process.stdin.on("data", (chunk) => (text += chunk)); + process.stdin.on("end", () => resolve(text)); +})); +console.log(JSON.stringify(prompts.map((p) => mod.isPromptWithinCap(p)))); +""" + + +@pytest.fixture(scope="module") +def relay_verdicts(tmp_path_factory: pytest.TempPathFactory) -> Iterator[list[bool]]: + """The relay's accept/refuse verdict for every prompt in `_PROMPTS`, from the real TypeScript.""" + reason = None + if shutil.which("node") is None: + reason = "node is not on PATH" + elif not ESBUILD.exists(): + reason = f"{ESBUILD} is absent (run `cd frontend && npm ci`)" + if reason is not None: + if os.environ.get(REQUIRE_ENV_VAR) == "1": + pytest.fail(f"{REQUIRE_ENV_VAR}=1 and {reason}") + pytest.skip(reason) + work = tmp_path_factory.mktemp("prompt-cap") + bundle = work / "requests.mjs" + proc_run.run( + [ + str(ESBUILD), + str(RELAY_SOURCE), + "--bundle", + "--platform=node", + "--format=esm", + f"--outfile={bundle}", + "--log-level=error", + ], + cwd=RELAY_SOURCE.parent, + check=True, + ) + driver = work / "driver.mjs" + driver.write_text(_DRIVER, encoding="utf-8") + completed = proc_run.run( + ["node", str(driver), str(bundle)], + input=json.dumps([prompt for prompt, _ in _PROMPTS]), + capture_output=True, + text=True, + check=True, + ) + yield json.loads(completed.stdout) + + +def _runtime_accepts(prompt: str) -> bool: + payload = { + AGENT_IDENTITY_KEY: { + "claims": {CLAIM_REP_ID: "rep-1", CLAIM_TENANT: "demo", "custom:book": "acc-1"}, + "session_id": "s" * 40, + }, + "prompt": prompt, + } + try: + decode_invocation(payload, load_capability_matrix()) + except ValidationFailed as exc: + assert exc.source == "agent.invocation.prompt", exc + return False + return True + + +def test_the_runtime_judges_every_prompt_as_expected() -> None: + assert [_runtime_accepts(prompt) for prompt, _ in _PROMPTS] == [ok for _, ok in _PROMPTS] + + +def test_the_relay_judges_every_prompt_as_the_runtime_does(relay_verdicts: list[bool]) -> None: + assert relay_verdicts == [_runtime_accepts(prompt) for prompt, _ in _PROMPTS] + assert relay_verdicts == [ok for _, ok in _PROMPTS] diff --git a/tests/integration/test_search_scope_metadata_ddb.py b/tests/integration/test_search_scope_metadata_ddb.py new file mode 100644 index 0000000..5f2d3d6 --- /dev/null +++ b/tests/integration/test_search_scope_metadata_ddb.py @@ -0,0 +1,295 @@ +# SPDX-License-Identifier: MIT +"""Caller-bound cursors and scope-filtered search metadata, on DynamoDB Local. + +Paging every cursor-issuing operation to exhaustion returns each in-scope row exactly once and no +out-of-book row; ``examined_count`` never counts out-of-book rows, and below the examination +budget they never cause ``truncated``; and a cursor replayed by another rep is refused as a +``cursor`` validation failure. +""" + +from __future__ import annotations + +import uuid +from collections.abc import Callable, Iterator +from typing import Any + +import pytest + +from crm import search +from crm.authz import Identity +from crm.envelope import IDENTITY_KEY, identity_event +from crm.handlers import list_activities, list_audit_records, list_proposals +from crm.store.provisioning import create_all_tables +from crm.store.store import Store +from tests.integration.conftest import _drop_prefixed_tables + +_TENANT = "eval-cursor-scope" +_REP = "rep-cursor" +#: Unique per process, so concurrent xdist workers never share a table. +_TABLE_PREFIX = f"int-cursor-scope-{uuid.uuid4().hex[:12]}-" +_IN_BOOK = tuple(f"acct-in-{n}" for n in range(6)) +_OUT_OF_BOOK = tuple(f"acct-out-{n}" for n in range(7)) +_ACTIVITY_OPPORTUNITY = "opp-acct-in-0" +_ACTIVITIES = 7 +_PAGE = 3 + + +@pytest.fixture +def store(dynamodb_local_client: Any) -> Iterator[Store]: + """A prefixed, seeded :class:`Store` on DynamoDB Local, dropped after each test.""" + create_all_tables(dynamodb_local_client, table_prefix=_TABLE_PREFIX) + try: + seeded = Store(table_prefix=_TABLE_PREFIX, client=dynamodb_local_client) + _seed(seeded) + yield seeded + finally: + _drop_prefixed_tables(dynamodb_local_client, _TABLE_PREFIX) + + +@pytest.fixture +def small_pages(monkeypatch: pytest.MonkeyPatch) -> None: + """Shrink every page and the search budget so a dozen rows span several cursors.""" + monkeypatch.setattr(search, "EXAMINATION_BUDGET", _PAGE) + monkeypatch.setattr(search, "_PAGE_SIZE", _PAGE) + for module in (list_activities, list_audit_records, list_proposals): + monkeypatch.setattr(module, "_DEFAULT_LIMIT", _PAGE) + + +def _seed(store: Store) -> None: + for n, account_id in enumerate(sorted(_IN_BOOK + _OUT_OF_BOOK)): + created_at = f"2026-11-01T00:00:{n:02d}+00:00" + opportunity_id = f"opp-{account_id}" + store.put_item( + "accounts", + { + "account_id": account_id, + "tenant": _TENANT, + "name": f"Account {account_id}", + "owner_rep_id": _REP, + "created_at": created_at, + }, + ) + store.put_item( + "opportunities", + { + "opportunity_id": opportunity_id, + "tenant": _TENANT, + "account_id": account_id, + "owner_rep_id": _REP, + "stage": "Discovery", + "close_date": "2026-12-01", + "value": 100, + "name": "Renewal", + "created_at": created_at, + }, + ) + store.put_item( + "audit_records", + { + "audit_id": f"aud-{account_id}", + "tenant": _TENANT, + "account_id": account_id, + "target_table": "opportunities", + "target_id": opportunity_id, + "actor_rep_id": _REP, + "status": "active", + "created_at": created_at, + }, + ) + store.put_item( + "proposals", + { + "proposal_id": f"prop-{account_id}", + "tenant": _TENANT, + "status": "pending", + "actor_rep_id": _REP, + "target_table": "opportunities", + "target_id": opportunity_id, + "created_at": created_at, + "before_snapshot": {"tenant": _TENANT, "account_id": account_id}, + }, + ) + for n in range(_ACTIVITIES): + store.put_item( + "activities", + { + "activity_id": f"act-{n:02d}", + "tenant": _TENANT, + "opportunity_id": _ACTIVITY_OPPORTUNITY, + "account_id": "acct-in-0", + "kind": "call", + "subject": f"call {n}", + "occurred_at": f"2026-11-02T00:00:{n:02d}+00:00", + "created_at": f"2026-11-02T00:00:{n:02d}+00:00", + }, + ) + + +def _identity(*, rep_id: str = _REP) -> Identity: + return Identity(rep_id=rep_id, book=frozenset(_IN_BOOK), tenant=_TENANT) + + +def _identity_payload(*, rep_id: str = _REP) -> dict[str, Any]: + return { + "rep_id": rep_id, + "book": list(_IN_BOOK), + "full_visibility": False, + "principal_type": "user", + "session_id": "sess-cursor-scope", + "source": "gateway", + "tenant": _TENANT, + } + + +def _call( + handler: Callable[..., dict[str, Any]], + store: Store, + arguments: dict[str, Any], + *, + rep_id: str = _REP, +) -> dict[str, Any]: + event = identity_event(IDENTITY_KEY, _identity_payload(rep_id=rep_id), arguments) + return handler(event, store=store) + + +def _page_all( + handler: Callable[..., dict[str, Any]], + store: Store, + arguments: dict[str, Any], + rows_key: str, + row_id: Callable[[dict[str, Any]], str], +) -> tuple[list[str], int]: + """Follow ``next_cursor`` to exhaustion; return every row id seen and the page count.""" + seen: list[str] = [] + cursor: str | None = None + pages = 0 + while True: + args = dict(arguments) if cursor is None else {**arguments, "cursor": cursor} + result = _call(handler, store, args) + assert result["statusCode"] == 200, result + pages += 1 + seen.extend(row_id(row) for row in result["body"][rows_key]) + cursor = result["body"]["next_cursor"] + if cursor is None: + return seen, pages + assert pages < 50, "paging did not terminate" + + +def test_search_opportunities_pages_every_in_scope_row_once_and_counts_only_in_scope( + store: Store, small_pages: None +) -> None: + seen: list[str] = [] + examined = 0 + cursor: str | None = None + pages = 0 + while True: + result = search.search_opportunities(store, _identity(), cursor=cursor) + pages += 1 + seen.extend(str(item["account_id"]) for item in result.items) + examined += result.examined_count + cursor = result.next_cursor + if cursor is None: + break + assert pages < 50, "paging did not terminate" + + assert sorted(seen) == sorted(_IN_BOOK) + assert examined == len(_IN_BOOK) + assert pages > 1 + + +def test_search_accounts_pages_every_in_scope_row_once(store: Store, small_pages: None) -> None: + seen: list[str] = [] + cursor: str | None = None + for _ in range(50): + result = search.search_accounts(store, _identity(), cursor=cursor) + seen.extend(str(item["account_id"]) for item in result.items) + cursor = result.next_cursor + if cursor is None: + break + + assert cursor is None + assert sorted(seen) == sorted(_IN_BOOK) + + +@pytest.mark.parametrize( + ("handler", "arguments", "rows_key", "row_id", "expected"), + [ + ( + list_audit_records.handler, + {}, + "audit_records", + lambda row: str(row["account_id"]), + sorted(_IN_BOOK), + ), + ( + list_proposals.handler, + {}, + "proposals", + lambda row: str(row["before_snapshot"]["account_id"]), + sorted(_IN_BOOK), + ), + ( + list_activities.handler, + {"opportunity_id": _ACTIVITY_OPPORTUNITY}, + "activities", + lambda row: str(row["activity_id"]), + [f"act-{n:02d}" for n in range(_ACTIVITIES)], + ), + ], + ids=["list_audit_records", "list_proposals", "list_activities"], +) +def test_each_listing_pages_every_in_scope_row_exactly_once( + store: Store, + small_pages: None, + handler: Callable[..., dict[str, Any]], + arguments: dict[str, Any], + rows_key: str, + row_id: Callable[[dict[str, Any]], str], + expected: list[str], +) -> None: + seen, pages = _page_all(handler, store, arguments, rows_key, row_id) + + assert sorted(seen) == expected + assert len(seen) == len(set(seen)) + assert pages > 1 + + +def test_out_of_book_rows_below_the_budget_never_move_examined_count_or_truncated( + store: Store, +) -> None: + outsider = Identity(rep_id=_REP, book=frozenset({"acct-elsewhere"}), tenant=_TENANT) + + for result in ( + search.search_opportunities(store, outsider, limit=1), + search.search_accounts(store, outsider, limit=1), + ): + assert result.items == [] + assert result.examined_count == 0 + assert result.truncated is False + assert result.next_cursor is None + + +@pytest.mark.parametrize( + ("handler", "arguments"), + [ + (list_audit_records.handler, {}), + (list_proposals.handler, {}), + (list_activities.handler, {"opportunity_id": _ACTIVITY_OPPORTUNITY}), + ], + ids=["list_audit_records", "list_proposals", "list_activities"], +) +def test_a_listing_cursor_replayed_by_another_rep_is_a_cursor_validation_failure( + store: Store, + small_pages: None, + handler: Callable[..., dict[str, Any]], + arguments: dict[str, Any], +) -> None: + first = _call(handler, store, arguments) + cursor = first["body"]["next_cursor"] + assert cursor is not None + + replayed = _call(handler, store, {**arguments, "cursor": cursor}, rep_id="rep-other") + + assert replayed["statusCode"] == 400, replayed + assert replayed["error"]["code"] == "validation_failed" + assert replayed["error"]["source"] == "cursor" diff --git a/tests/integration/test_tier_comparison_ui_contract.py b/tests/integration/test_tier_comparison_ui_contract.py new file mode 100644 index 0000000..a9bf2c5 --- /dev/null +++ b/tests/integration/test_tier_comparison_ui_contract.py @@ -0,0 +1,254 @@ +# SPDX-License-Identifier: MIT +"""The run payload's tier table and the published ``matrix.md`` agree byte for byte. + +For stub-built matrices, ``write_matrix_artifacts`` writes ``matrix.md``; the same matrix's report +fields, round-tripped through JSON as the aggregate step stores them, become a ``RunRecord`` whose +``to_payload()["tier_comparison_table"]``, formatted as Markdown here, must equal that file's +``## Tier comparison summary`` section. The test also writes the payload tables the frontend +renders to ``frontend/src/pages/evals/__fixtures__/tierComparison.json``. +""" + +from __future__ import annotations + +import json +import os +from pathlib import Path +from typing import Any, cast + +import pytest + +from eval.matrix import ( + ArmResult, + MatrixResult, + RunProvenance, + build_matrix_result, + write_matrix_artifacts, +) +from eval.runs import RunRecord + +_REPO_ROOT = Path(__file__).resolve().parents[2] +FRONTEND_FIXTURE = ( + _REPO_ROOT / "frontend" / "src" / "pages" / "evals" / "__fixtures__" / ("tierComparison.json") +) + +_OPUS = "anthropic.claude-opus-5-5" +_SONNET = "anthropic.claude-sonnet-5-5" +_HAIKU = "anthropic.claude-haiku-5-5" +_SOL = "openai.gpt-6-1-sol" +_LUNA = "openai.gpt-6-1-luna" +_TIERS = ("supervisor", "subagent", "tool") + + +def _summary_entry(met: int, applicable: int, tokens: tuple[int, int]) -> dict[str, object]: + return { + "input_tokens": tokens[0], + "output_tokens": tokens[1], + "cost_total": None, + "latency_p50_ms": None, + "latency_p95_ms": None, + "success": { + "passed": met, + "applicable": applicable, + "rate": met / applicable if applicable else None, + }, + } + + +def _stub_arm( + family: str, + models: tuple[str, str, str], + *, + completions: tuple[tuple[int, int], tuple[int, int], tuple[int, int]], + outcomes: tuple[int, int, int, int, int], +) -> ArmResult: + """A stub-mode arm with cost withheld; only an ``anthropic`` arm records retry counts.""" + by_tier = { + tier: { + "configured_model_id": model_id, + "efforts": ["medium"] if tier == "supervisor" else ["low"], + "latency_sample_count": 0, + "completed_task_latency_ms_p50": None, + "completed_task_latency_ms_p95": None, + } + for tier, model_id in zip(_TIERS, models, strict=True) + } + if family == "anthropic": + for tier in _TIERS: + by_tier[tier]["retry_count"] = 0 + tasks: tuple[dict[str, object], ...] = tuple( + { + "task_id": f"gt-{index:02d}", + "scoring_mode": "machine", + "correctness": 1.0 if index < completions[0][0] else 0.0, + "unscored_reason": None, + "bad_write": False, + "tool_call_correct": True, + "truncated": False, + "budget_exhausted": False, + "assertion_results": [], + } + for index in range(completions[0][1]) + ) + return ArmResult( + provenance=RunProvenance( + mode="stub", + timestamp="2026-11-06T00:00:00+00:00", + model_id=models[0], + effort="medium", + dataset_seed=20261106, + git_revision="not-a-commit", + runtime_identifier="local-stub-runtime", + price_table_version="v1", + answer_style_sha256="0" * 64, + ), + model_metrics_fields={ + "cost_withheld_provisional": True, + "exclusions": {"total_excluded": 0, "by_category": {"cold_start": 0}}, + }, + aggregate_score_fields={ + "scored_task_count": len(tasks), + "unscored_task_count": 0, + "mean_correctness": completions[0][0] / completions[0][1], + "bad_write_rate": 0.0, + "tool_call_correct_rate": 1.0, + }, + task_score_fields=tasks, + tier_role_model_fields=tuple( + { + "tier": tier, + "role": tier, + "model_id": model_id, + "included_invocation_count": 2, + "input_tokens": 20, + "output_tokens": 2, + } + for tier, model_id in zip(_TIERS, models, strict=True) + ), + tier_summary_fields={ + tier: _summary_entry(met, applicable, (100 * (i + 1), 10 * (i + 1))) + for i, (tier, (met, applicable)) in enumerate(zip(_TIERS, completions, strict=True)) + }, + tier_task_metrics_fields={ + "family": family, + "by_tier": by_tier, + "delegation_outcomes": dict( + zip(("data", "no_match", "denied", "tool_failure", "none"), outcomes, strict=True) + ), + }, + ) + + +def _matrices() -> dict[str, MatrixResult]: + anthropic = _stub_arm( + "anthropic", + (_SONNET, _HAIKU, _HAIKU), + completions=((3, 4), (2, 3), (1, 2)), + outcomes=(2, 0, 1, 0, 1), + ) + openai = _stub_arm( + "openai", + (_SOL, _LUNA, _LUNA), + completions=((2, 4), (0, 0), (2, 2)), + outcomes=(0, 0, 0, 0, 4), + ) + return { + "multi_arm": build_matrix_result([anthropic, openai]), + "single_arm": build_matrix_result( + [ + _stub_arm( + "anthropic", + (_OPUS, _SONNET, _HAIKU), + completions=((1, 1), (1, 1), (0, 1)), + outcomes=(1, 0, 0, 0, 0), + ) + ] + ), + } + + +def _matrix_md_section(markdown: str) -> str: + start = markdown.index("## Tier comparison summary") + end = markdown.index("Measured dimensions per model arm") + return markdown[start:end] + + +def _table_markdown(table: dict[str, Any]) -> str: + """Format a payload table the way ``matrix.md`` lays the summary out.""" + + def line(cells: list[str]) -> str: + return "| " + " | ".join(cells) + " |" + + headers = cast(list[str], table["headers"]) + lines = [ + "## Tier comparison summary", + "", + "Per-tier figures for each arm, one column per arm in run order; the notes below the " + "tables define each row.", + "", + ] + for section in table["sections"]: + lines.extend([f"### {section['heading']}", "", line(headers), line(["---"] * len(headers))]) + lines.extend(line(row) for row in section["rows"]) + lines.append("") + lines.extend(["Notes:", "", *(f"- {note}" for note in table["notes"]), ""]) + return "\n".join(lines) + "\n" + + +def _payload_table(matrix: MatrixResult, run_id: str) -> dict[str, Any]: + stored = json.loads(json.dumps(matrix.to_report_fields())) + record = RunRecord( + run_id=run_id, + tenant=f"eval-{run_id}", + mode="stub", + status="completed", + started_at="2026-11-06T00:00:00+00:00", + matrix_report=stored, + ) + wire = json.loads(json.dumps(record.to_payload())) + return cast(dict[str, Any], wire["tier_comparison_table"]) + + +@pytest.mark.parametrize("case", ["multi_arm", "single_arm"]) +def test_the_payload_table_formats_to_the_published_matrix_md_section( + case: str, tmp_path: Path +) -> None: + matrix = _matrices()[case] + paths = write_matrix_artifacts(matrix, tmp_path) + published = _matrix_md_section(paths["md"].read_text(encoding="utf-8")) + table = _payload_table(matrix, f"run-{case}") + assert _table_markdown(table) == published + assert len(table["headers"]) == 1 + len(matrix.arms) + + +def test_a_reordered_cell_is_detected_control(tmp_path: Path) -> None: + """Control: the byte comparison above sees a single changed cell.""" + matrix = _matrices()["multi_arm"] + published = _matrix_md_section( + write_matrix_artifacts(matrix, tmp_path)["md"].read_text("utf-8") + ) + table = _payload_table(matrix, "run-control") + row = table["sections"][0]["rows"][0] + row[1], row[2] = row[2], row[1] + assert _table_markdown(table) != published + + +def _fixture_document() -> str: + cases: dict[str, object] = {} + for case, matrix in _matrices().items(): + cases[case] = {"tier_comparison_table": _payload_table(matrix, f"run-{case}")} + return json.dumps(cases, indent=2, ensure_ascii=False) + "\n" + + +def test_the_frontend_fixture_is_the_payload_tables(tmp_path: Path) -> None: + document = _fixture_document() + FRONTEND_FIXTURE.parent.mkdir(parents=True, exist_ok=True) + staging = FRONTEND_FIXTURE.with_name(f".{FRONTEND_FIXTURE.name}.{os.getpid()}.tmp") + staging.write_text(document, encoding="utf-8") + staging.replace(FRONTEND_FIXTURE) + written = json.loads(FRONTEND_FIXTURE.read_text(encoding="utf-8")) + for case, matrix in _matrices().items(): + table = written[case]["tier_comparison_table"] + published = _matrix_md_section( + write_matrix_artifacts(matrix, tmp_path / case)["md"].read_text("utf-8") + ) + assert _table_markdown(table) == published diff --git a/tests/integration/test_update_conditional_ddb.py b/tests/integration/test_update_conditional_ddb.py new file mode 100644 index 0000000..308a6f1 --- /dev/null +++ b/tests/integration/test_update_conditional_ddb.py @@ -0,0 +1,244 @@ +# SPDX-License-Identifier: MIT +"""Conditional ``update_*`` writes against DynamoDB Local, through each handler's real entry point. + +An approve-style ``UpdateItem`` landing between a handler's consistent read and its transaction makes +the handler return 409 ``conflict`` with ``reason="fields_changed"``; the approved values persist and +no audit record is written. A replay under the same ``transaction_key`` writes nothing new. +""" + +from __future__ import annotations + +import uuid +from collections.abc import Callable, Iterator +from dataclasses import dataclass +from typing import Any + +import pytest + +from crm.envelope import IDENTITY_KEY, identity_event +from crm.handlers import ( + log_activity, + update_account, + update_activity, + update_contact, + update_opportunity, +) +from crm.store.provisioning import create_all_tables +from crm.store.store import Store +from tests.integration.conftest import _drop_prefixed_tables + +_TENANT = "demo" +_ACCOUNT = "acct-1" +_APPROVED_AT = "2024-03-01T00:00:00+00:00" + +#: Unique per process, so concurrent xdist workers never share a table. +_TABLE_PREFIX = f"upc-{uuid.uuid4().hex[:12]}-" + + +@dataclass(frozen=True) +class _Case: + table: str + key_attr: str + record_id: str + handler: Callable[..., dict[str, Any]] + field: str + + +_CASES = [ + _Case("accounts", "account_id", _ACCOUNT, update_account.handler, "name"), + _Case("contacts", "contact_id", "cont-1", update_contact.handler, "name"), + _Case("opportunities", "opportunity_id", "opp-1", update_opportunity.handler, "description"), + _Case("activities", "activity_id", "act-1", update_activity.handler, "subject"), +] + + +def _transaction_key() -> str: + """A fresh 36-character key; DynamoDB Local retains ``ClientRequestToken``s across sessions.""" + return uuid.uuid4().hex + uuid.uuid4().hex[:4] + + +@pytest.fixture +def client(dynamodb_local_client: Any) -> Iterator[Any]: + create_all_tables(dynamodb_local_client, table_prefix=_TABLE_PREFIX) + try: + yield dynamodb_local_client + finally: + _drop_prefixed_tables(dynamodb_local_client, _TABLE_PREFIX) + + +@pytest.fixture +def store(client: Any) -> Store: + store = Store(table_prefix=_TABLE_PREFIX, client=client) + stamp = {"updated_at": "2024-02-01T00:00:00+00:00"} + store.put_item( + "accounts", + {"account_id": _ACCOUNT, "tenant": _TENANT, "owner_rep_id": "rep-1", "name": "Acme"} + | stamp, + ) + store.put_item( + "contacts", + { + "contact_id": "cont-1", + "tenant": _TENANT, + "account_id": _ACCOUNT, + "name": "Jane Doe", + "status": "active", + "created_at": "2024-01-01T00:00:00+00:00", + } + | stamp, + ) + store.put_item( + "opportunities", + { + "opportunity_id": "opp-1", + "tenant": _TENANT, + "account_id": _ACCOUNT, + "owner_rep_id": "rep-1", + "name": "Big Deal", + "stage": "Discovery", + "value": 1000, + "primary_contact_id": None, + "last_touch": None, + "created_at": "2024-01-01T00:00:00+00:00", + } + | stamp, + ) + store.put_item( + "activities", + { + "activity_id": "act-1", + "tenant": _TENANT, + "opportunity_id": "opp-1", + "account_id": _ACCOUNT, + "kind": "call", + "subject": "Intro", + "occurred_at": "2024-01-01T00:00:00+00:00", + "created_at": "2024-01-01T00:00:00+00:00", + } + | stamp, + ) + return store + + +def _event(case: _Case, value: str, transaction_key: str) -> dict[str, Any]: + identity = { + "rep_id": "rep-1", + "book": [_ACCOUNT], + "full_visibility": False, + "principal_type": "user", + "session_id": "sess-1", + "source": "gateway", + "tenant": _TENANT, + } + args = { + case.key_attr: case.record_id, + "fields": {case.field: value}, + "transaction_key": transaction_key, + } + return identity_event(IDENTITY_KEY, identity, args) + + +def _audit_rows(store: Store, client: Any, record_id: str) -> list[dict[str, Any]]: + items = client.scan(TableName=store.physical_name("audit_records"), ConsistentRead=True) + return [row for row in items["Items"] if row.get("target_id", {}).get("S") == record_id] + + +@pytest.mark.parametrize("case", _CASES, ids=[case.table for case in _CASES]) +def test_approve_between_read_and_put_wins_and_the_update_is_refused( + store: Store, client: Any, monkeypatch: pytest.MonkeyPatch, case: _Case +) -> None: + real_get_item = store.get_item + + def _get_item_then_approve(table: str, key: Any, *, consistent: bool = False) -> Any: + item = real_get_item(table, key, consistent=consistent) + if table == case.table: + client.update_item( + TableName=store.physical_name(case.table), + Key={case.key_attr: {"S": case.record_id}}, + UpdateExpression="SET approved_marker = :m, updated_at = :t", + ExpressionAttributeValues={":m": {"S": "approved"}, ":t": {"S": _APPROVED_AT}}, + ) + return item + + monkeypatch.setattr(store, "get_item", _get_item_then_approve) + + result = case.handler(_event(case, "from-the-loser", _transaction_key()), store=store) + + assert result["statusCode"] == 409 + assert result["error"]["code"] == "conflict" + assert result["error"]["reason"] == "fields_changed" + persisted = real_get_item(case.table, {case.key_attr: case.record_id}, consistent=True) + assert persisted is not None + assert persisted["approved_marker"] == "approved" + assert persisted["updated_at"] == _APPROVED_AT + assert persisted.get(case.field) != "from-the-loser" + assert _audit_rows(store, client, case.record_id) == [] + + +@pytest.mark.parametrize("case", _CASES, ids=[case.table for case in _CASES]) +def test_replay_with_the_same_transaction_key_writes_nothing_new( + store: Store, client: Any, case: _Case +) -> None: + transaction_key = _transaction_key() + first = case.handler(_event(case, "first", transaction_key), store=store) + assert first["statusCode"] == 200 + after_first = store.get_item(case.table, {case.key_attr: case.record_id}, consistent=True) + + replay = case.handler(_event(case, "first", transaction_key), store=store) + + assert replay["statusCode"] == 409 + assert replay["error"]["code"] == "conflict" + assert replay["error"].get("reason") != "fields_changed" + after_replay = store.get_item(case.table, {case.key_attr: case.record_id}, consistent=True) + assert after_replay == after_first + assert len(_audit_rows(store, client, case.record_id)) == 1 + + +def test_approve_between_log_activity_read_and_write_is_refused_as_fields_changed( + store: Store, client: Any, monkeypatch: pytest.MonkeyPatch +) -> None: + real_get_item = store.get_item + + def _get_item_then_approve(table: str, key: Any, *, consistent: bool = False) -> Any: + item = real_get_item(table, key, consistent=consistent) + if table == "opportunities": + client.update_item( + TableName=store.physical_name("opportunities"), + Key={"opportunity_id": {"S": "opp-1"}}, + UpdateExpression="SET approved_marker = :m, updated_at = :t", + ExpressionAttributeValues={":m": {"S": "approved"}, ":t": {"S": _APPROVED_AT}}, + ) + return item + + monkeypatch.setattr(store, "get_item", _get_item_then_approve) + identity = { + "rep_id": "rep-1", + "book": [_ACCOUNT], + "full_visibility": False, + "principal_type": "user", + "session_id": "sess-1", + "source": "gateway", + "tenant": _TENANT, + } + event = identity_event( + IDENTITY_KEY, + identity, + { + "opportunity_id": "opp-1", + "kind": "call", + "subject": "Checked in", + "occurred_at": "2024-05-01T00:00:00+00:00", + "transaction_key": _transaction_key(), + }, + ) + + result = log_activity.handler(event, store=store) + + assert result["statusCode"] == 409 + assert result["error"]["reason"] == "fields_changed" + persisted = real_get_item("opportunities", {"opportunity_id": "opp-1"}, consistent=True) + assert persisted is not None and persisted["approved_marker"] == "approved" + assert persisted.get("last_touch") is None + activities = client.scan(TableName=store.physical_name("activities"), ConsistentRead=True) + assert [row["activity_id"]["S"] for row in activities["Items"]] == ["act-1"] + assert _audit_rows(store, client, "opp-1") == [] diff --git a/tests/integration/test_user_settings_store.py b/tests/integration/test_user_settings_store.py index fec6362..c8e1ca3 100644 --- a/tests/integration/test_user_settings_store.py +++ b/tests/integration/test_user_settings_store.py @@ -22,6 +22,7 @@ ) from providers.capabilities import load_capability_matrix from providers.tier_tuning import WIRE_SCHEMA_VERSION, TierRequest, TurnTuning +from tests.conftest import TEST_API_CLIENT_ID MATRIX = load_capability_matrix() @@ -37,7 +38,12 @@ def _user(rep_id: str, tenant: str = "demo") -> Identity: "requestContext": { "requestId": "req-1", "authorizer": { - "claims": {"custom:rep_id": rep_id, "custom:tenant": tenant}, + "claims": { + "custom:rep_id": rep_id, + "custom:tenant": tenant, + "token_use": "id", + "aud": TEST_API_CLIENT_ID, + }, }, } } diff --git a/tests/unit/test_audit.py b/tests/unit/test_audit.py index 4b7d4e0..da02c55 100644 --- a/tests/unit/test_audit.py +++ b/tests/unit/test_audit.py @@ -988,3 +988,187 @@ def get_item( assert ("accounts", True) in reads assert ("accounts", False) not in reads + + +# -- stage moves a revert may not make ------------------------------------------------------ + + +def _put_stage_update_record( + store: Store, identity: Identity, *, before_stage: str, after_stage: str, audit_id: str +) -> None: + snapshot = { + "opportunity_id": "opp-1", + "tenant": "demo", + "account_id": "acc-1", + "name": "Acme Renewal", + "value": 50000, + } + record = build_audit_record( + identity=identity, + target_table="opportunities", + target_id="opp-1", + before_snapshot={**snapshot, "stage": before_stage}, + after_snapshot={**snapshot, "stage": after_stage}, + audit_id=audit_id, + ) + store.put_item("audit_records", record.to_item()) + + +@pytest.mark.parametrize( + ("before_stage", "after_stage"), + [("Negotiation", "Closed Won"), ("Discovery", "Closed Lost"), ("Closed Lost", "Closed Won")], + ids=["reopen-won", "reopen-lost", "closed-lateral"], +) +def test_revert_that_would_make_a_refused_stage_move_is_a_conflict_writing_nothing( + store: Store, identity: Identity, before_stage: str, after_stage: str +) -> None: + _seed_opportunity(store, stage=after_stage) + _put_stage_update_record( + store, identity, before_stage=before_stage, after_stage=after_stage, audit_id="audit-close" + ) + + with pytest.raises(Conflict) as raised: + revert(identity, store, audit_id="audit-close", transaction_key="tx-refused-stage") + + assert "closed" in raised.value.message + opportunity = store.get_item("opportunities", {"opportunity_id": "opp-1"}) + assert opportunity is not None and opportunity["stage"] == after_stage + audit = store.get_item("audit_records", {"audit_id": "audit-close"}) + assert audit is not None and audit["status"] == "active" + + +def test_revert_of_a_regression_still_restores_the_earlier_stage( + store: Store, identity: Identity +) -> None: + _seed_opportunity(store, stage="Discovery") + _put_stage_update_record( + store, + identity, + before_stage="Qualification", + after_stage="Discovery", + audit_id="audit-regress", + ) + + result = revert(identity, store, audit_id="audit-regress", transaction_key="tx-regress") + + assert result["status"] == "reversed" + opportunity = store.get_item("opportunities", {"opportunity_id": "opp-1"}) + assert opportunity is not None and opportunity["stage"] == "Qualification" + + +# -- a restored primary contact must still exist under the opportunity's account ------------- + + +def _put_contact_update_record( + store: Store, identity: Identity, *, before_contact: str | None, after_contact: str | None +) -> str: + base = {**_opportunity(), "stage": "Discovery"} + record = build_audit_record( + identity=identity, + target_table="opportunities", + target_id="opp-1", + before_snapshot={**base, "primary_contact_id": before_contact}, + after_snapshot={**base, "primary_contact_id": after_contact}, + audit_id="audit-contact", + ) + store.put_item("audit_records", record.to_item()) + return "audit-contact" + + +def _seed_opportunity_naming(store: Store, contact_id: str | None) -> None: + store.put_item( + "opportunities", {**_opportunity(), "stage": "Discovery", "primary_contact_id": contact_id} + ) + + +@pytest.mark.parametrize( + "restored_contact", + [ + {}, + {"contact_id": "con-old", "tenant": "demo", "account_id": "acc-other", "name": "Elsewhere"}, + {"contact_id": "con-old", "tenant": "other", "account_id": "acc-1", "name": "Foreign"}, + ], + ids=["deleted", "other-account", "other-tenant"], +) +def test_update_revert_restoring_a_dangling_primary_contact_is_a_conflict_writing_nothing( + store: Store, identity: Identity, restored_contact: dict[str, object] +) -> None: + if restored_contact: + store.put_item("contacts", restored_contact) + store.put_item("contacts", {**_contact(), "contact_id": "con-new"}) + _seed_opportunity_naming(store, "con-new") + audit_id = _put_contact_update_record( + store, identity, before_contact="con-old", after_contact="con-new" + ) + + with pytest.raises(Conflict) as raised: + revert(identity, store, audit_id=audit_id, transaction_key="tx-dangling") + + assert "primary contact" in raised.value.message + opportunity = store.get_item("opportunities", {"opportunity_id": "opp-1"}) + assert opportunity is not None and opportunity["primary_contact_id"] == "con-new" + audit = store.get_item("audit_records", {"audit_id": audit_id}) + assert audit is not None and audit["status"] == "active" + + +def test_update_revert_restoring_a_live_primary_contact_succeeds( + store: Store, identity: Identity +) -> None: + store.put_item("contacts", {**_contact(), "contact_id": "con-old"}) + store.put_item("contacts", {**_contact(), "contact_id": "con-new"}) + _seed_opportunity_naming(store, "con-new") + audit_id = _put_contact_update_record( + store, identity, before_contact="con-old", after_contact="con-new" + ) + + revert(identity, store, audit_id=audit_id, transaction_key="tx-live-contact") + + opportunity = store.get_item("opportunities", {"opportunity_id": "opp-1"}) + assert opportunity is not None and opportunity["primary_contact_id"] == "con-old" + + +def test_update_revert_restoring_a_cleared_primary_contact_needs_no_contact( + store: Store, identity: Identity +) -> None: + store.put_item("contacts", {**_contact(), "contact_id": "con-new"}) + _seed_opportunity_naming(store, "con-new") + audit_id = _put_contact_update_record( + store, identity, before_contact=None, after_contact="con-new" + ) + + revert(identity, store, audit_id=audit_id, transaction_key="tx-cleared-contact") + + opportunity = store.get_item("opportunities", {"opportunity_id": "opp-1"}) + assert opportunity is not None and opportunity["primary_contact_id"] is None + + +def test_update_revert_leaving_the_primary_contact_unchanged_does_not_check_it( + store: Store, identity: Identity +) -> None: + _seed_opportunity_naming(store, "con-gone") + audit_id = _put_contact_update_record( + store, identity, before_contact="con-gone", after_contact="con-gone" + ) + + revert(identity, store, audit_id=audit_id, transaction_key="tx-unchanged-contact") + + audit = store.get_item("audit_records", {"audit_id": audit_id}) + assert audit is not None and audit["status"] == "reversed" + + +def test_delete_revert_restoring_a_dangling_primary_contact_is_a_conflict( + store: Store, identity: Identity +) -> None: + _seed_account(store) + audit_id = _put_delete_record( + store, + identity, + "opportunities", + "opp-1", + {**_opportunity(), "primary_contact_id": "con-gone"}, + ) + + with pytest.raises(Conflict): + revert(identity, store, audit_id=audit_id, transaction_key="tx-delete-dangling") + + assert store.get_item("opportunities", {"opportunity_id": "opp-1"}) is None diff --git a/tests/unit/test_check_canary_tenant_empty.py b/tests/unit/test_check_canary_tenant_empty.py index 1eb0c3b..85cf6d6 100644 --- a/tests/unit/test_check_canary_tenant_empty.py +++ b/tests/unit/test_check_canary_tenant_empty.py @@ -15,11 +15,18 @@ import boto3 import pytest import scripts.check_canary_tenant_empty as gate -from botocore.exceptions import ClientError, NoCredentialsError, ProfileNotFound +from botocore.exceptions import ( + ClientError, + ConnectTimeoutError, + EndpointConnectionError, + HTTPClientError, + NoCredentialsError, + ProfileNotFound, +) from moto import mock_aws from scripts.run_gates import GATE_SKIP_EXIT_STATUS -from crm.errors import CrmError, wrap_aws_error +from crm.errors import CrmError, ServiceBusy, wrap_aws_error from crm.store.provisioning import create_all_tables from crm.store.schema import TENANT_SCOPED_TABLES from crm.store.store import Store @@ -29,13 +36,49 @@ _MANY_PLANTED = 25 +#: Every environment variable through which the host's AWS identity, profile or region could reach a +#: session built in these tests. +_AMBIENT_AWS_ENV: tuple[str, ...] = ( + "AWS_PROFILE", + "AWS_DEFAULT_PROFILE", + "AWS_ACCESS_KEY_ID", + "AWS_SECRET_ACCESS_KEY", + "AWS_SESSION_TOKEN", + "AWS_SECURITY_TOKEN", + "AWS_CREDENTIAL_EXPIRATION", + "AWS_VAULT", + "AWS_REGION", + "AWS_DEFAULT_REGION", + "AWS_CONFIG_FILE", + "AWS_SHARED_CREDENTIALS_FILE", + "AWS_MAX_ATTEMPTS", + "AWS_RETRY_MODE", +) + + +def _hermetic_aws_env(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None: + """Replace the host's AWS configuration with a `default` profile holding fake static credentials + and a single attempt per call, so an unreachable endpoint fails at once rather than after retries. + + No session built afterwards reads the host's ``~/.aws`` or its ambient ``AWS_*`` variables. + """ + for name in _AMBIENT_AWS_ENV: + monkeypatch.delenv(name, raising=False) + config = tmp_path / "aws-config" + credentials = tmp_path / "aws-credentials" + config.write_text("[default]\nregion = us-east-1\nmax_attempts = 1\n", encoding="utf-8") + credentials.write_text( + "[default]\naws_access_key_id = testing\naws_secret_access_key = testing\n", + encoding="utf-8", + ) + monkeypatch.setenv("AWS_CONFIG_FILE", str(config)) + monkeypatch.setenv("AWS_SHARED_CREDENTIALS_FILE", str(credentials)) + + @pytest.fixture -def dynamodb_client(monkeypatch: pytest.MonkeyPatch) -> Iterator[Any]: +def dynamodb_client(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> Iterator[Any]: """A moto-mocked DynamoDB client built from its own session with fake static credentials.""" - monkeypatch.delenv("AWS_PROFILE", raising=False) - monkeypatch.delenv("AWS_DEFAULT_PROFILE", raising=False) - monkeypatch.setenv("AWS_ACCESS_KEY_ID", "testing") - monkeypatch.setenv("AWS_SECRET_ACCESS_KEY", "testing") + _hermetic_aws_env(monkeypatch, tmp_path) with mock_aws(): yield boto3.session.Session(region_name="us-east-1").client("dynamodb") @@ -680,3 +723,64 @@ def test_the_import_bootstrap_covers_both_roots_not_only_src() -> None: f"the bootstrap no longer adds BOTH roots, so the deferred scripts.* import needs " f"PYTHONPATH=. again: {bootstrap!r}" ) + + +def _busy_raised_from(cause: BaseException | None) -> ServiceBusy: + """A `ServiceBusy` raised the way `Store` raises it, `from` ``cause``.""" + try: + try: + if cause is not None: + raise cause + raise ServiceBusy("The service is busy. Retry shortly.") + except ServiceBusy: + raise + except Exception as exc: + raise ServiceBusy("The service is busy. Retry shortly.") from exc + except ServiceBusy as busy: + return busy + + +@pytest.mark.parametrize( + "cause", + [ + EndpointConnectionError(endpoint_url="http://127.0.0.1:1"), + ConnectTimeoutError(endpoint_url="http://127.0.0.1:1"), + HTTPClientError(error="connection reset"), + ], + ids=["endpoint_connection", "connect_timeout", "http_client"], +) +def test_a_service_busy_raised_from_a_connection_failure_is_unreachable(cause: Exception) -> None: + import scripts.seed_demo_tenant as cli + + busy = _busy_raised_from(cause) + assert gate.is_unreachable_failure(busy) is True + assert cli.is_unreachable_failure(busy) is True + + +@pytest.mark.parametrize( + "cause", + [None, ClientError({"Error": {"Code": "ThrottlingException", "Message": "x"}}, "Query")], + ids=["no_cause", "throttle_answer"], +) +def test_a_service_busy_without_a_connection_cause_is_an_answer(cause: Exception | None) -> None: + import scripts.seed_demo_tenant as cli + + busy = _busy_raised_from(cause) + assert gate.is_unreachable_failure(busy) is False + assert cli.is_unreachable_failure(busy) is False + + +def test_a_real_store_against_a_closed_port_raises_service_busy_and_the_gate_skips( + monkeypatch: pytest.MonkeyPatch, tmp_path: Path +) -> None: + """The real `Store` maps the connection error to `ServiceBusy`; the gate still exits 3.""" + _hermetic_aws_env(monkeypatch, tmp_path) + store = gate.build_store(table_prefix="crm-agent-eval", endpoint_url="http://127.0.0.1:1") + with pytest.raises(ServiceBusy) as raised: + store.query_tenant_scan( + sorted(TENANT_SCOPED_TABLES)[0], tenant=gate.CANARY_TENANT, exclusive_start_key=None + ) + assert isinstance(raised.value.__cause__, EndpointConnectionError) + assert gate.main( + ["--table-prefix", "crm-agent-eval", "--endpoint-url", "http://127.0.0.1:1"] + ) == (GATE_SKIP_EXIT_STATUS) diff --git a/tests/unit/test_check_handler_grant_coverage.py b/tests/unit/test_check_handler_grant_coverage.py index 03fcb32..760fcf7 100644 --- a/tests/unit/test_check_handler_grant_coverage.py +++ b/tests/unit/test_check_handler_grant_coverage.py @@ -1360,3 +1360,102 @@ def test_batch_put_items_is_attributed_batch_write_item_only() -> None: """Batched puts are PutRequest entries inside BatchWriteItem; no PutItem is issued.""" method = gate.STORE_METHOD_ACTIONS["batch_put_items"] assert method.actions == frozenset({"dynamodb:BatchWriteItem"}) + + +# --------------------------------------------------------------------------- +# The pagination-cursor key, compared as its own resource. +# --------------------------------------------------------------------------- + +MODULE_TF = REPO_ROOT / "infra" / "modules" / "lambda_action" / "main.tf" +CURSOR_TOOLS = frozenset( + { + "search_opportunities", + "search_accounts", + "list_activities", + "list_audit_records", + "list_proposals", + } +) +_CURSOR_TOOLS_LINE = re.compile(r"^(\s*cursor_tools\s*=\s*)\[[^\]]*\]", re.MULTILINE) + + +def _known_functions(matrix_grants: Any) -> frozenset[str]: + return frozenset(function for function, _table in matrix_grants) + + +def _cursor_findings(analysis: Any, main_tf: Path, known: frozenset[str]) -> list[str]: + kms_enabled = gate.load_kms_enabled_functions(main_tf, known) + cursor_enabled = gate.load_cursor_enabled_functions(main_tf, known) + functions = frozenset(function for function, _table in analysis.derived) + granted = gate.load_module_resource_grants(MODULE_TF, functions, kms_enabled, cursor_enabled) + implied = gate.derive_resource_grants(analysis.derived, kms_enabled, analysis.reached) + return [f for f in gate.compare(implied, granted, "lambda_action module") if "cursor" in f] + + +def _with_cursor_tools(tmp_path: Path, tools: list[str]) -> Path: + infra = tmp_path / "infra" + infra.mkdir() + for path in MAIN_TF.parent.glob("*.tf"): + shutil.copy(path, infra / path.name) + main = infra / "main.tf" + text = main.read_text(encoding="utf-8") + listed = "[" + ", ".join(f'"{tool}"' for tool in tools) + "]" + planted, count = _CURSOR_TOOLS_LINE.subn(lambda m: m.group(1) + listed, text) + assert count == 1 + main.write_text(planted, encoding="utf-8") + return main + + +def test_exactly_the_cursor_tools_hold_the_cursor_key_grant(matrix_grants: Any) -> None: + assert gate.load_cursor_enabled_functions(MAIN_TF, _known_functions(matrix_grants)) == ( + CURSOR_TOOLS + ) + + +def test_exactly_the_cursor_tools_reach_the_codec(analysis: Any) -> None: + implied = gate.derive_resource_grants(analysis.derived, frozenset(), analysis.reached) + users = {f for f, resource in implied if resource == gate.CURSOR_KMS_RESOURCE_KEY} + assert users == CURSOR_TOOLS + for tool in CURSOR_TOOLS: + assert implied[(tool, gate.CURSOR_KMS_RESOURCE_KEY)] == {"kms:Encrypt", "kms:Decrypt"} + + +def test_the_repository_cursor_grant_matches_the_codec_users( + analysis: Any, matrix_grants: Any +) -> None: + assert _cursor_findings(analysis, MAIN_TF, _known_functions(matrix_grants)) == [] + + +def test_a_cursor_grant_on_a_non_cursor_function_is_surplus( + analysis: Any, matrix_grants: Any, tmp_path: Path +) -> None: + main = _with_cursor_tools(tmp_path, [*sorted(CURSOR_TOOLS), "get_account"]) + findings = _cursor_findings(analysis, main, _known_functions(matrix_grants)) + assert findings, "a cursor grant on get_account went unreported" + assert all(f.startswith("SURPLUS GRANT") and " get_account " in f for f in findings), findings + + +def test_a_codec_user_without_the_cursor_grant_is_missing( + analysis: Any, matrix_grants: Any, tmp_path: Path +) -> None: + main = _with_cursor_tools(tmp_path, sorted(CURSOR_TOOLS - {"list_proposals"})) + findings = _cursor_findings(analysis, main, _known_functions(matrix_grants)) + assert findings and all( + f.startswith("MISSING GRANT") and " list_proposals " in f for f in findings + ), findings + + +def test_an_unreadable_cursor_flag_expression_is_refused( + matrix_grants: Any, tmp_path: Path +) -> None: + infra = tmp_path / "infra" + infra.mkdir() + for path in MAIN_TF.parent.glob("*.tf"): + shutil.copy(path, infra / path.name) + main = infra / "main.tf" + text = main.read_text(encoding="utf-8") + old = "cursor_kms_grant_enabled = contains(local.cursor_tools, each.key)" + assert text.count(old) == 1 + main.write_text(text.replace(old, "cursor_kms_grant_enabled = true"), encoding="utf-8") + with pytest.raises(ValueError, match="cursor_kms_grant_enabled"): + gate.load_cursor_enabled_functions(main, _known_functions(matrix_grants)) diff --git a/tests/unit/test_cursor.py b/tests/unit/test_cursor.py new file mode 100644 index 0000000..61f9e78 --- /dev/null +++ b/tests/unit/test_cursor.py @@ -0,0 +1,772 @@ +# SPDX-License-Identifier: MIT +"""Tests for crm.cursor: opaque, caller-bound cursors on the AES-GCM and KMS paths, and their +refusal as a ``cursor`` validation failure at every handler that accepts one. +""" + +from __future__ import annotations + +import base64 +import json +import pathlib +from collections.abc import Iterator +from typing import Any + +import boto3 +import pytest +from botocore.exceptions import ( + ClientError, + ConnectTimeoutError, + EndpointConnectionError, + ReadTimeoutError, +) +from moto import mock_aws + +from crm import cursor as cursor_module +from crm.authz import Identity +from crm.cursor import ( + CURSOR_KMS_KEY_ENV, + CURSOR_MAX_LENGTH, + bound_operation, + decode_cursor, + encode_cursor, + encryption_context, +) +from crm.envelope import IDENTITY_KEY, identity_event +from crm.errors import CrmError, ServiceBusy, ValidationFailed +from crm.handlers import ( + list_activities, + list_audit_records, + list_proposals, + search_accounts, + search_opportunities, +) +from crm.search import search_opportunities as search_opportunities_fn + +pytestmark = pytest.mark.filterwarnings("ignore::DeprecationWarning") + +_TENANT = "demo" +_REP = "rep-1" +_OPERATION = "search_opportunities" +_PAGE_KEY: dict[str, Any] = { + "opportunity_id": {"S": "opp-1"}, + "tenant": {"S": _TENANT}, + "value": {"N": "1000"}, +} + + +def _identity(*, rep_id: str = _REP, tenant: str = _TENANT) -> Identity: + return Identity(rep_id=rep_id, full_visibility=True, tenant=tenant) + + +@pytest.fixture(autouse=True) +def _local_cipher(monkeypatch: pytest.MonkeyPatch) -> None: + """Every test starts on the AES-GCM path, outside a Lambda, unless it opts into KMS.""" + monkeypatch.delenv(CURSOR_KMS_KEY_ENV, raising=False) + monkeypatch.delenv("AWS_LAMBDA_FUNCTION_NAME", raising=False) + + +def _seal_locally(plaintext: bytes, *, identity: Identity, operation: str) -> str: + """Encrypt arbitrary plaintext exactly as the AES-GCM path would, bypassing the shape check.""" + sealed = cursor_module._local_encrypt(plaintext, encryption_context(identity, operation)) + return base64.urlsafe_b64encode(sealed).decode("ascii") + + +def _flip_one_byte(token: str) -> str: + raw = bytearray(base64.urlsafe_b64decode(token.encode("ascii"))) + raw[len(raw) // 2] ^= 0x01 + return base64.urlsafe_b64encode(bytes(raw)).decode("ascii") + + +def _assert_cursor_refusal(exc_info: pytest.ExceptionInfo[ValidationFailed]) -> None: + assert exc_info.value.source == "cursor" + assert exc_info.value.http_status == 400 + assert exc_info.value.message == "The cursor is not valid." + + +# -- AES-GCM path --------------------------------------------------------------------------------- + + +def test_a_cursor_round_trips_for_the_same_caller_and_operation() -> None: + token = encode_cursor(_PAGE_KEY, identity=_identity(), operation=_OPERATION) + + assert token is not None + assert decode_cursor(token, identity=_identity(), operation=_OPERATION) == _PAGE_KEY + + +def test_no_page_key_encodes_to_no_cursor_and_no_cursor_decodes_to_no_page_key() -> None: + assert encode_cursor(None, identity=_identity(), operation=_OPERATION) is None + assert decode_cursor(None, identity=_identity(), operation=_OPERATION) is None + assert decode_cursor("", identity=_identity(), operation=_OPERATION) is None + + +def test_a_cursor_is_url_safe_base64_and_does_not_carry_the_key_in_the_clear() -> None: + token = encode_cursor(_PAGE_KEY, identity=_identity(), operation=_OPERATION) + + assert token is not None + assert set(token) <= set("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=") + raw = base64.urlsafe_b64decode(token.encode("ascii")) + assert b"opp-1" not in raw + assert b"opportunity_id" not in raw + + +def test_two_cursors_for_the_same_key_differ() -> None: + first = encode_cursor(_PAGE_KEY, identity=_identity(), operation=_OPERATION) + second = encode_cursor(_PAGE_KEY, identity=_identity(), operation=_OPERATION) + + assert first != second + + +@pytest.mark.parametrize( + ("identity", "operation"), + [ + (_identity(rep_id="rep-2"), _OPERATION), + (_identity(tenant="eval-other"), _OPERATION), + (_identity(), "search_accounts"), + ], + ids=["other-rep", "other-tenant", "other-operation"], +) +def test_a_cursor_presented_by_another_caller_or_to_another_operation_is_refused( + identity: Identity, operation: str +) -> None: + token = encode_cursor(_PAGE_KEY, identity=_identity(), operation=_OPERATION) + assert token is not None + + with pytest.raises(ValidationFailed) as refused: + decode_cursor(token, identity=identity, operation=operation) + + _assert_cursor_refusal(refused) + + +def test_a_tampered_cursor_is_refused() -> None: + token = encode_cursor(_PAGE_KEY, identity=_identity(), operation=_OPERATION) + assert token is not None + + with pytest.raises(ValidationFailed) as refused: + decode_cursor(_flip_one_byte(token), identity=_identity(), operation=_OPERATION) + + _assert_cursor_refusal(refused) + + +@pytest.mark.parametrize( + "token", + [ + "not-a-valid-cursor!!!", + "abc", + base64.urlsafe_b64encode(b"short").decode("ascii"), + base64.urlsafe_b64encode(json.dumps(_PAGE_KEY).encode("utf-8")).decode("ascii"), + "é" * 8, + "A" * (CURSOR_MAX_LENGTH + 4), + ], + ids=["bad-alphabet", "bad-padding", "too-short", "plaintext-json", "non-ascii", "too-long"], +) +def test_a_malformed_cursor_is_refused(token: str) -> None: + with pytest.raises(ValidationFailed) as refused: + decode_cursor(token, identity=_identity(), operation=_OPERATION) + + _assert_cursor_refusal(refused) + + +@pytest.mark.parametrize( + "plaintext", + [ + b'{"x":"y"}', + b'"just a string"', + b"[]", + b"{}", + b'{"x":{"S":"a","N":"1"}}', + b'{"x":{"M":{}}}', + b'{"x":{"N":1}}', + b"not json", + b"\xff\xfe", + ], + ids=[ + "string-value", + "non-mapping", + "list", + "empty", + "two-type-tags", + "map-type", + "non-string-member", + "not-json", + "not-utf8", + ], +) +def test_a_correctly_sealed_cursor_that_is_not_a_key_attribute_map_is_refused( + plaintext: bytes, +) -> None: + token = _seal_locally(plaintext, identity=_identity(), operation=_OPERATION) + + with pytest.raises(ValidationFailed) as refused: + decode_cursor(token, identity=_identity(), operation=_OPERATION) + + _assert_cursor_refusal(refused) + + +def test_the_local_cipher_being_unavailable_is_a_configuration_error_not_a_cursor_refusal( + monkeypatch: pytest.MonkeyPatch, +) -> None: + import builtins + + token = encode_cursor(_PAGE_KEY, identity=_identity(), operation=_OPERATION) + real_import = builtins.__import__ + + def refuse_cryptography(name: str, *args: Any, **kwargs: Any) -> Any: + if name.startswith("cryptography"): + raise ModuleNotFoundError(name, name=name) + return real_import(name, *args, **kwargs) + + monkeypatch.setattr(builtins, "__import__", refuse_cryptography) + + for call in ( + lambda: encode_cursor(_PAGE_KEY, identity=_identity(), operation=_OPERATION), + lambda: decode_cursor(token, identity=_identity(), operation=_OPERATION), + ): + with pytest.raises(CrmError) as failed: + call() + assert type(failed.value) is CrmError + + +@pytest.mark.parametrize("key_value", [None, ""], ids=["unset", "empty"]) +def test_a_deployed_lambda_without_the_kms_key_refuses_cursors_as_a_configuration_error( + monkeypatch: pytest.MonkeyPatch, key_value: str | None +) -> None: + token = encode_cursor(_PAGE_KEY, identity=_identity(), operation=_OPERATION) + monkeypatch.setenv("AWS_LAMBDA_FUNCTION_NAME", "crm-search_opportunities") + if key_value is not None: + monkeypatch.setenv(CURSOR_KMS_KEY_ENV, key_value) + + for call in ( + lambda: encode_cursor(_PAGE_KEY, identity=_identity(), operation=_OPERATION), + lambda: decode_cursor(token, identity=_identity(), operation=_OPERATION), + ): + with pytest.raises(CrmError) as failed: + call() + assert type(failed.value) is CrmError + assert failed.value.http_status >= 500 + assert CURSOR_KMS_KEY_ENV in str(failed.value.detail) + assert CURSOR_KMS_KEY_ENV not in failed.value.message + + +def test_a_deployed_lambda_with_no_cursor_and_no_page_key_needs_no_cipher( + monkeypatch: pytest.MonkeyPatch, +) -> None: + monkeypatch.setenv("AWS_LAMBDA_FUNCTION_NAME", "crm-search_opportunities") + + assert encode_cursor(None, identity=_identity(), operation=_OPERATION) is None + assert decode_cursor(None, identity=_identity(), operation=_OPERATION) is None + + +def test_a_deployed_lambda_without_the_kms_key_fails_the_handler_as_internal_not_400( + monkeypatch: pytest.MonkeyPatch, +) -> None: + token = encode_cursor(_PAGE_KEY, identity=_identity(), operation=_OPERATION) + monkeypatch.setenv("AWS_LAMBDA_FUNCTION_NAME", "crm-search_opportunities") + + result = search_opportunities.handler(_event({"cursor": token}), store=_SpyStore()) + + assert result["statusCode"] >= 500, result + assert result["error"]["code"] != "validation_failed" + + +# -- a malformed key never reaches DynamoDB ------------------------------------------------------- + + +class _SpyStore: + """A store stand-in that records every attribute access and refuses to serve any of them.""" + + def __init__(self) -> None: + self.calls: list[str] = [] + + def __getattr__(self, name: str) -> Any: + self.calls.append(name) + raise AssertionError(f"store.{name} was reached") + + +def test_a_sealed_string_valued_key_is_refused_before_any_store_call() -> None: + binding = bound_operation(_OPERATION, "gsi_tenant", _TENANT) + token = _seal_locally(b'{"x":"y"}', identity=_identity(), operation=binding) + assert ( + cursor_module._local_decrypt( + base64.urlsafe_b64decode(token), encryption_context(_identity(), binding) + ) + == b'{"x":"y"}' + ) + + spy = _SpyStore() + + with pytest.raises(ValidationFailed) as refused: + search_opportunities_fn(spy, _identity(), cursor=token) # type: ignore[arg-type] + + _assert_cursor_refusal(refused) + assert spy.calls == [] + + +# -- every cursor-accepting handler answers 400, never 502 ---------------------------------------- + + +def _event(arguments: dict[str, Any]) -> dict[str, Any]: + payload = { + "rep_id": _REP, + "book": [], + "full_visibility": True, + "principal_type": "user", + "session_id": "sess-1", + "source": "gateway", + "tenant": _TENANT, + } + return identity_event(IDENTITY_KEY, payload, arguments) + + +@pytest.fixture +def store() -> Iterator[Any]: + from crm.store.keys import tenant_prefixed + from crm.store.provisioning import create_all_tables + from crm.store.store import Store + + with mock_aws(): + client = boto3.client("dynamodb", region_name="us-east-1") + create_all_tables(client) + seeded = Store(client=client) + seeded.put_item( + "opportunities", + { + "opportunity_id": "opp-1", + "tenant": _TENANT, + "account_id": "acct-1", + "owner_rep_id": _REP, + "stage": "Discovery", + "name": "Renewal", + "name_lower": "renewal", + "created_at": "2026-01-01T00:00:00Z", + "tenant_account_id": tenant_prefixed(_TENANT, "acct-1"), + }, + ) + yield seeded + + +_HANDLER_CASES = [ + ("search_opportunities", search_opportunities.handler, {}, "gsi_tenant", _TENANT), + ("search_accounts", search_accounts.handler, {}, "gsi_tenant", _TENANT), + ( + "list_activities", + list_activities.handler, + {"opportunity_id": "opp-1"}, + "gsi_opportunity", + f"{_TENANT}#opp-1", + ), + ("list_audit_records", list_audit_records.handler, {}, "gsi_tenant", _TENANT), + ("list_proposals", list_proposals.handler, {}, "gsi_tenant", _TENANT), +] + + +@pytest.mark.parametrize( + ("operation", "handler", "arguments", "index_name", "partition_value"), + _HANDLER_CASES, + ids=[case[0] for case in _HANDLER_CASES], +) +@pytest.mark.parametrize( + "kind", ["tampered", "foreign-operation", "unbound-operation", "string-valued-key"] +) +def test_every_cursor_accepting_handler_returns_a_cursor_validation_failure( + store: Any, + operation: str, + handler: Any, + arguments: dict[str, Any], + index_name: str, + partition_value: str, + kind: str, +) -> None: + binding = bound_operation(operation, index_name, partition_value) + if kind == "tampered": + issued = encode_cursor(_PAGE_KEY, identity=_identity(), operation=binding) + assert issued is not None + token = _flip_one_byte(issued) + elif kind == "foreign-operation": + foreign = "list_activities" if operation != "list_activities" else "list_proposals" + foreign_binding = bound_operation(foreign, index_name, partition_value) + token = str(encode_cursor(_PAGE_KEY, identity=_identity(), operation=foreign_binding)) + elif kind == "unbound-operation": + token = str(encode_cursor(_PAGE_KEY, identity=_identity(), operation=operation)) + else: + token = _seal_locally(b'{"x":"y"}', identity=_identity(), operation=binding) + + result = handler(_event({**arguments, "cursor": token}), store=store) + + assert result["statusCode"] == 400, result + assert result["error"]["code"] == "validation_failed" + assert result["error"]["source"] == "cursor" + + +# -- KMS path ------------------------------------------------------------------------------------- + + +@pytest.fixture +def kms_key(monkeypatch: pytest.MonkeyPatch) -> Iterator[str]: + """A moto KMS key named by the cursor key variable, with the module client pointed at moto.""" + with mock_aws(): + client = boto3.client("kms", region_name="us-east-1") + key_arn = client.create_key(Description="crm-cursor")["KeyMetadata"]["Arn"] + monkeypatch.setenv(CURSOR_KMS_KEY_ENV, key_arn) + monkeypatch.setattr(cursor_module, "_kms_client", client) + yield key_arn + + +def test_a_kms_cursor_round_trips_for_the_same_caller_and_operation(kms_key: str) -> None: + token = encode_cursor(_PAGE_KEY, identity=_identity(), operation=_OPERATION) + + assert token is not None + assert decode_cursor(token, identity=_identity(), operation=_OPERATION) == _PAGE_KEY + + +def test_a_kms_cursor_is_encrypted_under_the_named_key_with_the_caller_context( + kms_key: str, +) -> None: + token = encode_cursor(_PAGE_KEY, identity=_identity(), operation=_OPERATION) + assert token is not None + blob = base64.urlsafe_b64decode(token.encode("ascii")) + + decrypted = cursor_module._kms_client.decrypt( + CiphertextBlob=blob, EncryptionContext=encryption_context(_identity(), _OPERATION) + ) + + assert decrypted["KeyId"] == kms_key + assert json.loads(decrypted["Plaintext"]) == _PAGE_KEY + + +@pytest.mark.parametrize( + ("identity", "operation"), + [ + (_identity(rep_id="rep-2"), _OPERATION), + (_identity(tenant="eval-other"), _OPERATION), + (_identity(), "list_proposals"), + ], + ids=["other-rep", "other-tenant", "other-operation"], +) +def test_a_kms_cursor_presented_under_another_context_is_refused( + kms_key: str, identity: Identity, operation: str +) -> None: + token = encode_cursor(_PAGE_KEY, identity=_identity(), operation=_OPERATION) + assert token is not None + + with pytest.raises(ValidationFailed) as refused: + decode_cursor(token, identity=identity, operation=operation) + + _assert_cursor_refusal(refused) + + +def test_a_tampered_kms_cursor_is_refused(kms_key: str) -> None: + token = encode_cursor(_PAGE_KEY, identity=_identity(), operation=_OPERATION) + assert token is not None + + with pytest.raises(ValidationFailed) as refused: + decode_cursor(_flip_one_byte(token), identity=_identity(), operation=_OPERATION) + + _assert_cursor_refusal(refused) + + +def test_an_aes_cursor_is_refused_once_the_kms_key_is_configured( + monkeypatch: pytest.MonkeyPatch, +) -> None: + token = encode_cursor(_PAGE_KEY, identity=_identity(), operation=_OPERATION) + assert token is not None + with mock_aws(): + client = boto3.client("kms", region_name="us-east-1") + key_arn = client.create_key(Description="crm-cursor")["KeyMetadata"]["Arn"] + monkeypatch.setenv(CURSOR_KMS_KEY_ENV, key_arn) + monkeypatch.setattr(cursor_module, "_kms_client", client) + + with pytest.raises(ValidationFailed) as refused: + decode_cursor(token, identity=_identity(), operation=_OPERATION) + + _assert_cursor_refusal(refused) + + +class _FailingKms: + """A KMS client whose every call raises the configured exception.""" + + def __init__(self, exc: Exception) -> None: + self._exc = exc + + def encrypt(self, **_: Any) -> Any: + raise self._exc + + def decrypt(self, **_: Any) -> Any: + raise self._exc + + +def _client_error(code: str) -> ClientError: + return ClientError({"Error": {"Code": code, "Message": "x"}}, "Decrypt") + + +_RETRYABLE_KMS_FAILURES = [ + _client_error("ThrottlingException"), + _client_error("KMSInternalException"), + _client_error("DependencyTimeoutException"), + EndpointConnectionError(endpoint_url="https://kms"), + ConnectTimeoutError(endpoint_url="https://kms"), + ReadTimeoutError(endpoint_url="https://kms"), +] +_DEPLOYMENT_KMS_FAILURES = [ + _client_error("DisabledException"), + _client_error("KMSInvalidStateException"), + _client_error("NotFoundException"), + _client_error("AccessDeniedException"), + _client_error("ExpiredTokenException"), +] + + +def _both_directions(token: str) -> list[Any]: + return [ + lambda: encode_cursor(_PAGE_KEY, identity=_identity(), operation=_OPERATION), + lambda: decode_cursor(token, identity=_identity(), operation=_OPERATION), + ] + + +@pytest.mark.parametrize( + "exc", + _RETRYABLE_KMS_FAILURES, + ids=["throttled", "internal", "dependency-timeout", "unreachable", "connect-timeout", "read"], +) +def test_a_transient_kms_failure_is_a_retryable_service_busy( + monkeypatch: pytest.MonkeyPatch, exc: Exception +) -> None: + token = _seal_locally(b"{}", identity=_identity(), operation=_OPERATION) + monkeypatch.setenv(CURSOR_KMS_KEY_ENV, "arn:aws:kms:us-east-1:123456789012:key/k") + monkeypatch.setattr(cursor_module, "_kms_client", _FailingKms(exc)) + + for call in _both_directions(token): + with pytest.raises(ServiceBusy) as failed: + call() + assert failed.value.next_step == "retry_later" + assert failed.value.http_status >= 500 + + +@pytest.mark.parametrize( + "exc", + _DEPLOYMENT_KMS_FAILURES, + ids=["disabled", "invalid-state", "not-found", "access-denied", "expired-token"], +) +def test_a_kms_deployment_fault_is_a_taxonomy_error_neither_400_nor_retryable( + monkeypatch: pytest.MonkeyPatch, exc: Exception +) -> None: + token = _seal_locally(b"{}", identity=_identity(), operation=_OPERATION) + monkeypatch.setenv(CURSOR_KMS_KEY_ENV, "arn:aws:kms:us-east-1:123456789012:key/k") + monkeypatch.setattr(cursor_module, "_kms_client", _FailingKms(exc)) + + for call in _both_directions(token): + with pytest.raises(CrmError) as failed: + call() + assert not isinstance(failed.value, (ValidationFailed, ServiceBusy)) + assert failed.value.http_status >= 500 + + +@pytest.mark.parametrize("code", ["ValidationException", "AccessDeniedException"]) +def test_a_kms_encrypt_refusal_is_a_5xx_never_a_client_error( + monkeypatch: pytest.MonkeyPatch, code: str +) -> None: + monkeypatch.setenv(CURSOR_KMS_KEY_ENV, "arn:aws:kms:us-east-1:123456789012:key/k") + monkeypatch.setattr(cursor_module, "_kms_client", _FailingKms(_client_error(code))) + + with pytest.raises(CrmError) as failed: + encode_cursor(_PAGE_KEY, identity=_identity(), operation=_OPERATION) + + assert failed.value.http_status >= 500 + + +def test_a_kms_decrypt_validation_exception_is_a_5xx_not_a_cursor_refusal( + monkeypatch: pytest.MonkeyPatch, +) -> None: + token = _seal_locally(b"{}", identity=_identity(), operation=_OPERATION) + monkeypatch.setenv(CURSOR_KMS_KEY_ENV, "arn:aws:kms:us-east-1:123456789012:key/k") + monkeypatch.setattr( + cursor_module, "_kms_client", _FailingKms(_client_error("ValidationException")) + ) + + with pytest.raises(CrmError) as failed: + decode_cursor(token, identity=_identity(), operation=_OPERATION) + + assert not isinstance(failed.value, ValidationFailed) + assert failed.value.http_status >= 500 + + +@pytest.mark.parametrize("value", [0, [], {}, False, 7, ["c"]], ids=repr) +def test_a_non_string_cursor_is_refused_even_when_falsy(value: object) -> None: + with pytest.raises(ValidationFailed) as refused: + decode_cursor(value, identity=_identity(), operation=_OPERATION) # type: ignore[arg-type] + + _assert_cursor_refusal(refused) + + +def test_a_kms_encrypt_failure_fails_the_search_rather_than_dropping_the_cursor( + monkeypatch: pytest.MonkeyPatch, +) -> None: + from crm.search import EXAMINATION_BUDGET + + class _FullPageStore: + def query_gsi(self, *_: Any, **kwargs: Any) -> Any: + rows = [ + {"opportunity_id": f"opp-{n}", "tenant": _TENANT, "account_id": "acct-1"} + for n in range(int(kwargs["limit"])) + ] + return rows, {"opportunity_id": {"S": "opp-last"}, "tenant": {"S": _TENANT}} + + monkeypatch.setenv(CURSOR_KMS_KEY_ENV, "arn:aws:kms:us-east-1:123456789012:key/k") + monkeypatch.setattr( + cursor_module, "_kms_client", _FailingKms(_client_error("ThrottlingException")) + ) + + with pytest.raises(ServiceBusy): + search_opportunities_fn(_FullPageStore(), _identity()) # type: ignore[arg-type] + assert EXAMINATION_BUDGET > 0 + + +def test_a_kms_client_that_cannot_be_built_is_a_configuration_error( + monkeypatch: pytest.MonkeyPatch, +) -> None: + from botocore.exceptions import NoRegionError + + def no_region(*_: Any, **__: Any) -> Any: + raise NoRegionError() + + monkeypatch.setenv(CURSOR_KMS_KEY_ENV, "arn:aws:kms:us-east-1:123456789012:key/k") + monkeypatch.setattr(cursor_module, "_kms_client", None) + monkeypatch.setattr(boto3, "client", no_region) + + with pytest.raises(CrmError) as failed: + encode_cursor(_PAGE_KEY, identity=_identity(), operation=_OPERATION) + + assert type(failed.value) is CrmError + assert "region" not in failed.value.message.lower() + + +def test_the_cursor_module_imports_only_what_every_action_zip_carries() -> None: + import ast + + source = pathlib.Path(cursor_module.__file__).read_text(encoding="utf-8") + roots: set[str] = set() + for node in ast.walk(ast.parse(source)): + if isinstance(node, ast.Import): + roots.update(alias.name.split(".")[0] for alias in node.names) + elif isinstance(node, ast.ImportFrom) and node.module and not node.level: + roots.add(node.module.split(".")[0]) + if node.module.startswith("crm."): + roots.add(node.module) + first_party = {root for root in roots if root.startswith("crm.")} + + assert first_party <= {"crm.authz", "crm.errors"}, first_party + assert "yaml" not in roots + assert roots - {"crm", "__future__"} - first_party <= { + "base64", + "binascii", + "json", + "os", + "threading", + "collections", + "typing", + "botocore", + "boto3", + "cryptography", + }, roots + + +def test_kms_rejecting_the_ciphertext_is_a_cursor_refusal(monkeypatch: pytest.MonkeyPatch) -> None: + token = _seal_locally(b"{}", identity=_identity(), operation=_OPERATION) + monkeypatch.setenv(CURSOR_KMS_KEY_ENV, "arn:aws:kms:us-east-1:123456789012:key/k") + monkeypatch.setattr( + cursor_module, "_kms_client", _FailingKms(_client_error("InvalidCiphertextException")) + ) + + with pytest.raises(ValidationFailed) as refused: + decode_cursor(token, identity=_identity(), operation=_OPERATION) + + _assert_cursor_refusal(refused) + + +# -- length bound --------------------------------------------------------------------------------- + +#: A page key at the application's field caps: 128-character ids, a long eval tenant, a composite +#: tenant-prefixed key, and a 256-character sort key of four-byte UTF-8 characters. +_LONG_TENANT = "eval-" + "f" * 32 + "-a1r10" +_WORST_CASE_PAGE_KEY: dict[str, Any] = { + "account_id": {"S": "a" * 128}, + "opportunity_id": {"S": "o" * 128}, + "tenant": {"S": _LONG_TENANT}, + "tenant_account_id": {"S": f"{_LONG_TENANT}#{'a' * 128}"}, + "name_lower": {"S": "\U0001f600" * 256}, +} +_WORST_CASE_BINDING = bound_operation( + "search_opportunities", "gsi_account", f"{_LONG_TENANT}#{'a' * 128}" +) + +#: Ciphertext-blob bytes real KMS adds to a symmetric-key plaintext, rounded well above observed. +_KMS_BLOB_OVERHEAD_BOUND = 256 + + +def _worst_identity() -> Identity: + return Identity(rep_id="r" * 128, full_visibility=True, tenant=_LONG_TENANT) + + +def _encoded_length(plaintext_bytes: int) -> int: + return 4 * -(-plaintext_bytes // 3) + + +def _worst_plaintext_bytes() -> int: + return len( + json.dumps( + _WORST_CASE_PAGE_KEY, sort_keys=True, separators=(",", ":"), ensure_ascii=False + ).encode("utf-8") + ) + + +def test_a_worst_case_aes_cursor_fits_the_tool_schema_cap() -> None: + token = encode_cursor( + _WORST_CASE_PAGE_KEY, identity=_worst_identity(), operation=_WORST_CASE_BINDING + ) + + assert token is not None + assert len(token) < CURSOR_MAX_LENGTH == 4000 + assert ( + decode_cursor(token, identity=_worst_identity(), operation=_WORST_CASE_BINDING) + == _WORST_CASE_PAGE_KEY + ) + + +def test_a_worst_case_kms_cursor_fits_the_tool_schema_cap(kms_key: str) -> None: + token = encode_cursor( + _WORST_CASE_PAGE_KEY, identity=_worst_identity(), operation=_WORST_CASE_BINDING + ) + + assert token is not None + assert len(token) < CURSOR_MAX_LENGTH + assert _encoded_length(_worst_plaintext_bytes() + _KMS_BLOB_OVERHEAD_BOUND) < CURSOR_MAX_LENGTH + assert ( + decode_cursor(token, identity=_worst_identity(), operation=_WORST_CASE_BINDING) + == _WORST_CASE_PAGE_KEY + ) + + +def test_a_cursor_that_would_exceed_the_cap_is_never_issued() -> None: + oversized = {"name_lower": {"S": "x" * CURSOR_MAX_LENGTH}} + + with pytest.raises(CrmError) as failed: + encode_cursor(oversized, identity=_identity(), operation=_OPERATION) + + assert not isinstance(failed.value, ValidationFailed) + + +def test_every_cursor_length_cap_is_the_same_value() -> None: + from crm.toolspec import definitions, page_context + + assert CURSOR_MAX_LENGTH == definitions.CURSOR_MAX_LENGTH == page_context.CURSOR_MAX_LENGTH + + +def test_a_real_kms_worst_case_length_cursor_is_accepted_as_page_context() -> None: + from crm.toolspec.page_context import PageDescriptor + + worst = _encoded_length(_worst_plaintext_bytes() + _KMS_BLOB_OVERHEAD_BOUND) + assert worst == 2492 + + descriptor = PageDescriptor(cursor="A" * (worst - 2) + "==", limit=25) + + assert descriptor.cursor is not None + assert len(descriptor.cursor) == worst diff --git a/tests/unit/test_e2e_browser_scaffold.py b/tests/unit/test_e2e_browser_scaffold.py index 776f3e1..7a51b99 100644 --- a/tests/unit/test_e2e_browser_scaffold.py +++ b/tests/unit/test_e2e_browser_scaffold.py @@ -32,7 +32,31 @@ CONFIG = BROWSER_DIR / "playwright.config.ts" GLOBAL_SETUP = BROWSER_DIR / "fixtures" / "globalSetup.ts" AUTH_FIXTURE = BROWSER_DIR / "fixtures" / "auth.ts" +CSP_TRAP_FIXTURE = BROWSER_DIR / "fixtures" / "cspTrap.ts" +SSE_RECORDER_FIXTURE = BROWSER_DIR / "fixtures" / "sseRecorder.ts" + +#: The only fixture files allowed to call `addInitScript`: the CSP violation trap and the SSE frame +#: recorder. Any other fixture, including one added later, is refused it. +INIT_SCRIPT_ALLOWED_FIXTURES: Final = frozenset({CSP_TRAP_FIXTURE.name, SSE_RECORDER_FIXTURE.name}) + +#: Lowercased identifiers naming browser storage or a credential; none may appear in the code of a +#: fixture allowed an init script. +CREDENTIAL_SURFACE_TERMS: Final = ( + "localstorage", + "sessionstorage", + "indexeddb", + "cookie", + "storagestate", + "token", + "credential", + "password", + "secret", + "authorization", + "setextrahttpheaders", + "jwt", +) SIGN_IN_FORM = REPO_ROOT / "frontend" / "src" / "auth" / "SignInForm.tsx" +EVAL_ARTIFACT_LIST = REPO_ROOT / "frontend" / "src" / "pages" / "evals" / "EvalArtifactList.tsx" APP_SHELL = REPO_ROOT / "frontend" / "src" / "AppShell.tsx" SRP_SESSION = REPO_ROOT / "frontend" / "src" / "auth" / "CognitoAuthSession.ts" @@ -482,10 +506,34 @@ def test_journey_08_opens_each_artefact_through_its_presigned_url_popup() -> Non (BROWSER_DIR / "journeys/08-eval-dashboard.spec.ts").read_text(encoding="utf-8") ) assert 'artifactSection.getByRole("link")' not in code - assert 'artifactSection.getByRole("button")' in code assert 'page.waitForEvent("popup")' in code assert "toBe(200)" in code and "artefactContentType(" in code assert "runStubSweep(page)" in code + compact = re.sub(r"\s+", "", code) + assert ( + 'constcontrols=artifactSection.getByRole("button")' + '.and(artifactSection.locator(`:not([data-testid="${MATRIX_DOWNLOAD_TEST_ID}"])`));' + ) in compact, "the popup loop must cover every artefact button except the in-place download" + assert "controls.nth(index)" in code + + +def test_journey_08_excludes_only_the_matrix_download_and_asserts_it_once() -> None: + """The one artefact control that downloads in place is named by the test id the SPA renders, + excluded from journey 08's popup loop, and asserted present exactly once.""" + code = strip_comments( + (BROWSER_DIR / "journeys/08-eval-dashboard.spec.ts").read_text(encoding="utf-8") + ) + compact = re.sub(r"\s+", "", code) + assert 'const MATRIX_DOWNLOAD_TEST_ID = "download-matrix-md";' in code + assert compact.count("MATRIX_DOWNLOAD_TEST_ID") == 3 + assert ( + "constdownloadControl=artifactSection.getByTestId(MATRIX_DOWNLOAD_TEST_ID);" + "awaitexpect(downloadControl," + ) in compact + assert re.search(r"awaitexpect\(downloadControl,[^)]*\)\.toHaveCount\(1\)", compact) + artifact_list = (EVAL_ARTIFACT_LIST).read_text(encoding="utf-8") + assert 'data-testid="download-matrix-md"' in artifact_list + assert "window.location.assign(url)" in artifact_list def test_the_live_start_detector_reads_both_click_forms() -> None: @@ -758,6 +806,44 @@ def test_it_injects_no_token_or_storage_state(self) -> None: "'auth works' from 'auth is absent'." ) + def test_no_fixture_outside_the_allowance_calls_add_init_script(self) -> None: + """Every fixture file, present or added later, is refused `addInitScript` unless it is in + the allowance, and auth.ts is never allowed it.""" + fixtures = typescript_sources(BROWSER_DIR / "fixtures") + names = {path.name for path in fixtures} + assert AUTH_FIXTURE.name in names + assert AUTH_FIXTURE.name not in INIT_SCRIPT_ALLOWED_FIXTURES + assert names >= INIT_SCRIPT_ALLOWED_FIXTURES, "an allowance names no existing fixture" + offenders = [ + path.name + for path in fixtures + if path.name not in INIT_SCRIPT_ALLOWED_FIXTURES + and "addInitScript" in strip_comments(path.read_text(encoding="utf-8")) + ] + assert offenders == [], ( + f"{offenders} call addInitScript, which can seed a credential before the page runs; only " + f"{sorted(INIT_SCRIPT_ALLOWED_FIXTURES)} may." + ) + + def test_the_csp_trap_registers_one_violation_listener(self) -> None: + """The CSP trap's one init script is the `securitypolicyviolation` listener.""" + code = strip_comments(CSP_TRAP_FIXTURE.read_text(encoding="utf-8")) + assert code.count("addInitScript(") == 1 + assert '"securitypolicyviolation"' in code + + @pytest.mark.parametrize("name", sorted(INIT_SCRIPT_ALLOWED_FIXTURES)) + def test_an_init_script_fixture_names_no_storage_or_credential(self, name: str) -> None: + """A fixture allowed an init script names no storage, cookie or credential identifier + anywhere in its code.""" + lowered = strip_comments( + (BROWSER_DIR / "fixtures" / name).read_text(encoding="utf-8") + ).lower() + found = [term for term in CREDENTIAL_SURFACE_TERMS if term in lowered] + assert found == [], ( + f"{name} names {found}; its init script runs in every document before the app, so it " + "must not read or write storage, cookies or credentials." + ) + def test_it_reads_credentials_from_the_environment_and_fails_loudly(self) -> None: source = AUTH_FIXTURE.read_text(encoding="utf-8") assert "CRM_DEMO_USER_PASSWORD" in source, ( diff --git a/tests/unit/test_envelope.py b/tests/unit/test_envelope.py index e49e080..4994714 100644 --- a/tests/unit/test_envelope.py +++ b/tests/unit/test_envelope.py @@ -6,13 +6,17 @@ from __future__ import annotations +import json +from pathlib import Path from typing import Any import pytest +from crm import envelope from crm.authz import DEMO_TENANT from crm.envelope import ( AGENT_IDENTITY_KEY, + API_ALLOWED_CLIENT_IDS_PARAMETER_ENV, CLAIM_BOOK, CLAIM_FULL_VISIBILITY, CLAIM_REP_ID, @@ -24,19 +28,47 @@ split_book, strip_identity, ) -from crm.errors import AuthenticationFailed +from crm.errors import AuthenticationFailed, CrmError +from tests.conftest import ( + RECORDED_EVENT_CLIENT_ID, + SESSION_ALLOWLIST, + TEST_API_CLIENT_ID, + TEST_API_CLIENT_IDS_PARAMETER, + StubAllowlist, +) + +_SPA_CLIENT_ID = TEST_API_CLIENT_ID +_MCP_CLIENT_ID = "mcp-oauth-client-1" def _apigw_event(**claims: Any) -> dict[str, Any]: - """Build an API Gateway event carrying authorizer claims.""" + """Build an API Gateway event carrying the authorizer claims of a SPA ID token.""" return { "requestContext": { "requestId": "req-1", - "authorizer": {"jwt": {"claims": {CLAIM_REP_ID: "rep-1", **claims}}}, + "authorizer": { + "jwt": { + "claims": { + CLAIM_REP_ID: "rep-1", + "token_use": "id", + "aud": _SPA_CLIENT_ID, + **claims, + } + } + }, } } +def _apigw_event_without(*claim_names: str) -> dict[str, Any]: + """Build a SPA ID-token API Gateway event with `claim_names` removed from its claims.""" + event = _apigw_event() + claims = event["requestContext"]["authorizer"]["jwt"]["claims"] + for name in claim_names: + del claims[name] + return event + + def _gateway_event(**overrides: Any) -> dict[str, Any]: """Build a Gateway Lambda-target event with an injected identity.""" identity: dict[str, Any] = { @@ -152,7 +184,9 @@ def test_apigw_rest_authorizer_claims_without_the_jwt_nesting_are_honoured() -> { "requestContext": { "requestId": "req-rest-1", - "authorizer": {"claims": {CLAIM_REP_ID: "rep-1"}}, + "authorizer": { + "claims": {CLAIM_REP_ID: "rep-1", "token_use": "id", "aud": _SPA_CLIENT_ID} + }, } } ) @@ -181,6 +215,277 @@ def test_apigw_event_missing_the_rep_claim_is_rejected() -> None: decode_identity(event) +def test_apigw_access_token_is_matched_on_its_client_id() -> None: + """An access token names its app client in ``client_id``; a listed one decodes.""" + event = _apigw_event_without("aud") + event["requestContext"]["authorizer"]["jwt"]["claims"].update( + {"token_use": "access", "client_id": _SPA_CLIENT_ID} + ) + + assert decode_identity(event).rep_id == "rep-1" + + +def test_the_session_stub_admits_the_shared_test_client_by_default() -> None: + """Without the opt-out, every test decodes against the suite-wide stub parameter.""" + assert envelope._parameter_reader == SESSION_ALLOWLIST.read + + assert decode_identity(_apigw_event()).source == "apigw" + with pytest.raises(AuthenticationFailed): + decode_identity(_apigw_event(aud=_MCP_CLIENT_ID)) + + +_RECORDED_EVENTS = sorted( + (Path(__file__).resolve().parents[1] / "fixtures" / "events").glob("apigw_*.json") +) + + +@pytest.mark.parametrize("path", _RECORDED_EVENTS, ids=lambda path: path.name) +def test_recorded_apigw_events_name_the_client_the_session_stub_admits(path: Path) -> None: + """The recorded events are SPA access tokens whose client id the session stub lists.""" + event = json.loads(path.read_text(encoding="utf-8")) + authorizer = event["requestContext"]["authorizer"] + claims = authorizer["jwt"]["claims"] if "jwt" in authorizer else authorizer["claims"] + + assert (claims["token_use"], claims["client_id"]) == ("access", RECORDED_EVENT_CLIENT_ID) + assert decode_identity(event).source == "apigw" + + +def test_recorded_apigw_events_exist() -> None: + assert len(_RECORDED_EVENTS) >= 2 + + +def test_the_opt_out_replaces_the_session_stub(apigw_client_allowlist: StubAllowlist) -> None: + """With the opt-out, the session stub is neither consulted nor able to admit the request.""" + apigw_client_allowlist.value = "some-other-client" + session_reads_before = list(SESSION_ALLOWLIST.reads) + + with pytest.raises(AuthenticationFailed): + decode_identity(_apigw_event()) + + assert apigw_client_allowlist.reads == [TEST_API_CLIENT_IDS_PARAMETER] + assert SESSION_ALLOWLIST.reads == session_reads_before + + +def test_apigw_allowlist_admits_any_listed_client(apigw_client_allowlist: StubAllowlist) -> None: + """The parameter is a comma-separated list; surrounding whitespace is ignored.""" + apigw_client_allowlist.value = f" other-client , {_SPA_CLIENT_ID} " + + assert decode_identity(_apigw_event()).source == "apigw" + + +@pytest.mark.usefixtures("apigw_client_allowlist") +@pytest.mark.parametrize( + "claims", + [ + {"aud": _MCP_CLIENT_ID}, + {"token_use": "access", "client_id": _MCP_CLIENT_ID}, + {"aud": f"{_SPA_CLIENT_ID},{_MCP_CLIENT_ID}"}, + {"aud": [_SPA_CLIENT_ID]}, + {"aud": ""}, + ], + ids=["id-foreign-aud", "access-foreign-client", "joined-aud", "list-aud", "empty-aud"], +) +def test_apigw_token_for_a_foreign_app_client_is_rejected(claims: dict[str, Any]) -> None: + """A Cognito token issued to another app client of the same pool is refused.""" + with pytest.raises(AuthenticationFailed) as caught: + decode_identity(_apigw_event(**claims)) + + assert caught.value.http_status == 401 + + +@pytest.mark.usefixtures("apigw_client_allowlist") +@pytest.mark.parametrize( + ("token_use", "present_claim"), + [("id", "client_id"), ("access", "aud")], +) +def test_apigw_client_is_read_only_from_the_claim_its_token_use_names( + token_use: str, present_claim: str +) -> None: + """An ID token is matched on ``aud`` and an access token on ``client_id``, never swapped.""" + event = _apigw_event_without("aud") + event["requestContext"]["authorizer"]["jwt"]["claims"].update( + {"token_use": token_use, present_claim: _SPA_CLIENT_ID} + ) + + with pytest.raises(AuthenticationFailed): + decode_identity(event) + + +@pytest.mark.usefixtures("apigw_client_allowlist") +@pytest.mark.parametrize("missing", ["aud", "token_use"]) +def test_apigw_token_missing_its_client_claims_is_rejected(missing: str) -> None: + with pytest.raises(AuthenticationFailed): + decode_identity(_apigw_event_without(missing)) + + +@pytest.mark.usefixtures("apigw_client_allowlist") +@pytest.mark.parametrize("token_use", ["refresh", "ID", ""]) +def test_apigw_token_with_an_unrecognised_token_use_is_rejected(token_use: str) -> None: + with pytest.raises(AuthenticationFailed): + decode_identity(_apigw_event(token_use=token_use)) + + +def test_apigw_allowlist_parameter_is_read_once_per_process( + apigw_client_allowlist: StubAllowlist, +) -> None: + """A second decode in the same process reuses the cached value instead of reading again.""" + decode_identity(_apigw_event()) + decode_identity(_apigw_event()) + with pytest.raises(AuthenticationFailed): + decode_identity(_apigw_event(aud=_MCP_CLIENT_ID)) + + assert apigw_client_allowlist.reads == [TEST_API_CLIENT_IDS_PARAMETER] + + +@pytest.mark.parametrize("value", ["", " , ", " "]) +def test_apigw_empty_allowlist_parameter_is_a_server_error_that_refuses( + apigw_client_allowlist: StubAllowlist, value: str +) -> None: + """A parameter listing no client is a configuration error (5xx), and admits no one.""" + apigw_client_allowlist.value = value + + with pytest.raises(CrmError) as caught: + decode_identity(_apigw_event()) + + assert not isinstance(caught.value, AuthenticationFailed) + assert caught.value.http_status >= 500 + + +def test_apigw_empty_allowlist_parameter_is_not_cached( + apigw_client_allowlist: StubAllowlist, +) -> None: + """An empty value is read again on the next call, so filling the parameter recovers.""" + apigw_client_allowlist.value = " , " + with pytest.raises(CrmError): + decode_identity(_apigw_event()) + + apigw_client_allowlist.value = _SPA_CLIENT_ID + assert decode_identity(_apigw_event()).source == "apigw" + assert apigw_client_allowlist.reads == [TEST_API_CLIENT_IDS_PARAMETER] * 2 + + +@pytest.mark.parametrize("configured", [None, "", " "]) +def test_apigw_unset_parameter_variable_is_a_server_error_with_no_read( + apigw_client_allowlist: StubAllowlist, monkeypatch: pytest.MonkeyPatch, configured: str | None +) -> None: + if configured is None: + monkeypatch.delenv(API_ALLOWED_CLIENT_IDS_PARAMETER_ENV, raising=False) + else: + monkeypatch.setenv(API_ALLOWED_CLIENT_IDS_PARAMETER_ENV, configured) + + with pytest.raises(CrmError) as caught: + decode_identity(_apigw_event()) + + assert not isinstance(caught.value, AuthenticationFailed) + assert caught.value.http_status >= 500 + assert API_ALLOWED_CLIENT_IDS_PARAMETER_ENV in (caught.value.detail or "") + assert apigw_client_allowlist.reads == [] + + +@pytest.mark.parametrize( + "aws_code", + [ + "ThrottlingException", + "AccessDeniedException", + "ExpiredTokenException", + "ParameterNotFound", + "ValidationException", + "InternalServerError", + ], +) +def test_apigw_parameter_read_failure_is_never_a_401_and_is_not_cached( + apigw_client_allowlist: StubAllowlist, monkeypatch: pytest.MonkeyPatch, aws_code: str +) -> None: + """An SSM failure refuses the request as a server error; the next request reads again.""" + from botocore.exceptions import ClientError + + def _failing_read(name: str) -> str: + apigw_client_allowlist.reads.append(name) + raise ClientError({"Error": {"Code": aws_code, "Message": "x"}}, "GetParameter") + + monkeypatch.setattr(envelope, "_parameter_reader", _failing_read) + + with pytest.raises(CrmError) as caught: + decode_identity(_apigw_event()) + + assert not isinstance(caught.value, AuthenticationFailed) + assert caught.value.http_status >= 500 + assert TEST_API_CLIENT_IDS_PARAMETER in (caught.value.detail or "") + + monkeypatch.setattr(envelope, "_parameter_reader", apigw_client_allowlist.read) + assert decode_identity(_apigw_event()).source == "apigw" + assert len(apigw_client_allowlist.reads) == 2 + + +def test_apigw_transport_failure_reading_the_parameter_is_a_server_error( + apigw_client_allowlist: StubAllowlist, monkeypatch: pytest.MonkeyPatch +) -> None: + from botocore.exceptions import EndpointConnectionError + + def _unreachable(_name: str) -> str: + raise EndpointConnectionError(endpoint_url="https://ssm.us-east-1.amazonaws.com") + + monkeypatch.setattr(envelope, "_parameter_reader", _unreachable) + + with pytest.raises(CrmError) as caught: + decode_identity(_apigw_event()) + + assert not isinstance(caught.value, AuthenticationFailed) + assert caught.value.http_status >= 500 + + +def test_apigw_allowlist_is_read_from_ssm_by_the_default_reader( + apigw_client_allowlist: StubAllowlist, monkeypatch: pytest.MonkeyPatch +) -> None: + """The production reader resolves the named String parameter (moto SSM).""" + import boto3 + from moto import mock_aws + + monkeypatch.setenv("AWS_DEFAULT_REGION", "us-east-1") + monkeypatch.setenv("AWS_ACCESS_KEY_ID", "testing") + monkeypatch.setenv("AWS_SECRET_ACCESS_KEY", "testing") + monkeypatch.delenv("AWS_PROFILE", raising=False) + monkeypatch.setattr(envelope, "_parameter_reader", envelope._ssm_parameter_reader) + with mock_aws(): + boto3.client("ssm", region_name="us-east-1").put_parameter( + Name=TEST_API_CLIENT_IDS_PARAMETER, + Value=f"{_SPA_CLIENT_ID},other-client", + Type="String", + ) + assert decode_identity(_apigw_event()).rep_id == "rep-1" + with pytest.raises(AuthenticationFailed): + decode_identity(_apigw_event(aud=_MCP_CLIENT_ID)) + + +def test_apigw_missing_ssm_parameter_is_a_server_error_not_a_401( + apigw_client_allowlist: StubAllowlist, monkeypatch: pytest.MonkeyPatch +) -> None: + from moto import mock_aws + + monkeypatch.setenv("AWS_DEFAULT_REGION", "us-east-1") + monkeypatch.setenv("AWS_ACCESS_KEY_ID", "testing") + monkeypatch.setenv("AWS_SECRET_ACCESS_KEY", "testing") + monkeypatch.delenv("AWS_PROFILE", raising=False) + monkeypatch.setattr(envelope, "_parameter_reader", envelope._ssm_parameter_reader) + with mock_aws(), pytest.raises(CrmError) as caught: + decode_identity(_apigw_event()) + + assert not isinstance(caught.value, AuthenticationFailed) + assert caught.value.http_status >= 500 + + +def test_gateway_and_agent_channels_ignore_the_apigw_allowlist( + apigw_client_allowlist: StubAllowlist, monkeypatch: pytest.MonkeyPatch +) -> None: + """The allowlist binds the ``apigw`` channel only; neither other channel reads it.""" + monkeypatch.delenv(API_ALLOWED_CLIENT_IDS_PARAMETER_ENV, raising=False) + agent_event = {AGENT_IDENTITY_KEY: {"claims": {CLAIM_REP_ID: "rep-2"}, "session_id": "s"}} + + assert decode_identity(_gateway_event()).source == "gateway" + assert decode_identity(agent_event).source == "agent" + assert apigw_client_allowlist.reads == [] + + # -------------------------------------------------------------------------------------- # Agent channel # -------------------------------------------------------------------------------------- diff --git a/tests/unit/test_envelope_groups.py b/tests/unit/test_envelope_groups.py index 4184bbb..43f8747 100644 --- a/tests/unit/test_envelope_groups.py +++ b/tests/unit/test_envelope_groups.py @@ -23,6 +23,7 @@ split_groups, ) from crm.errors import AuthenticationFailed +from tests.conftest import TEST_API_CLIENT_ID _REST_V1_EVENT = ( Path(__file__).resolve().parents[2] @@ -47,7 +48,16 @@ def _http_v2_event(groups: object) -> dict[str, Any]: return { "requestContext": { "requestId": "req-1", - "authorizer": {"jwt": {"claims": {CLAIM_REP_ID: "rep-1", CLAIM_GROUPS: groups}}}, + "authorizer": { + "jwt": { + "claims": { + CLAIM_REP_ID: "rep-1", + CLAIM_GROUPS: groups, + "token_use": "id", + "aud": TEST_API_CLIENT_ID, + } + } + }, } } diff --git a/tests/unit/test_eval_artefacts.py b/tests/unit/test_eval_artefacts.py index d801182..180ad21 100644 --- a/tests/unit/test_eval_artefacts.py +++ b/tests/unit/test_eval_artefacts.py @@ -32,6 +32,7 @@ EVAL_ARTEFACTS_SCOPE, PREFIX_ENV_VAR, ArtefactsConfig, + download_disposition, validate_artefact_key, ) from eval.runs import job_row_id @@ -348,3 +349,192 @@ def test_an_artefact_the_sweep_uploads_is_the_object_artefact_url_signs( status, body = _call(store, _artefact_url(run_id, relative, full=True), s3=s3) assert status == 200, body assert requests.get(body["url"], timeout=10).text == f"uploaded {relative}" + + +# -- download disposition ------------------------------------------------------------------------- + + +def _download_url(run_id: str, key: str, download: object, **claims: bool) -> dict[str, Any]: + return _event( + {"action": "artefact_url", "run_id": run_id, "key": key, "download": download}, **claims + ) + + +class TestDownload: + @pytest.mark.parametrize( + ("key", "filename"), + [ + ("matrix.md", "matrix-{run}.md"), + ("matrix.csv", "matrix-{run}.csv"), + (_RAW_KEY, "matrix-{run}.json"), + ], + ) + def test_a_download_url_serves_the_object_as_a_named_attachment( + self, aws: tuple[Store, Any], key: str, filename: str + ) -> None: + store, s3 = aws + run_id = _completed_run(store, s3) + + status, body = _call(store, _download_url(run_id, key, True, full=True), s3=s3) + + assert status == 200, body + expected = f'attachment; filename="{filename.format(run=run_id)}"' + query = parse_qs(urlsplit(body["url"]).query) + assert query["response-content-disposition"] == [expected] + fetched = requests.get(body["url"], timeout=10) + assert fetched.status_code == 200 + assert fetched.headers["Content-Disposition"] == expected + assert fetched.text == f"body of {key}" + + @pytest.mark.parametrize("download", [False, None]) + def test_without_download_the_url_names_no_disposition( + self, aws: tuple[Store, Any], download: object + ) -> None: + store, s3 = aws + run_id = _completed_run(store, s3) + body_args: dict[str, Any] = {"action": "artefact_url", "run_id": run_id, "key": "matrix.md"} + if download is not None: + body_args["download"] = download + status, body = _call(store, _event(body_args, full=True), s3=s3) + assert status == 200, body + assert "response-content-disposition" not in parse_qs(urlsplit(body["url"]).query) + + @pytest.mark.parametrize("download", ["true", 1, None, ["x"]]) + def test_a_non_boolean_download_is_400_before_any_presign( + self, aws: tuple[Store, Any], download: object + ) -> None: + store, s3 = aws + run_id = _completed_run(store, s3) + status, body = _call( + store, _download_url(run_id, "matrix.md", download, full=True), s3=_NeverPresign() + ) + assert status == 400, body + assert body["error"]["source"] == "download" + + def test_a_caller_without_full_visibility_is_403_with_download( + self, aws: tuple[Store, Any] + ) -> None: + store, s3 = aws + run_id = _completed_run(store, s3) + status, body = _call(store, _download_url(run_id, "matrix.md", True), s3=_NeverPresign()) + assert status == 403 + assert body["error"]["missing_scope"] == EVAL_ARTEFACTS_SCOPE + + def test_an_unrecorded_key_is_404_with_download(self, aws: tuple[Store, Any]) -> None: + store, s3 = aws + run_id = _completed_run(store, s3) + status, _body = _call( + store, _download_url(run_id, "other.md", True, full=True), s3=_NeverPresign() + ) + assert status == 404 + + def test_download_is_refused_by_every_other_action(self, aws: tuple[Store, Any]) -> None: + store, s3 = aws + run_id = _completed_run(store, s3) + for body_args in ( + {"action": "status", "run_id": run_id, "download": True}, + {"action": "list", "download": True}, + {"action": "submit", "download": True}, + ): + status, body = _call(store, _event(body_args, full=True), s3=_NeverPresign()) + assert status == 400, (body_args, body) + assert body["error"]["source"] == "arguments" + + +@pytest.mark.parametrize( + ("key", "expected"), + [ + ("matrix.md", 'attachment; filename="matrix-r1.md"'), + ("raw/a.b.json", 'attachment; filename="matrix-r1.json"'), + ("raw/README", 'attachment; filename="matrix-r1"'), + ], +) +def test_download_disposition_names_matrix_run_and_the_key_suffix(key: str, expected: str) -> None: + assert download_disposition("r1", key) == expected + + +# -- the run payload's tier table guard ----------------------------------------------------------- + + +def _tier_record(summary: object) -> runs.RunRecord: + return runs.RunRecord( + run_id="r-guard", + tenant="eval-r-guard", + mode="stub", + status="completed", + started_at="2026-11-06T00:00:00+00:00", + matrix_report={"tier_comparison": summary}, + ) + + +def _unavailable_lines(caplog: pytest.LogCaptureFixture) -> list[dict[str, Any]]: + lines = [] + for record in caplog.records: + try: + parsed = json.loads(record.getMessage()) + except ValueError: + continue + if isinstance(parsed, dict) and parsed.get("event") == "eval_tier_table_unavailable": + lines.append(parsed) + return lines + + +def test_a_summary_the_formatter_refuses_is_omitted_and_logged_with_its_reason( + caplog: pytest.LogCaptureFixture, +) -> None: + caplog.set_level("INFO") + payload = _tier_record({"tiers": {}, "notes": []}).to_payload() + assert "tier_comparison_table" not in payload + assert _unavailable_lines(caplog) == [ + { + "event": "eval_tier_table_unavailable", + "correlation_id": "r-guard", + "reason": "tier comparison summary field 'columns' is not a list", + } + ] + + +@pytest.mark.parametrize("bug", [TypeError, KeyError, AttributeError]) +def test_a_formatter_bug_is_not_swallowed( + bug: type[Exception], monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture +) -> None: + def _broken(_summary: object) -> dict[str, object]: + raise bug("formatter bug") + + monkeypatch.setattr(runs, "tier_comparison_table", _broken) + caplog.set_level("INFO") + with pytest.raises(bug): + _tier_record({"columns": [], "tiers": {}, "notes": []}).to_payload() + assert _unavailable_lines(caplog) == [] + + +def _stored_summary() -> dict[str, Any]: + from eval.matrix import build_matrix_result, tier_comparison + + stored: dict[str, Any] = json.loads(json.dumps(tier_comparison(build_matrix_result([])))) + return stored + + +@pytest.mark.parametrize( + ("field", "value", "reason"), + [ + ("model_ids", [1, 2], "has a non-string model id"), + ("model_ids", "not-a-list", "has a non-string model id"), + ("efforts", [{"x": 1}], "has a non-string effort"), + ], +) +def test_a_stored_entry_with_unjoinable_lists_is_refused_as_malformed( + field: str, value: object, reason: str, caplog: pytest.LogCaptureFixture +) -> None: + from eval.matrix import tier_comparison_table + + summary = _stored_summary() + summary["columns"] = [{"label": "anthropic", "mode": "stub"}] + entry: dict[str, Any] = {"model_ids": ["m"], "efforts": ["medium"], field: value} + summary["tiers"] = {tier: [dict(entry)] for tier in ("supervisor", "subagent", "tool")} + with pytest.raises(ValueError, match=reason): + tier_comparison_table(summary) + caplog.set_level("INFO") + assert "tier_comparison_table" not in _tier_record(summary).to_payload() + (line,) = _unavailable_lines(caplog) + assert reason in line["reason"] diff --git a/tests/unit/test_eval_trigger.py b/tests/unit/test_eval_trigger.py index 3c1389e..e566b94 100644 --- a/tests/unit/test_eval_trigger.py +++ b/tests/unit/test_eval_trigger.py @@ -36,6 +36,7 @@ from eval.tenancy import ( tenant_for_run, ) +from tests.conftest import TEST_API_CLIENT_ID @pytest.fixture @@ -97,11 +98,11 @@ def test_no_public_function_accepts_a_provider_selecting_parameter(forbidden: st def test_the_handler_recognises_exactly_its_arguments() -> None: - """`mode` is for `submit` only, `repeats` for `submit` and `estimate` only, and `key` for - `artefact_url` only (`test_eval_artefacts.py`).""" - assert frozenset({"action", "run_id", "mode", "confirmed", "cursor", "key", "repeats"}) == ( - handler_module._RECOGNISED_ARGUMENTS - ) + """`mode` is for `submit` only, `repeats` for `submit` and `estimate` only, and `key` and + `download` for `artefact_url` only (`test_eval_artefacts.py`).""" + assert frozenset( + {"action", "run_id", "mode", "confirmed", "cursor", "key", "repeats", "download"} + ) == (handler_module._RECOGNISED_ARGUMENTS) def test_job_row_id_refuses_an_already_prefixed_id() -> None: @@ -298,7 +299,9 @@ def test_the_proxy_channel_returns_a_json_string_body( "version": "2.0", "routeKey": "POST /evals", "requestContext": { - "authorizer": {"jwt": {"claims": _admin_claims()}}, + "authorizer": { + "jwt": {"claims": {**_admin_claims(), "token_use": "id", "aud": TEST_API_CLIENT_ID}} + }, "http": {"method": "POST"}, }, "body": json.dumps({"action": "submit"}), @@ -318,7 +321,16 @@ def test_a_proxy_denial_carries_the_errors_own_status(store: Store) -> None: "version": "2.0", "routeKey": "POST /evals", "requestContext": { - "authorizer": {"jwt": {"claims": {CLAIM_REP_ID: "rep-brixton", CLAIM_TENANT: "demo"}}}, + "authorizer": { + "jwt": { + "claims": { + CLAIM_REP_ID: "rep-brixton", + CLAIM_TENANT: "demo", + "token_use": "id", + "aud": TEST_API_CLIENT_ID, + } + } + }, "http": {"method": "POST"}, }, "body": json.dumps({"action": "submit"}), @@ -362,3 +374,112 @@ def test_the_handler_reaches_no_agent_registry() -> None: assert "eval_trigger" not in REGISTERED_TOOL_NAMES assert not any("eval" in name for name in REGISTERED_TOOL_NAMES) + + +# -- the tier comparison table on the run payload ------------------------------------------------- + + +def _record(matrix_report: dict[str, Any] | None) -> RunRecord: + return RunRecord( + run_id="r-tier", + tenant="eval-r-tier", + mode="stub", + status="completed", + started_at="2026-11-06T00:00:00+00:00", + matrix_report=matrix_report, + ) + + +def _summary() -> dict[str, object]: + note = "Columns are the sweep's arms in run order." + entry: dict[str, object] = { + "model_ids": ["m"], + "efforts": ["medium"], + "completion": {"passed": 1, "applicable": 2, "rate": 0.5}, + "completion_over_repeats": None, + "accuracy": 0.5, + "cost_withheld_provisional": True, + "cost_per_completed_task": None, + "cost_per_task": None, + "completed_task_latency_ms_p50": None, + "completed_task_latency_ms_p95": None, + "latency_sample_count": None, + "invocation_count": 3, + "input_tokens": 10, + "output_tokens": 2, + "retry_count": None, + } + return { + "columns": [{"label": "anthropic", "mode": "stub"}], + "tiers": { + "supervisor": [{**entry, "budget_exhausted_task_count": 0}], + "subagent": [{**entry, "delegation_outcomes": None}], + "tool": [{**entry, "truncated_task_count": 0}], + }, + "notes": [note], + } + + +def _table_events(caplog: pytest.LogCaptureFixture) -> list[dict[str, Any]]: + events = [] + for record in caplog.records: + try: + parsed = json.loads(record.getMessage()) + except ValueError: + continue + if isinstance(parsed, dict) and parsed.get("event") == "eval_tier_table_unavailable": + events.append(parsed) + return events + + +def test_the_payload_carries_the_tier_table_of_the_stored_summary() -> None: + from eval.matrix import tier_comparison_table + + payload = _record({"tier_comparison": _summary(), "arms": []}).to_payload() + assert payload["tier_comparison_table"] == tier_comparison_table(_summary()) + table = payload["tier_comparison_table"] + assert table["headers"] == ["Metric", "anthropic"] + assert [section["tier"] for section in table["sections"]] == ["supervisor", "subagent", "tool"] + supervisor = {row[0]: row[1:] for row in table["sections"][0]["rows"]} + assert supervisor["Cost per completed task"] == ["withheld"] + assert supervisor["P95 latency per completed task (ms)"] == ["not measured"] + assert payload["matrix"]["tier_comparison"] == _summary() + json.dumps(payload) + + +@pytest.mark.parametrize( + "matrix_report", + [None, {}, {"arms": []}, {"tier_comparison": None}, {"tier_comparison": ["x"]}], + ids=["no-matrix", "empty", "pre-summary", "null-block", "list-block"], +) +def test_a_record_without_a_summary_mapping_omits_the_table( + matrix_report: dict[str, Any] | None, caplog: pytest.LogCaptureFixture +) -> None: + caplog.set_level("INFO") + assert "tier_comparison_table" not in _record(matrix_report).to_payload() + assert _table_events(caplog) == [] + + +@pytest.mark.parametrize( + "corrupt", + [ + lambda s: s.pop("columns"), + lambda s: s["tiers"].pop("tool"), + lambda s: s.update(notes=[7]), + lambda s: s["tiers"]["supervisor"][0].update(model_ids=[1, 2]), + ], + ids=["no-columns", "missing-tier", "non-string-note", "non-string-model"], +) +def test_a_malformed_summary_is_omitted_and_logged_never_raised( + corrupt: Any, caplog: pytest.LogCaptureFixture +) -> None: + summary = _summary() + corrupt(summary) + caplog.set_level("INFO") + payload = _record({"tier_comparison": summary}).to_payload() + assert "tier_comparison_table" not in payload + assert payload["status"] == "completed" + events = _table_events(caplog) + assert len(events) == 1 + assert events[0]["correlation_id"] == "r-tier" + assert set(events[0]) == {"event", "correlation_id", "reason"} diff --git a/tests/unit/test_eval_trigger_authz.py b/tests/unit/test_eval_trigger_authz.py index 46e4f20..1c5dbd7 100644 --- a/tests/unit/test_eval_trigger_authz.py +++ b/tests/unit/test_eval_trigger_authz.py @@ -484,21 +484,23 @@ def _unparseable(*_a: Any, **_k: Any) -> None: raise yaml.YAMLError("bad yaml") monkeypatch.setattr(runs, "load_static_estimate", _unparseable) - status, body = _call(store, sfn, _event({"action": "estimate"})) + status, body = _call(store, sfn, _event({"action": "estimate"}, full=True)) assert status == 500 and body["error"]["code"] == "internal_error" class TestReads: - def test_any_authenticated_user_reads_status_list_and_estimate( + def test_a_full_visibility_user_reads_status_list_and_estimate( self, store: Store, sfn: Sfn ) -> None: _status, run = _call(store, sfn, _event({"action": "submit"}, full=True)) - status, body = _call(store, sfn, _event({"action": "status", "run_id": run["run_id"]})) + status, body = _call( + store, sfn, _event({"action": "status", "run_id": run["run_id"]}, full=True) + ) assert status == 200 and body["run_id"] == run["run_id"] and body["is_terminal"] is False - status, page = _call(store, sfn, _event({"action": "list"})) + status, page = _call(store, sfn, _event({"action": "list"}, full=True)) assert status == 200 and [r["run_id"] for r in page["runs"]] == [run["run_id"]] assert page["next_cursor"] is None - status, estimate = _call(store, sfn, _event({"action": "estimate"})) + status, estimate = _call(store, sfn, _event({"action": "estimate"}, full=True)) assert status == 200 and estimate["basis"] == "static" and estimate["estimate_usd"] > 0 def test_status_reconciles_a_failed_execution(self, store: Store, sfn: Sfn) -> None: @@ -506,16 +508,22 @@ def test_status_reconciles_a_failed_execution(self, store: Store, sfn: Sfn) -> N arn = runs.require_run(store, run["run_id"]).execution_arn assert arn is not None sfn.statuses[arn] = "TIMED_OUT" - _status, body = _call(store, sfn, _event({"action": "status", "run_id": run["run_id"]})) + _status, body = _call( + store, sfn, _event({"action": "status", "run_id": run["run_id"]}, full=True) + ) assert body["status"] == "failed" and body["teardown_status"] == "unknown" assert runs.read_lock(store) is None def test_status_of_an_unknown_run_is_404(self, store: Store, sfn: Sfn) -> None: - assert _call(store, sfn, _event({"action": "status", "run_id": "nope"}))[0] == 404 + assert ( + _call(store, sfn, _event({"action": "status", "run_id": "nope"}, full=True))[0] == 404 + ) def test_the_payload_carries_no_execution_arn_or_account(self, store: Store, sfn: Sfn) -> None: _status, run = _call(store, sfn, _event({"action": "submit"}, full=True)) - _status, body = _call(store, sfn, _event({"action": "status", "run_id": run["run_id"]})) + _status, body = _call( + store, sfn, _event({"action": "status", "run_id": run["run_id"]}, full=True) + ) assert "123456789012" not in json.dumps(body) and "execution_arn" not in body @@ -596,3 +604,104 @@ def _record(service: str, **kwargs: Any) -> _Client: assert built == [ {"service": "stepfunctions", "region_name": resolve_aws_config(validate=False).region} ] + + +def _unlocked_lines(caplog: pytest.LogCaptureFixture) -> list[dict[str, Any]]: + lines = [] + for record in caplog.records: + try: + parsed = json.loads(record.getMessage()) + except ValueError: + continue + if isinstance(parsed, dict) and parsed.get("event") == "eval_run_unlocked": + lines.append(parsed) + return lines + + +class TestUnlockAttribution: + def test_an_admin_release_logs_one_line_naming_the_releasing_rep( + self, store: Store, sfn: Sfn, caplog: pytest.LogCaptureFixture + ) -> None: + _status, run = _call(store, sfn, _event({"action": "submit"}, full=True)) + arn = runs.require_run(store, run["run_id"]).execution_arn + assert arn is not None + sfn.statuses[arn] = "ABORTED" + caplog.set_level("INFO") + status, body = _call(store, sfn, _event({"action": "unlock"}, admin=True, rep="rep-adm")) + assert status == 200 and body["released"] is True + assert _unlocked_lines(caplog) == [ + {"event": "eval_run_unlocked", "rep_id": "rep-adm", "correlation_id": run["run_id"]} + ] + + def test_a_forced_release_fails_the_holder_with_a_summary_naming_the_rep( + self, store: Store, sfn: Sfn, caplog: pytest.LogCaptureFixture + ) -> None: + _status, run = _call(store, sfn, _event({"action": "submit"}, full=True)) + arn = runs.require_run(store, run["run_id"]).execution_arn + assert arn is not None + sfn.statuses[arn] = "PENDING_REDRIVE" + caplog.set_level("INFO") + status, body = _call(store, sfn, _event({"action": "unlock"}, admin=True, rep="rep-adm")) + assert status == 200 and body == {"released": True, "holder_run_id": run["run_id"]} + record = runs.require_run(store, run["run_id"]) + assert record.status == "failed" + assert record.failure_summary == "An administrator (rep rep-adm) released the sweep lock." + assert [line["rep_id"] for line in _unlocked_lines(caplog)] == ["rep-adm"] + + def test_a_refused_or_empty_unlock_logs_no_release( + self, store: Store, sfn: Sfn, caplog: pytest.LogCaptureFixture + ) -> None: + caplog.set_level("INFO") + assert _call(store, sfn, _event({"action": "unlock"}, admin=True))[1]["released"] is False + _call(store, sfn, _event({"action": "submit"}, full=True)) + assert _call(store, sfn, _event({"action": "unlock"}, full=True))[0] == 403 + assert _call(store, sfn, _event({"action": "unlock"}, admin=True))[0] == 409 + assert _unlocked_lines(caplog) == [] + assert runs.read_lock(store) is not None + + +class TestReadScope: + @pytest.mark.parametrize("action", ["estimate", "status", "list"]) + def test_a_book_limited_caller_is_403_eval_trigger( + self, store: Store, sfn: Sfn, action: str + ) -> None: + _status, run = _call(store, sfn, _event({"action": "submit"}, full=True)) + body: dict[str, Any] = {"action": action} + if action == "status": + body["run_id"] = run["run_id"] + status, response = _call(store, sfn, _event(body, rep="rep-book")) + assert status == 403 + assert response["error"]["missing_scope"] == "eval:trigger" + assert run["run_id"] not in json.dumps(response) + + def test_a_book_limited_caller_learns_nothing_about_an_unknown_run( + self, store: Store, sfn: Sfn + ) -> None: + status, response = _call(store, sfn, _event({"action": "status", "run_id": "nope"})) + assert status == 403 and response["error"]["missing_scope"] == "eval:trigger" + + @pytest.mark.parametrize(("admin", "full"), [(True, False), (False, True), (True, True)]) + @pytest.mark.parametrize("action", ["estimate", "status", "list"]) + def test_an_admin_or_full_visibility_caller_still_reads( + self, store: Store, sfn: Sfn, action: str, admin: bool, full: bool + ) -> None: + _status, run = _call(store, sfn, _event({"action": "submit"}, full=True)) + body: dict[str, Any] = {"action": action} + if action == "status": + body["run_id"] = run["run_id"] + status, response = _call(store, sfn, _event(body, admin=admin, full=full)) + assert status == 200, response + + def test_admin_claims_on_the_agent_channel_do_not_grant_reads( + self, store: Store, sfn: Sfn + ) -> None: + event = { + AGENT_IDENTITY_KEY: { + "claims": {CLAIM_REP_ID: "rep-1", CLAIM_TENANT: "demo", CLAIM_GROUPS: ["admin"]}, + "session_id": "s", + }, + "action": "list", + } + response = handler_module.handler(event, None, store=store, sfn=sfn) + assert response["statusCode"] == 403 + assert response["error"]["missing_scope"] == "eval:trigger" diff --git a/tests/unit/test_eval_trigger_repeats.py b/tests/unit/test_eval_trigger_repeats.py index 64ea0c9..0ef2f4e 100644 --- a/tests/unit/test_eval_trigger_repeats.py +++ b/tests/unit/test_eval_trigger_repeats.py @@ -50,13 +50,15 @@ def test_a_stub_submit_records_its_repeats_and_counts_every_item( (row,) = _job_rows(store) stored = store.get_item("eval_runs", {"run_id": str(row["run_id"])}) assert stored is not None and stored["repeats"] == repeats - status, polled = _call(store, sfn, _event({"action": "status", "run_id": run["run_id"]})) + status, polled = _call( + store, sfn, _event({"action": "status", "run_id": run["run_id"]}, full=True) + ) assert status == 200 and polled["repeats"] == repeats def test_the_estimate_scales_with_repeats(store: Store, sfn: Sfn) -> None: - status_one, one = _call(store, sfn, _event({"action": "estimate"})) - status_three, three = _call(store, sfn, _event({"action": "estimate", "repeats": 3})) + status_one, one = _call(store, sfn, _event({"action": "estimate"}, full=True)) + status_three, three = _call(store, sfn, _event({"action": "estimate", "repeats": 3}, full=True)) assert (status_one, status_three) == (200, 200) assert (one["repeats"], three["repeats"]) == (1, 3) assert one["task_count"] == three["task_count"] diff --git a/tests/unit/test_field_length_caps.py b/tests/unit/test_field_length_caps.py new file mode 100644 index 0000000..356ef25 --- /dev/null +++ b/tests/unit/test_field_length_caps.py @@ -0,0 +1,271 @@ +# SPDX-License-Identifier: MIT +"""Free-text length caps: declared in every tool schema and enforced on open field objects. + +Long text (``description``, ``notes``, ``body``, ``reason``) is capped at 4000 characters, cursors +at 4000, the revert reason at the limit revert enforces, every other free-text string at 256. Over-cap values are refused with ``validation_failed`` +naming the field as ``source``; at-cap values are accepted. +""" + +from __future__ import annotations + +import uuid +from collections.abc import Iterator +from typing import Any + +import boto3 +import pytest +from moto import mock_aws + +from crm import audit +from crm.domain.allowlists import validate_field_values +from crm.envelope import IDENTITY_KEY, identity_event +from crm.errors import ValidationFailed +from crm.handlers import ( + create_account, + create_note, + create_opportunity, + log_activity, + submit_proposal, + update_account, + update_opportunity, +) +from crm.store.keys import derive +from crm.store.provisioning import create_all_tables +from crm.store.store import Store +from crm.toolspec.definitions import ( + ALL_TOOLS, + BY_NAME, + CURSOR_MAX_LENGTH, + LONG_TEXT_FIELDS, + LONG_TEXT_MAX_LENGTH, + REVERT_REASON_MAX_LENGTH, + TEXT_MAX_LENGTH, + max_length_for, +) + +pytestmark = pytest.mark.filterwarnings("ignore::DeprecationWarning") + +_TENANT = "demo" +_REP = "rep-1" +_ACCOUNT = "acct-1" +_OPPORTUNITY = "opp-1" +_LONG = LONG_TEXT_MAX_LENGTH +_SHORT = TEXT_MAX_LENGTH + + +@pytest.fixture +def store() -> Iterator[Store]: + with mock_aws(): + client = boto3.client("dynamodb", region_name="us-east-1") + create_all_tables(client) + engine = Store(client=client) + engine.put_item( + "accounts", + derive( + "accounts", + {"account_id": _ACCOUNT, "tenant": _TENANT, "owner_rep_id": _REP, "name": "Acme"}, + ), + ) + engine.put_item( + "opportunities", + derive( + "opportunities", + { + "opportunity_id": _OPPORTUNITY, + "tenant": _TENANT, + "account_id": _ACCOUNT, + "owner_rep_id": _REP, + "name": "Acme Renewal", + "stage": "Discovery", + "created_at": "2026-01-01T00:00:00+00:00", + "updated_at": "2026-01-01T00:00:00+00:00", + }, + ), + ) + yield engine + + +def _call(module: Any, store: Store, args: dict[str, Any]) -> dict[str, Any]: + event = identity_event( + IDENTITY_KEY, + { + "rep_id": _REP, + "book": [_ACCOUNT], + "full_visibility": False, + "principal_type": "user", + "session_id": "sess-1", + "source": "gateway", + "tenant": _TENANT, + }, + {**args, "transaction_key": uuid.uuid4().hex}, + ) + result: dict[str, Any] = module.handler(event, store=store) + return result + + +def _assert_refused(result: dict[str, Any], source: str) -> None: + assert result["statusCode"] == 400, result + assert result["error"]["code"] == "validation_failed", result + assert result["error"]["source"] == source, result + + +def _assert_accepted(result: dict[str, Any]) -> None: + assert result["statusCode"] == 200, result + + +# --- the declared schema ----------------------------------------------------------------------- + + +def _free_text_properties() -> list[tuple[str, str, dict[str, Any]]]: + return [ + (tool.name, name, prop) + for tool in ALL_TOOLS + for name, prop in tool.input_schema["properties"].items() + if isinstance(prop, dict) and prop.get("type") == "string" and "enum" not in prop + ] + + +def _expected_cap(tool_name: str, name: str) -> int: + if name == "transaction_key": + return 128 + if (tool_name, name) == ("revert_audit_record", "reason"): + return REVERT_REASON_MAX_LENGTH + return max_length_for(name) + + +def test_every_free_text_tool_argument_declares_its_class_cap() -> None: + properties = _free_text_properties() + assert properties + for tool_name, name, prop in properties: + assert prop.get("maxLength") == _expected_cap(tool_name, name), (tool_name, name, prop) + + +def test_the_revert_reason_cap_is_the_limit_revert_enforces() -> None: + assert REVERT_REASON_MAX_LENGTH == audit._MAX_REASON_LENGTH + schema = BY_NAME["revert_audit_record"].input_schema["properties"]["reason"] + assert schema["maxLength"] == audit._MAX_REASON_LENGTH + + +def test_the_cap_classes_are_the_decided_values() -> None: + assert (LONG_TEXT_MAX_LENGTH, TEXT_MAX_LENGTH, CURSOR_MAX_LENGTH) == (4000, 256, 4000) + assert {"description", "notes", "body", "reason"} == LONG_TEXT_FIELDS + assert max_length_for("description") == 4000 + assert max_length_for("name") == 256 + assert max_length_for("query") == 256 + assert max_length_for("cursor") == 4000 + + +# --- top-level tool arguments ---------------------------------------------------------------- + + +def test_create_opportunity_refuses_an_over_cap_description(store: Store) -> None: + result = _call( + create_opportunity, + store, + {"account_id": _ACCOUNT, "name": "Deal", "description": "x" * (_LONG + 1)}, + ) + _assert_refused(result, "description") + + +def test_create_opportunity_accepts_an_at_cap_description(store: Store) -> None: + result = _call( + create_opportunity, + store, + {"account_id": _ACCOUNT, "name": "Deal", "description": "x" * _LONG}, + ) + _assert_accepted(result) + + +def test_log_activity_refuses_an_over_cap_body_and_accepts_one_at_cap(store: Store) -> None: + args: dict[str, Any] = { + "opportunity_id": _OPPORTUNITY, + "kind": "call", + "subject": "Check-in", + "occurred_at": "2026-03-01T09:00:00+00:00", + } + _assert_refused(_call(log_activity, store, {**args, "body": "x" * (_LONG + 1)}), "body") + _assert_accepted(_call(log_activity, store, {**args, "body": "x" * _LONG})) + + +def test_create_note_refuses_an_over_cap_body(store: Store) -> None: + result = _call(create_note, store, {"opportunity_id": _OPPORTUNITY, "body": "x" * (_LONG + 1)}) + _assert_refused(result, "body") + + +def test_create_account_refuses_an_over_cap_name_and_accepts_one_at_cap(store: Store) -> None: + _assert_refused(_call(create_account, store, {"name": "x" * (_SHORT + 1)}), "name") + _assert_accepted(_call(create_account, store, {"name": "x" * _SHORT})) + + +def test_submit_proposal_refuses_an_over_cap_reason(store: Store) -> None: + result = _call( + submit_proposal, + store, + { + "target_table": "opportunities", + "target_id": _OPPORTUNITY, + "operation": "update", + "after_payload": {"stage": "Qualification"}, + "reason": "x" * (_LONG + 1), + }, + ) + _assert_refused(result, "reason") + + +# --- open field objects ---------------------------------------------------------------------- + + +def test_update_opportunity_refuses_an_over_cap_description_and_accepts_one_at_cap( + store: Store, +) -> None: + def update(description: str) -> dict[str, Any]: + return _call( + update_opportunity, + store, + {"opportunity_id": _OPPORTUNITY, "fields": {"description": description}}, + ) + + _assert_refused(update("x" * (_LONG + 1)), "description") + _assert_accepted(update("x" * _LONG)) + + +def test_update_account_refuses_an_over_cap_short_field(store: Store) -> None: + result = _call( + update_account, store, {"account_id": _ACCOUNT, "fields": {"website": "x" * (_SHORT + 1)}} + ) + _assert_refused(result, "website") + + +def test_submit_proposal_refuses_an_over_cap_after_payload_field(store: Store) -> None: + result = _call( + submit_proposal, + store, + { + "target_table": "opportunities", + "target_id": _OPPORTUNITY, + "operation": "update", + "after_payload": {"name": "x" * (_SHORT + 1)}, + "reason": "rename", + }, + ) + _assert_refused(result, "name") + + +@pytest.mark.parametrize( + ("table", "field", "cap"), + [ + ("accounts", "notes", 4000), + ("accounts", "name", 256), + ("contacts", "email", 256), + ("opportunities", "description", 4000), + ("activities", "body", 4000), + ("activities", "subject", 256), + ], +) +def test_validate_field_values_caps_each_string_field_by_class( + table: str, field: str, cap: int +) -> None: + validate_field_values(table, {field: "x" * cap}) + with pytest.raises(ValidationFailed) as raised: + validate_field_values(table, {field: "x" * (cap + 1)}) + assert raised.value.source == field diff --git a/tests/unit/test_handler_error_logging.py b/tests/unit/test_handler_error_logging.py new file mode 100644 index 0000000..a470df5 --- /dev/null +++ b/tests/unit/test_handler_error_logging.py @@ -0,0 +1,240 @@ +# SPDX-License-Identifier: MIT +"""Every handler ``CrmError`` is logged as one structured ``crm_error`` line, never with the request. + +Drives real handler entry points (format-1.0 proxy events built from the captured fixture, and the +flat Gateway channel) against a `moto`-mocked DynamoDB, and reads the emitted records with +``caplog``. Asserted: one WARNING ``crm_error`` line per error, ``reason`` is the error code plus its +bounded ``detail``, ``rep_id`` appears only when the identity was decoded, the response is the +error's own API response, and a bearer token carried in the event reaches no log record. +""" + +from __future__ import annotations + +import copy +import json +import logging +from collections.abc import Iterator +from pathlib import Path +from typing import Any + +import boto3 +import pytest +from moto import mock_aws + +from crm.envelope import IDENTITY_KEY, identity_event +from crm.errors import AuthenticationFailed, CrmError, ValidationFailed +from crm.handlers import _common, get_account +from crm.handlers._common import ERROR_LOG_DETAIL_MAX_CHARS, error_response, run_handler +from crm.store.provisioning import create_all_tables +from crm.store.store import Store +from crm.toolspec.definitions import ALL_TOOLS + +pytestmark = pytest.mark.filterwarnings("ignore::DeprecationWarning") + +_V1_EVENT = ( + Path(__file__).resolve().parents[2] + / "tests" + / "fixtures" + / "events" + / "apigw_v1_proxy_post_get_account.json" +) +_FAKE_TOKEN = ( + "eyJhbGciOiJSUzI1NiJ9.ZmFrZS1jbGFpbXMtZm9yLWxvZy10ZXN0.c2lnbmF0dXJlLXNlY3JldA" # gitleaks:allow +) +_OUT_OF_BOOK_ACCOUNT = "acct-eval-smoke-9999" + + +@pytest.fixture +def store() -> Iterator[Store]: + with mock_aws(): + client = boto3.client("dynamodb", region_name="us-east-1") + create_all_tables(client) + yield Store(client=client) + + +@pytest.fixture +def caplog_all(caplog: pytest.LogCaptureFixture) -> pytest.LogCaptureFixture: + caplog.set_level(logging.DEBUG) + return caplog + + +def _v1_event(*, account_id: str, with_claims: bool) -> dict[str, Any]: + event: dict[str, Any] = copy.deepcopy(json.loads(_V1_EVENT.read_text(encoding="utf-8"))) + bearer = f"Bearer {_FAKE_TOKEN}" + event["headers"]["Authorization"] = bearer + event["multiValueHeaders"]["Authorization"] = [bearer] + event["body"] = json.dumps({"account_id": account_id}) + if not with_claims: + event["requestContext"].pop("authorizer", None) + return event + + +def _seed_out_of_book_account(store: Store, tenant: str) -> None: + store.put_item( + "accounts", + { + "account_id": _OUT_OF_BOOK_ACCOUNT, + "tenant": tenant, + "owner_rep_id": "rep-elsewhere", + "name": "Elsewhere", + }, + ) + + +def _claims() -> dict[str, Any]: + claims: dict[str, Any] = json.loads(_V1_EVENT.read_text(encoding="utf-8"))["requestContext"][ + "authorizer" + ]["claims"] + return claims + + +def _crm_error_lines( + caplog: pytest.LogCaptureFixture, +) -> list[tuple[logging.LogRecord, dict[str, Any]]]: + lines = [] + for record in caplog.records: + try: + parsed = json.loads(record.getMessage()) + except ValueError: + continue + if isinstance(parsed, dict) and parsed.get("event") == "crm_error": + lines.append((record, parsed)) + return lines + + +def _assert_token_absent(caplog: pytest.LogCaptureFixture) -> None: + for record in caplog.records: + rendered = record.getMessage() + assert _FAKE_TOKEN not in rendered + assert _FAKE_TOKEN not in repr(record.args) + assert _FAKE_TOKEN not in caplog.text + + +def test_scope_denial_logs_one_line_naming_the_operation_and_rep( + store: Store, caplog_all: pytest.LogCaptureFixture, monkeypatch: pytest.MonkeyPatch +) -> None: + monkeypatch.setenv("CRM_API_ALLOWED_CLIENT_IDS", str(_claims()["client_id"])) + _seed_out_of_book_account(store, str(_claims()["custom:tenant"])) + event = _v1_event(account_id=_OUT_OF_BOOK_ACCOUNT, with_claims=True) + + response = get_account.handler(event, store=store) + + assert response["statusCode"] == 403 + lines = _crm_error_lines(caplog_all) + assert len(lines) == 1 + record, line = lines[0] + assert record.levelno == logging.WARNING + assert record.name == _common.__name__ + assert set(line) == {"event", "reason", "rep_id"} + assert line["reason"].startswith("scope_denied: ") + assert "operation=" in line["reason"] + assert line["rep_id"] == _claims()["custom:rep_id"] + _assert_token_absent(caplog_all) + + +def test_authentication_failure_logs_one_line_without_rep_id( + store: Store, caplog_all: pytest.LogCaptureFixture +) -> None: + event = _v1_event(account_id=_OUT_OF_BOOK_ACCOUNT, with_claims=False) + + response = get_account.handler(event, store=store) + + assert response["statusCode"] == 401 + lines = _crm_error_lines(caplog_all) + assert len(lines) == 1 + record, line = lines[0] + assert record.levelno == logging.WARNING + assert set(line) == {"event", "reason"} + assert line["reason"].startswith("authentication_failed: ") + _assert_token_absent(caplog_all) + + +def test_gateway_channel_denial_is_logged_with_rep_id( + store: Store, caplog_all: pytest.LogCaptureFixture +) -> None: + identity = { + "rep_id": "rep-1", + "book": ["acct-1"], + "full_visibility": False, + "principal_type": "user", + "session_id": "sess-1", + "source": "gateway", + "tenant": "demo", + } + _seed_out_of_book_account(store, "demo") + event = identity_event(IDENTITY_KEY, identity, {"account_id": _OUT_OF_BOOK_ACCOUNT}) + + response = get_account.handler(event, store=store) + + assert response["statusCode"] == 403 + lines = _crm_error_lines(caplog_all) + assert [line for _, line in lines] == [ + {"event": "crm_error", "reason": lines[0][1]["reason"], "rep_id": "rep-1"} + ] + assert "operation=" in lines[0][1]["reason"] + + +def test_successful_call_logs_no_crm_error( + store: Store, caplog_all: pytest.LogCaptureFixture +) -> None: + store.put_item( + "accounts", + {"account_id": "acct-1", "tenant": "demo", "owner_rep_id": "rep-1", "name": "Acme"}, + ) + identity = { + "rep_id": "rep-1", + "book": ["acct-1"], + "full_visibility": False, + "principal_type": "user", + "session_id": "sess-1", + "source": "gateway", + "tenant": "demo", + } + + response = get_account.handler( + identity_event(IDENTITY_KEY, identity, {"account_id": "acct-1"}), store=store + ) + + assert response["statusCode"] == 200 + assert _crm_error_lines(caplog_all) == [] + + +_GET_ACCOUNT_TOOL = next(tool for tool in ALL_TOOLS if tool.name == "get_account") + + +def _gateway_event() -> dict[str, Any]: + identity = { + "rep_id": "rep-1", + "book": ["acct-1"], + "full_visibility": False, + "principal_type": "user", + "session_id": "sess-1", + "source": "gateway", + "tenant": "demo", + } + return identity_event(IDENTITY_KEY, identity, {"account_id": "acct-1"}) + + +@pytest.mark.parametrize( + "error", + [ + ValidationFailed("bad", source="x", detail="d" * (ERROR_LOG_DETAIL_MAX_CHARS + 50)), + AuthenticationFailed("no", detail=None), + CrmError("boom", detail="internal"), + ], + ids=["long-detail", "no-detail", "base"], +) +def test_reason_is_code_and_bounded_detail_and_response_is_unchanged( + caplog_all: pytest.LogCaptureFixture, error: CrmError +) -> None: + def _raise(identity: Any, arguments: Any) -> Any: + raise error + + response = run_handler(_gateway_event(), _raise, tool=_GET_ACCOUNT_TOOL) + + assert response == error_response(error) + lines = _crm_error_lines(caplog_all) + assert len(lines) == 1 + expected_detail = (error.detail or "")[:ERROR_LOG_DETAIL_MAX_CHARS] + assert lines[0][1]["reason"] == f"{error.code}: {expected_detail}" + assert len(lines[0][1]["reason"]) <= len(error.code) + 2 + ERROR_LOG_DETAIL_MAX_CHARS diff --git a/tests/unit/test_handlers_apigw_proxy.py b/tests/unit/test_handlers_apigw_proxy.py index 9da4f3d..34a3e6b 100644 --- a/tests/unit/test_handlers_apigw_proxy.py +++ b/tests/unit/test_handlers_apigw_proxy.py @@ -45,6 +45,7 @@ from crm.store.provisioning import create_all_tables from crm.store.store import Store from crm.toolspec.definitions import ALL_TOOLS +from tests.conftest import RECORDED_EVENT_CLIENT_ID, StubAllowlist pytestmark = pytest.mark.filterwarnings("ignore::DeprecationWarning") @@ -473,3 +474,50 @@ def test_a_format_1_0_envelope_without_an_authorizer_is_a_401_not_an_empty_scope assert response["statusCode"] == 401 assert _decoded_body(response)["error"]["code"] == "authentication_failed" + + +def _claims_of(event: dict[str, Any]) -> dict[str, Any]: + authorizer: dict[str, Any] = event["requestContext"]["authorizer"] + claims: dict[str, Any] = ( + authorizer["jwt"]["claims"] if "jwt" in authorizer else authorizer["claims"] + ) + return claims + + +@pytest.mark.parametrize("fmt", sorted(_ENVELOPE_BUILDERS)) +def test_a_token_issued_to_a_foreign_app_client_is_a_401_through_the_full_handler( + store: Store, apigw_client_allowlist: StubAllowlist, fmt: str +) -> None: + """Only the client claim differs from a served replay, and the proxy response is a 401.""" + _seed_account(store, _IN_BOOK_ACCOUNT) + served = _ENVELOPE_BUILDERS[fmt]({"account_id": _IN_BOOK_ACCOUNT}) + foreign = copy.deepcopy(served) + assert _claims_of(foreign)["client_id"] == RECORDED_EVENT_CLIENT_ID + _claims_of(foreign)["client_id"] = "mcp-oauth-third-party-client" + + assert get_account.handler(served, None, store=store)["statusCode"] == 200 + response = get_account.handler(foreign, None, store=store) + + assert response["statusCode"] == 401 + assert _decoded_body(response)["error"]["code"] == "authentication_failed" + assert apigw_client_allowlist.reads != [] + + +@pytest.mark.parametrize("fmt", sorted(_ENVELOPE_BUILDERS)) +def test_an_id_token_for_a_foreign_audience_is_a_401_through_the_full_handler( + store: Store, apigw_client_allowlist: StubAllowlist, fmt: str +) -> None: + """The same replay as an ID token is served for the admitted audience and refused otherwise.""" + _seed_account(store, _IN_BOOK_ACCOUNT) + served = _ENVELOPE_BUILDERS[fmt]({"account_id": _IN_BOOK_ACCOUNT}) + claims = _claims_of(served) + claims["token_use"] = "id" + claims["aud"] = claims.pop("client_id") + foreign = copy.deepcopy(served) + _claims_of(foreign)["aud"] = "mcp-oauth-third-party-client" + + assert get_account.handler(served, None, store=store)["statusCode"] == 200 + response = get_account.handler(foreign, None, store=store) + + assert response["statusCode"] == 401 + assert _decoded_body(response)["error"]["code"] == "authentication_failed" diff --git a/tests/unit/test_identity_interceptor.py b/tests/unit/test_identity_interceptor.py index 4398b5b..75c8438 100644 --- a/tests/unit/test_identity_interceptor.py +++ b/tests/unit/test_identity_interceptor.py @@ -10,6 +10,7 @@ from __future__ import annotations import json +import logging import time from typing import Any from unittest.mock import patch @@ -568,6 +569,108 @@ def test_denial_never_contains_the_raw_token_text() -> None: assert token not in denial_text +def _assert_denied(result: dict[str, Any]) -> dict[str, Any]: + assert "transformedGatewayRequest" not in result["mcp"] + denial: dict[str, Any] = result["mcp"]["transformedGatewayResponse"]["body"] + assert denial["error"]["code"] == -32001 + assert denial["error"]["message"] == "Authentication failed. Sign in again to continue." + return denial + + +def _event_with_body(body: object, *, token: str | None) -> dict[str, Any]: + headers = {"Authorization": f"Bearer {token}"} if token is not None else {} + return {"mcp": {"gatewayRequest": {"headers": headers, "body": body}}} + + +@pytest.mark.parametrize("body", [[{"method": "tools/list"}], ["tools/call"], "tools/call", 7]) +def test_a_non_object_body_is_denied_even_with_a_valid_token(body: object) -> None: + """A JSON-RPC batch (array) or scalar body is refused before any field of it is read.""" + result = _invoke(_event_with_body(body, token=_sign(_valid_claims())), _config()) + + denial = _assert_denied(result) + assert denial["id"] is None + + +@pytest.mark.parametrize("params", ["x", ["ab"], ["ab", "cd"], 3]) +def test_a_non_object_params_is_denied_even_with_a_valid_token(params: object) -> None: + """`params` that is not an object can carry no `arguments._identity`, so it is refused.""" + body = {"jsonrpc": "2.0", "id": "p-1", "method": "tools/call", "params": params} + + result = _invoke(_event_with_body(body, token=_sign(_valid_claims())), _config()) + + denial = _assert_denied(result) + assert denial["id"] == "p-1" + + +def test_an_absent_params_still_reaches_token_verification() -> None: + """Only a present, non-object `params` is malformed; an omitted one is not denied for shape.""" + body = {"jsonrpc": "2.0", "id": "p-2", "method": "initialize"} + + result = _invoke(_event_with_body(body, token=_sign(_valid_claims())), _config()) + + rewritten = result["mcp"]["transformedGatewayRequest"]["body"] + assert rewritten["params"]["arguments"][IDENTITY_KEY]["rep_id"] == "rep-1" + + +def test_an_unexpected_exception_is_denied_with_one_structured_log_line( + caplog: pytest.LogCaptureFixture, +) -> None: + """Any exception inside the handler becomes a denial, logged without a traceback or token.""" + token = _sign(_valid_claims()) + event = _gateway_request(token=token, arguments={"opportunity_id": "opp-1"}, tool_id="u-1") + + with ( + caplog.at_level(logging.DEBUG, logger="gateway.identity_interceptor"), + patch( + "gateway.identity_interceptor._build_verified_identity", + side_effect=RuntimeError("boom"), + ), + ): + result = _invoke(event, _config()) + + denial = _assert_denied(result) + assert denial["id"] == "u-1" + denied = [ + record + for record in caplog.records + if json.loads(record.getMessage()).get("event") == "gateway_auth_denied" + ] + assert len(denied) == 1 + assert json.loads(denied[0].getMessage())["reason"] == "unexpected_error:RuntimeError" + assert denied[0].exc_info is None + assert all(token not in record.getMessage() for record in caplog.records) + assert "boom" not in caplog.text + + +def test_a_configuration_error_is_denied_and_logs_which_setting_is_wrong( + caplog: pytest.LogCaptureFixture, +) -> None: + """A Lambda with missing configuration fails closed, and the denial names the bad setting.""" + token = _sign(_valid_claims()) + event = _gateway_request(token=token, arguments={}, tool_id="c-1") + + with ( + caplog.at_level(logging.DEBUG, logger="gateway.identity_interceptor"), + patch( + "gateway.identity_interceptor._load_config", + side_effect=InterceptorConfigError("discovery_url must be non-empty"), + ), + ): + result = lambda_handler(event, object()) + + assert _assert_denied(result)["id"] == "c-1" + reasons = [json.loads(record.getMessage())["reason"] for record in caplog.records] + assert reasons == ["config_error:discovery_url must be non-empty"] + assert token not in caplog.text + + +@pytest.mark.parametrize("event", [{}, {"mcp": []}, {"mcp": {"gatewayRequest": "x"}}, []]) +def test_a_malformed_event_envelope_is_denied(event: Any) -> None: + result = _invoke(event, _config()) + + assert _assert_denied(result)["id"] is None + + def test_denial_never_contains_an_account_identifier() -> None: """No account id appears in a user-facing denial, even one taken from the book.""" other_key = rsa.generate_private_key(public_exponent=65537, key_size=2048) diff --git a/tests/unit/test_infra_api.py b/tests/unit/test_infra_api.py index 14158c9..c57634a 100644 --- a/tests/unit/test_infra_api.py +++ b/tests/unit/test_infra_api.py @@ -315,24 +315,142 @@ def test_the_resource_policy_denies_every_other_vpc_endpoint(plan: Plan) -> None assert source_vpce == [VPC_ENDPOINT_ID] -def test_the_audience_regression_is_visible_in_source_not_silently_absent() -> None: - """No `cognito_user_pool_client_ids` variable exists, and `main.tf` discloses the unchecked audience. - - A `COGNITO_USER_POOLS` authorizer does not validate the app-client audience. - """ - module_dir = Path(__file__).resolve().parents[2] / "infra" / "modules" / "api" - variables = (module_dir / "variables.tf").read_text(encoding="utf-8") - assert 'variable "cognito_user_pool_client_ids"' not in variables, ( - "the audience variable is declared again; if the check was restored, update this test — if it " - "was not, an unread input implies an audience check that does not happen" +_INFRA_DIR = Path(__file__).resolve().parents[2] / "infra" +_ALLOWLIST_NAME = "local.api_allowed_client_ids_parameter_name" +_ALLOWLIST_ARN = "local.api_allowed_client_ids_parameter_arn" + + +def _uncommented(path: Path) -> str: + from scripts.hcl_text import blank_comments + + return str(blank_comments(path.read_text(encoding="utf-8"))) + + +def _column0_block(text: str, start: int) -> str: + depth = 0 + for index in range(text.index("{", start), len(text)): + if text[index] == "{": + depth += 1 + elif text[index] == "}": + depth -= 1 + if depth == 0: + return text[start : index + 1] + raise AssertionError(f"unterminated block at offset {start}") + + +def _root_module_calls() -> dict[str, str]: + calls: dict[str, str] = {} + for path in sorted(_INFRA_DIR.glob("*.tf")): + text = _uncommented(path) + for match in re.finditer(r'^module "(\w+)" \{', text, re.MULTILINE): + calls[match.group(1)] = _column0_block(text, match.start()) + return calls + + +def _api_integrated_modules() -> set[str]: + """`lambda_action` (every tool) plus each module the root's `extra_routes` integrates.""" + api = _root_module_calls()["api"] + tools = re.search(r"tool_lambda_invoke_arns\s*=\s*\{[^}]*module\.(\w+)\[name\]", api) + assert tools is not None and tools.group(1) == "lambda_action" + extra = re.search(r"extra_routes\s*=\s*\{(.*?)\n \}", api, re.DOTALL) + assert extra is not None + singletons = set(re.findall(r"invoke_arn\s*=\s*module\.(\w+)\.invoke_arn", extra.group(1))) + assert singletons, "no module behind extra_routes was found" + return {"lambda_action", *singletons} + + +def test_every_api_integrated_lambda_reads_the_client_allowlist_parameter() -> None: + """Each API-integrated function names the parameter and may read exactly that one ARN.""" + from crm.envelope import API_ALLOWED_CLIENT_IDS_PARAMETER_ENV + + calls = _root_module_calls() + modules = _api_integrated_modules() + assert {"lambda_action", "lambda_action_eval_trigger", "lambda_action_capabilities"} <= modules + for name in sorted(modules - {"lambda_action"}): + body = calls[name] + assert re.search( + rf"^\s+{API_ALLOWED_CLIENT_IDS_PARAMETER_ENV}\s*=\s*{re.escape(_ALLOWLIST_NAME)}$", + body, + re.MULTILINE, + ), f"module.{name} does not set {API_ALLOWED_CLIENT_IDS_PARAMETER_ENV}" + assert re.search( + rf"^ config_parameter_arns\s*=\s*\[{re.escape(_ALLOWLIST_ARN)}\]$", body, re.M + ), f"module.{name} is not granted the allowlist parameter" + + +_ROUTED = r"contains\(local\.routed_tool_names, each\.key\)" + + +def test_the_tool_lambdas_get_the_allowlist_only_when_routed() -> None: + """Every routed tool names and may read the parameter; an agent-only tool gets neither.""" + from crm.envelope import API_ALLOWED_CLIENT_IDS_PARAMETER_ENV + + calls = _root_module_calls() + api = calls["api"] + assert re.search(r"for name in local\.routed_tool_names : name => module\.lambda_action", api) + body = calls["lambda_action"] + assert re.search( + rf"^\s+{_ROUTED} \? \{{ {API_ALLOWED_CLIENT_IDS_PARAMETER_ENV} = " + rf"{re.escape(_ALLOWLIST_NAME)} \}} : \{{\}},$", + body, + re.M, + ), "lambda_action's allowlist env entry is not keyed on routed_tool_names" + assert re.search( + rf"^ config_parameter_arns\s*=\s*{_ROUTED} \? \[{re.escape(_ALLOWLIST_ARN)}\] : \[\]$", + body, + re.M, + ), "lambda_action's allowlist grant is not keyed on routed_tool_names" + assert body.count(API_ALLOWED_CLIENT_IDS_PARAMETER_ENV) == 1 + assert body.count(_ALLOWLIST_ARN) == 1 + + +def test_get_page_context_is_the_agent_only_tool_kept_off_the_allowlist() -> None: + text = _uncommented(_INFRA_DIR / "main.tf") + agent_only = re.search(r"^ agent_only_tools\s*=\s*\[(.*)\]$", text, re.M) + routed = re.search(r"^ routed_tool_names\s*=\s*(.+)$", text, re.M) + assert agent_only is not None and re.findall(r'"(\w+)"', agent_only.group(1)) == [ + "get_page_context" + ] + assert routed is not None and routed.group(1) == ( + "[for name in local.tool_names : name if !contains(local.agent_only_tools, name)]" ) - main = (module_dir / "main.tf").read_text(encoding="utf-8") - assert "does not" in main and "audience" in main.lower(), ( - "the module no longer discloses that the app-client audience is unchecked; a regression nobody " - "can read is worse than the regression" + + +def test_no_function_outside_the_api_channel_receives_the_allowlist() -> None: + from crm.envelope import API_ALLOWED_CLIENT_IDS_PARAMETER_ENV + + modules = _api_integrated_modules() + for name, body in _root_module_calls().items(): + if name not in modules: + assert API_ALLOWED_CLIENT_IDS_PARAMETER_ENV not in body, name + assert _ALLOWLIST_ARN not in body, name + + +def test_the_allowlist_parameter_holds_the_spa_client_id_under_the_named_path() -> None: + text = _uncommented(_INFRA_DIR / "main.tf") + match = re.search(r'^resource "aws_ssm_parameter" "api_allowed_client_ids" \{', text, re.M) + assert match is not None + block = _column0_block(text, match.start()) + assert re.search(rf"^ name\s*=\s*{re.escape(_ALLOWLIST_NAME)}$", block, re.M) + assert re.search(r'^ type\s*=\s*"String"$', block, re.M) + assert re.search(r"^ value\s*=\s*module\.cognito\.spa_client_id$", block, re.M) + assert '"data-classification" = "internal"' in block + name = re.search(r'^ api_allowed_client_ids_parameter_name\s*=\s*"(.+)"$', text, re.M) + arn = re.search(r'^ api_allowed_client_ids_parameter_arn\s*=\s*"(.+)"$', text, re.M) + assert name is not None and name.group(1) == "/${local.name_prefix}/api/allowed-client-ids" + assert arn is not None and arn.group(1) == ( + "arn:aws:ssm:${var.aws_region}:${data.aws_caller_identity.current.account_id}:parameter" + "${local.api_allowed_client_ids_parameter_name}" ) +def test_no_function_attribute_references_the_spa_client_id() -> None: + """A Lambda attribute naming `module.cognito.spa_client_id` would cycle through the CDN.""" + for name, body in _root_module_calls().items(): + if name.startswith("lambda_action"): + assert "module.cognito.spa_client_id" not in body, name + + # --------------------------------------------------------------------------- # `GET /api/capabilities`. # --------------------------------------------------------------------------- diff --git a/tests/unit/test_infra_cdn.py b/tests/unit/test_infra_cdn.py index b973248..b6838fd 100644 --- a/tests/unit/test_infra_cdn.py +++ b/tests/unit/test_infra_cdn.py @@ -365,12 +365,12 @@ def test_every_declared_input_is_wired_by_the_root() -> None: assert passed - variables == set(), f"passed by the root but not declared: {passed - variables}" -#: `Managed-SecurityHeadersPolicy`'s data-source reference. -SECURITY_HEADERS_DATA_SOURCE = "data.aws_cloudfront_response_headers_policy.security_headers.id" +#: The module's own response-headers policy: the standard security headers plus an enforced CSP. +SECURITY_HEADERS_POLICY = "aws_cloudfront_response_headers_policy.security_headers.id" -def test_every_behaviour_attaches_the_managed_security_headers_policy() -> None: - """The default behaviour and every ordered behaviour carry the security-headers policy.""" +def test_every_behaviour_attaches_the_modules_security_headers_policy() -> None: + """The default behaviour and every ordered behaviour carry the one CSP-bearing policy.""" text = CLOUDFRONT_TF.read_text(encoding="utf-8") behaviours = _blocks(text, "default_cache_behavior") + _blocks(text, "ordered_cache_behavior") assert len(behaviours) == 3, ( @@ -378,13 +378,14 @@ def test_every_behaviour_attaches_the_managed_security_headers_policy() -> None: ) for body in behaviours: arguments = _arguments(body) - assert arguments.get("response_headers_policy_id") == SECURITY_HEADERS_DATA_SOURCE, ( + assert arguments.get("response_headers_policy_id") == SECURITY_HEADERS_POLICY, ( arguments.get("path_pattern", "default"), arguments.get("response_headers_policy_id"), ) - data = re.search( - r'(?ms)^data\s+"aws_cloudfront_response_headers_policy"\s+"security_headers"\s*\{(.*?)^\}', - text, + policies = re.findall( + r'(?m)^resource\s+"aws_cloudfront_response_headers_policy"\s+"(\w+)"', text + ) + assert policies == ["security_headers"], policies + assert not re.search(r'(?m)^data\s+"aws_cloudfront_response_headers_policy"', text), ( + "a managed response-headers policy is still read; a behaviour takes only one policy" ) - assert data is not None, "the security-headers data source is not declared" - assert _arguments(data.group(1)).get("name") == "Managed-SecurityHeadersPolicy" diff --git a/tests/unit/test_infra_csp.py b/tests/unit/test_infra_csp.py new file mode 100644 index 0000000..63b3010 --- /dev/null +++ b/tests/unit/test_infra_csp.py @@ -0,0 +1,373 @@ +# SPDX-License-Identifier: MIT +"""Plan time: the frontend CDN's response-headers policy enforces the expected +`Content-Security-Policy`, keeps the standard security headers, and allows the SPA's inline +theme-boot script by the hash of the script that `frontend/index.html` actually carries. + +`frontend_cdn` reads live AWS data, so the policy resource, the `locals` block that renders the CSP +and the variables it reads are copied from the committed HCL into a scratch module and planned +offline (`_terraform_fixture`). The script hashes are the root module's own `csp_script_hashes` +expression, evaluated over a copy of `index.html` and compared with the hash a browser computes for +each inline script. Skips when terraform or the cached providers are absent, unless +`CRM_REQUIRE_TERRAFORM=1`. +""" + +from __future__ import annotations + +import base64 +import hashlib +import re +import shutil +from pathlib import Path +from typing import Any, Final + +import pytest +from scripts.hcl_text import blank_comments + +from tests.unit._terraform_fixture import ( + _PROVIDER_BLOCK, + MODULES_DIR, + REPO_ROOT, + REQUIRE_TERRAFORM_ENV_VAR, + Plan, + TerraformError, + plan_directory, + require_terraform, + terraform_unavailable_reason, +) + +MODULE_DIR: Final = MODULES_DIR / "frontend_cdn" +CLOUDFRONT_TF: Final = MODULE_DIR / "cloudfront.tf" +VARIABLES_TF: Final = MODULE_DIR / "variables.tf" +ROOT_TF: Final = REPO_ROOT / "infra" / "main.tf" +INDEX_HTML: Final = REPO_ROOT / "frontend" / "index.html" + +POLICY_HEADER: Final = 'resource "aws_cloudfront_response_headers_policy" "security_headers"' +POLICY_ADDRESS: Final = "module.subject.aws_cloudfront_response_headers_policy.security_headers" +CSP_VARIABLES: Final = ("csp_script_hashes", "csp_connect_src_extra") +EXTRACTED_VARIABLES: Final = ("name_prefix", *CSP_VARIABLES) + +FIXTURE_CONNECT: Final = ( + "https://cognito-idp.us-east-1.amazonaws.com", + "https://fixture-domain.auth.us-east-1.amazoncognito.com", +) + +#: An inline `", re.DOTALL) + + +def _skip_unless_terraform() -> None: + reason = terraform_unavailable_reason() + if reason is not None: + message = f"terraform plan harness unavailable: {reason}" + if require_terraform(): + pytest.fail(f"{message} (and {REQUIRE_TERRAFORM_ENV_VAR}=1 forbids skipping)") + pytest.skip(message) + + +def _csp_hash(script: str) -> str: + digest = hashlib.sha256(script.encode("utf-8")).digest() + return "sha256-" + base64.b64encode(digest).decode("ascii") + + +def _inline_script_hashes(html: str) -> list[str]: + return [_csp_hash(body) for body in _INLINE_SCRIPT.findall(html)] + + +def _hcl_list(values: tuple[str, ...] | list[str]) -> str: + return "[" + ", ".join(f'"{value}"' for value in values) + "]" + + +def _block(text: str, header: str) -> str: + """The one column-0 block starting with `header`, brace-matched.""" + starts = [m.start() for m in re.finditer(rf"(?m)^{re.escape(header)}", text)] + assert len(starts) == 1, f"expected one {header!r} block, got {len(starts)}" + depth = 0 + opened = False + for index in range(starts[0], len(text)): + if text[index] == "{": + depth += 1 + opened = True + elif text[index] == "}": + depth -= 1 + if opened and depth == 0: + return text[starts[0] : index + 1] + raise AssertionError(f"unterminated {header!r}") + + +def _scratch_module_hcl() -> str: + cloudfront = blank_comments(CLOUDFRONT_TF.read_text(encoding="utf-8")) + variables = blank_comments(VARIABLES_TF.read_text(encoding="utf-8")) + blocks = [_block(cloudfront, "locals {"), _block(cloudfront, POLICY_HEADER)] + blocks += [_block(variables, f'variable "{name}"') for name in EXTRACTED_VARIABLES] + text = "\n\n".join(blocks) + "\n" + references = set(re.findall(r"\b(?:data\.)?aws_[a-z0-9_]+\.[a-z0-9_]+", text)) + assert references == set(), f"the extracted blocks reference other resources: {references}" + return text + + +def _bracketed(text: str, start: int) -> str: + """The bracket-balanced `[...]` starting at the first `[` at or after `start`.""" + opening = text.index("[", start) + depth = 0 + for index in range(opening, len(text)): + if text[index] == "[": + depth += 1 + elif text[index] == "]": + depth -= 1 + if depth == 0: + return text[opening : index + 1] + raise AssertionError(f"unbalanced brackets from offset {start}") + + +def _root_script_hashes_expression() -> str: + """The HCL expression the root module passes as `module.frontend_cdn.csp_script_hashes`. + + A `local.` reference is resolved to that local's list expression. + """ + root = blank_comments(ROOT_TF.read_text(encoding="utf-8")) + module = _block(root, 'module "frontend_cdn"') + argument = re.search(r"(?m)^\s*csp_script_hashes\s*=\s*(\S.*)$", module) + assert argument is not None, "the root passes no csp_script_hashes to frontend_cdn" + value = argument.group(1).strip() + reference = re.fullmatch(r"local\.([a-z0-9_]+)", value) + if reference is None: + return _bracketed(module, argument.start(1)) + definitions = list(re.finditer(rf"(?m)^\s*{reference.group(1)}\s*=\s*\[", root)) + assert len(definitions) == 1, f"expected one definition of local.{reference.group(1)}" + return _bracketed(root, definitions[0].start()) + + +def _write_root( + work_dir: Path, + overrides: dict[str, str] | None = None, + *, + index_html: str | None = None, +) -> None: + """Write the fixture root, evaluating the root's hash expression over a copy of `index.html`. + + The copy sits at `/../frontend/index.html`, where the root's `${path.module}/..` + resolves; `index_html` replaces its content. + """ + frontend = work_dir.parent / "frontend" + frontend.mkdir(parents=True, exist_ok=True) + html = INDEX_HTML.read_text(encoding="utf-8") if index_html is None else index_html + (frontend / INDEX_HTML.name).write_text(html, encoding="utf-8") + subject = work_dir / "subject" + subject.mkdir(parents=True, exist_ok=True) + shutil.copyfile(MODULE_DIR / "versions.tf", subject / "versions.tf") + (subject / "policy.tf").write_text(_scratch_module_hcl(), encoding="utf-8") + arguments = { + "name_prefix": '"fixture-"', + "csp_script_hashes": "local.root_csp_script_hashes", + "csp_connect_src_extra": _hcl_list(FIXTURE_CONNECT), + **(overrides or {}), + } + body = "\n".join(f" {key} = {value}" for key, value in arguments.items()) + (work_dir / "main.tf").write_text( + f"{_PROVIDER_BLOCK}\n" + f"locals {{\n root_csp_script_hashes = {_root_script_hashes_expression()}\n}}\n\n" + f'module "subject" {{\n source = "./subject"\n{body}\n}}\n', + encoding="utf-8", + ) + + +def _plan( + work_dir: Path, + overrides: dict[str, str] | None = None, + *, + index_html: str | None = None, +) -> Plan: + _write_root(work_dir / "root", overrides, index_html=index_html) + return plan_directory(work_dir / "root") + + +@pytest.fixture(scope="module") +def plan(tmp_path_factory: pytest.TempPathFactory) -> Plan: + _skip_unless_terraform() + return _plan(tmp_path_factory.mktemp("frontend-csp")) + + +def _headers_config(plan: Plan) -> dict[str, Any]: + configs = plan.after(POLICY_ADDRESS)["security_headers_config"] + assert isinstance(configs, list) and len(configs) == 1, configs + config = configs[0] + assert isinstance(config, dict) + return config + + +def _only(config: dict[str, Any], key: str) -> dict[str, Any]: + entries = config[key] + assert isinstance(entries, list) and len(entries) == 1, (key, entries) + entry = entries[0] + assert isinstance(entry, dict) + return entry + + +def _csp(plan: Plan) -> str: + value = _only(_headers_config(plan), "content_security_policy")["content_security_policy"] + assert isinstance(value, str) + return value + + +def _directives(policy: str) -> dict[str, list[str]]: + parsed: dict[str, list[str]] = {} + for directive in policy.split(";"): + name, *sources = directive.split() + assert name not in parsed, f"directive {name} appears twice" + parsed[name] = sources + return parsed + + +# --------------------------------------------------------------------------- +# The inline script the hash pins. +# --------------------------------------------------------------------------- + + +def test_index_html_carries_exactly_one_inline_script() -> None: + """The control for the hash test: the parser finds the theme-boot script and nothing else.""" + html = INDEX_HTML.read_text(encoding="utf-8") + bodies = _INLINE_SCRIPT.findall(html) + assert len(bodies) == 1, bodies + assert "data-theme" in bodies[0] + attributed = re.findall(r"]*>", html) + assert all(re.search(r"\bsrc=", tag) for tag in attributed), attributed + + +def test_a_changed_inline_script_changes_its_hash() -> None: + """The hash discriminates on the script body, so an edited script no longer matches.""" + html = INDEX_HTML.read_text(encoding="utf-8") + edited = html.replace("data-theme", "data-theme-x", 1) + assert _inline_script_hashes(edited) != _inline_script_hashes(html) + + +def test_the_root_passes_the_hash_expression_or_list_for_csp_script_hashes() -> None: + """The parse finds a list expression for the root's `csp_script_hashes`.""" + expression = _root_script_hashes_expression() + assert expression.startswith("[") and expression.endswith("]"), expression + + +# --------------------------------------------------------------------------- +# The planned policy. +# --------------------------------------------------------------------------- + + +def test_the_planned_csp_is_exactly_the_designed_directive_set(plan: Plan) -> None: + (script_hash,) = _inline_script_hashes(INDEX_HTML.read_text(encoding="utf-8")) + assert _csp(plan) == "; ".join( + [ + "default-src 'self'", + f"script-src 'self' '{script_hash}'", + "style-src 'self' 'unsafe-inline'", + "img-src 'self' data:", + "font-src 'self' data:", + "connect-src 'self' " + " ".join(FIXTURE_CONNECT), + "frame-ancestors 'none'", + "base-uri 'none'", + "object-src 'none'", + "form-action 'self'", + ] + ) + + +def test_the_planned_script_src_allows_the_served_inline_script(plan: Plan) -> None: + hashes = _inline_script_hashes(INDEX_HTML.read_text(encoding="utf-8")) + script_src = _directives(_csp(plan))["script-src"] + for script_hash in hashes: + assert f"'{script_hash}'" in script_src, script_src + + +def test_the_planned_script_hashes_track_an_edited_inline_script(tmp_path: Path) -> None: + """With the root's value evaluated over an edited `index.html`, the plan carries the new hash + and not the old one, so the policy cannot keep allowing a script the page no longer serves.""" + _skip_unless_terraform() + html = INDEX_HTML.read_text(encoding="utf-8") + edited = html.replace('"data-theme", theme', '"data-theme", theme || "light"', 1) + assert edited != html, "the edit did not apply; the control would be vacuous" + script_src = _directives(_csp(_plan(tmp_path, index_html=edited)))["script-src"] + assert [f"'{h}'" for h in _inline_script_hashes(edited)] == script_src[1:], script_src + assert all(f"'{h}'" not in script_src for h in _inline_script_hashes(html)), script_src + + +def test_no_directive_allows_eval_and_only_styles_allow_inline(plan: Plan) -> None: + directives = _directives(_csp(plan)) + assert all("'unsafe-eval'" not in sources for sources in directives.values()), directives + inline = {name for name, sources in directives.items() if "'unsafe-inline'" in sources} + assert inline == {"style-src"}, directives + assert all("*" not in source for sources in directives.values() for source in sources) + + +def test_the_csp_is_enforced_and_overrides_the_origin(plan: Plan) -> None: + """Delivered as `Content-Security-Policy` (the enforcing header), never Report-Only.""" + entry = _only(_headers_config(plan), "content_security_policy") + assert entry["override"] is True + assert "Report-Only" not in CLOUDFRONT_TF.read_text(encoding="utf-8") + + +def test_the_managed_security_headers_are_kept(plan: Plan) -> None: + config = _headers_config(plan) + assert _only(config, "content_type_options")["override"] is True + assert _only(config, "frame_options") == {"frame_option": "DENY", "override": True} + assert _only(config, "referrer_policy") == { + "referrer_policy": "strict-origin-when-cross-origin", + "override": True, + } + assert _only(config, "strict_transport_security") == { + "access_control_max_age_sec": 31536000, + "include_subdomains": False, + "preload": False, + "override": True, + } + xss = _only(config, "xss_protection") + assert (xss["protection"], xss["mode_block"], xss["override"]) == (True, True, True) + + +def test_the_policy_adds_no_cors_or_custom_headers(plan: Plan) -> None: + after = plan.after(POLICY_ADDRESS) + assert not after.get("cors_config"), after.get("cors_config") + assert not after.get("custom_headers_config"), after.get("custom_headers_config") + assert not after.get("remove_headers_config"), after.get("remove_headers_config") + + +def test_the_policy_name_is_prefixed(plan: Plan) -> None: + assert plan.after(POLICY_ADDRESS)["name"] == "fixture-frontend-security-headers" + + +# --------------------------------------------------------------------------- +# Variable contract. +# --------------------------------------------------------------------------- + + +@pytest.mark.parametrize("variable", CSP_VARIABLES) +def test_csp_inputs_have_no_default(variable: str) -> None: + block = _block(blank_comments(VARIABLES_TF.read_text("utf-8")), f'variable "{variable}"') + assert not re.search(r"^\s*default\s*=", block, re.MULTILINE), block + assert re.search(r"^\s*type\s*=\s*list\(string\)\s*$", block, re.MULTILINE), block + + +@pytest.mark.parametrize( + ("variable", "value"), + [ + ("csp_script_hashes", "[\"'sha256-zKvj1tkJ70GikBqJ1UMWp8MS4dUXm9hbi2a8Yo3ItNs='\"]"), + ("csp_script_hashes", '["sha256-short="]'), + ("csp_script_hashes", '["unsafe-inline"]'), + ("csp_connect_src_extra", '["https://*.amazonaws.com"]'), + ("csp_connect_src_extra", '["http://cognito-idp.us-east-1.amazonaws.com"]'), + ("csp_connect_src_extra", '["https://example.test/path"]'), + ("csp_connect_src_extra", '["https://example.test; script-src *"]'), + ("csp_connect_src_extra", '["*"]'), + ], +) +def test_module_validation_rejects(tmp_path: Path, variable: str, value: str) -> None: + _skip_unless_terraform() + with pytest.raises(TerraformError) as raised: + _plan(tmp_path, {variable: value}) + message = str(raised.value) + assert "Invalid value for variable" in message, message + assert variable in message, message + + +def test_module_validation_admits_empty_extras(tmp_path: Path) -> None: + """The control for the rejections: valid shapes plan, and no extra leaves `connect-src 'self'`.""" + _skip_unless_terraform() + planned = _plan(tmp_path, {"csp_connect_src_extra": "[]"}) + assert _directives(_csp(planned))["connect-src"] == ["'self'"] diff --git a/tests/unit/test_infra_cursor_key.py b/tests/unit/test_infra_cursor_key.py new file mode 100644 index 0000000..28ca022 --- /dev/null +++ b/tests/unit/test_infra_cursor_key.py @@ -0,0 +1,699 @@ +# SPDX-License-Identifier: MIT +"""Plan time: the pagination-cursor CMK, its five role grants, and the SPA CSP sources. + +The root's `aws_kms_key.cursor`, its alias and `aws_kms_key_policy.cursor` are planned from their +committed text with every outside reference replaced by a known literal; the `lambda_action` module +is planned whole with the cursor grant on and off. The CSP locals are planned from their committed +text against the real `frontend/index.html`. Which functions receive the key, and which handlers +use the cursor codec, are read from source. Skips when terraform or the cached providers are +absent, unless `CRM_REQUIRE_TERRAFORM=1`. +""" + +from __future__ import annotations + +import ast +import base64 +import hashlib +import json +import re +import shutil +from pathlib import Path +from typing import Any, Final + +import pytest +from scripts.hcl_text import blank_comments, blank_heredoc_bodies, blank_string_literals + +from tests.unit import _eni_function_code_deny as eni_deny +from tests.unit._terraform_fixture import ( + MODULES_DIR, + REPO_ROOT, + REQUIRE_TERRAFORM_ENV_VAR, + Plan, + TerraformError, + plan_root, + require_terraform, + terraform_unavailable_reason, +) + +INFRA: Final = REPO_ROOT / "infra" +MAIN_TF: Final = INFRA / "main.tf" +INDEX_HTML: Final = REPO_ROOT / "frontend" / "index.html" +SRC: Final = REPO_ROOT / "src" +LAMBDA_ACTION: Final = MODULES_DIR / "lambda_action" + +ACCOUNT_ID: Final = "123456789012" +ROOT_ARN: Final = f"arn:aws:iam::{ACCOUNT_ID}:root" +KEY_ARN: Final = f"arn:aws:kms:us-east-1:{ACCOUNT_ID}:key/11111111-2222-3333-4444-5555cccc7777" +PURPOSE_KEY: Final = "kms:EncryptionContext:purpose" +PURPOSE: Final = "crm-cursor" +CONTEXT_KEYS: Final = ("operation", "purpose", "rep_id", "tenant") + +CURSOR_TOOLS: Final = ( + "search_opportunities", + "search_accounts", + "list_activities", + "list_audit_records", + "list_proposals", +) +CURSOR_ROLES: Final = tuple( + f"arn:aws:iam::{ACCOUNT_ID}:role/crm-agent-eval-{tool}-role" for tool in CURSOR_TOOLS +) +OPERATORS: Final = ( + f"arn:aws:iam::{ACCOUNT_ID}:role/fixture-operator", + f"arn:aws:iam::{ACCOUNT_ID}:role/service-role/fixture-second-operator", +) + +KEY_USE_ACTIONS: Final = ( + "kms:Decrypt", + "kms:Encrypt", + "kms:GenerateDataKey*", + "kms:ReEncrypt*", + "kms:CreateGrant", +) +CONTEXT_BOUND_ACTIONS: Final = ( + "kms:Decrypt", + "kms:Encrypt", + "kms:GenerateDataKey*", + "kms:ReEncrypt*", +) +KEY_ADMIN_ACTIONS: Final = ( + "kms:PutKeyPolicy", + "kms:ScheduleKeyDeletion", + "kms:DisableKey", + "kms:RevokeGrant", + "kms:DisableKeyRotation", + "kms:CreateAlias", + "kms:UpdateAlias", + "kms:DeleteAlias", + "kms:TagResource", + "kms:UntagResource", + "kms:UpdateKeyDescription", +) + +KEY: Final = "aws_kms_key.cursor" +ALIAS: Final = "aws_kms_alias.cursor" +KEY_POLICY: Final = "aws_kms_key_policy.cursor" +GRANT: Final = "module.subject.aws_iam_role_policy.dynamodb_kms[0]" +TABLE_KEY_ARN: Final = ( + f"arn:aws:kms:us-east-1:{ACCOUNT_ID}:key/11111111-2222-3333-4444-5555dddd8888" +) +TABLE_KEY_GRANT: Final = { + "dynamodb_kms_key_arn": f'"{TABLE_KEY_ARN}"', + "dynamodb_kms_grant_enabled": "true", +} + + +def _skip_unless_terraform() -> None: + reason = terraform_unavailable_reason() + if reason is not None: + message = f"terraform plan harness unavailable: {reason}" + if require_terraform(): + pytest.fail(f"{message} (and {REQUIRE_TERRAFORM_ENV_VAR}=1 forbids skipping)") + pytest.skip(message) + + +def _code(path: Path) -> str: + return blank_comments(blank_heredoc_bodies(path.read_text(encoding="utf-8"))) + + +def _block(text: str, header: str) -> str: + """The one column-0 block whose first line starts with `header`, brace-matched.""" + lines = text.splitlines(keepends=True) + starts = [i for i, line in enumerate(lines) if line.startswith(header)] + assert len(starts) == 1, f"expected one {header!r} block, got {len(starts)}" + depth = 0 + for offset, line in enumerate(lines[starts[0] :], start=starts[0]): + depth += line.count("{") - line.count("}") + if depth == 0: + return "".join(lines[starts[0] : offset + 1]) + raise AssertionError(f"unterminated {header!r}") + + +def _block_at(text: str, start: int) -> str: + """The brace-matched block whose header line begins at offset `start`.""" + depth = 0 + for index in range(text.index("{", start), len(text)): + if text[index] == "{": + depth += 1 + elif text[index] == "}": + depth -= 1 + if depth == 0: + return text[start : index + 1] + raise AssertionError(f"unterminated block at offset {start}") + + +def _locals_block_defining(text: str, name: str) -> str: + """The one column-0 `locals {` block that defines `name` at two-space indent.""" + blocks = [_block_at(text, match.start()) for match in re.finditer(r"^locals \{", text, re.M)] + found = [b for b in blocks if re.search(rf"^ {re.escape(name)}\s*=", b, re.MULTILINE)] + assert len(found) == 1, f"expected one locals block defining {name!r}, got {len(found)}" + return found[0] + + +def _hcl_list(values: tuple[str, ...] | list[str]) -> str: + return "[" + ", ".join(f'"{v}"' for v in values) + "]" + + +def _substitute(block: str, substitutions: dict[str, str], allowed: set[str]) -> str: + for old, new in substitutions.items(): + assert old in block, ( + f"{old!r} no longer appears in the extracted source; update the fixture" + ) + block = block.replace(old, new) + leftovers = ( + set( + re.findall( + r"\b(?:module|local|var|data|aws_[a-z0-9_]+)\.[a-z_]+", + blank_string_literals(block), + ) + ) + - allowed + ) + assert leftovers == set(), f"unsubstituted references: {sorted(leftovers)}" + return block + + +def _as_set(value: Any) -> frozenset[str]: + return frozenset(value) if isinstance(value, list) else frozenset({value}) + + +# --------------------------------------------------------------------------- +# The root key, alias and key policy, planned from their committed text. +# --------------------------------------------------------------------------- + + +def _root_key_hcl() -> str: + code = _code(MAIN_TF) + blocks = "\n".join( + _block(code, header) + for header in ( + 'resource "aws_kms_key" "cursor"', + 'resource "aws_kms_alias" "cursor"', + 'resource "aws_kms_key_policy" "cursor"', + ) + ) + body = _substitute( + blocks, + { + "local.name_prefix": '"crm-agent-eval"', + "data.aws_caller_identity.current.account_id": f'"{ACCOUNT_ID}"', + "data.aws_iam_session_context.current.issuer_arn": "var.fixture_caller", + "local.cursor_key_principal_arns": _hcl_list(CURSOR_ROLES), + "var.crm_operator_principal_arns": _hcl_list(OPERATORS), + }, + {"var.fixture_caller", "aws_kms_key.cursor"}, + ) + return f'variable "fixture_caller" {{\n type = string\n}}\n\n{body}' + + +def _plan_key(work_dir: Path, caller: str) -> Plan: + work_dir.mkdir(parents=True, exist_ok=True) + (work_dir / "terraform.tfvars").write_text(f'fixture_caller = "{caller}"\n', encoding="utf-8") + return plan_root(work_dir, _root_key_hcl()) + + +@pytest.fixture(scope="module") +def key_plan(tmp_path_factory: pytest.TempPathFactory) -> Plan: + _skip_unless_terraform() + return _plan_key(tmp_path_factory.mktemp("cursor-key"), OPERATORS[0]) + + +def _key_policy_statements(key_plan: Plan) -> dict[str, dict[str, Any]]: + policy = key_plan.after(KEY_POLICY)["policy"] + assert isinstance(policy, str), "the cursor key policy is not rendered at plan time" + statements = json.loads(policy)["Statement"] + by_sid = {s.get("Sid"): s for s in statements} + assert len(by_sid) == len(statements), "duplicate sids" + return by_sid + + +def test_the_key_rotates_and_is_classified(key_plan: Plan) -> None: + key = key_plan.after(KEY) + assert key["enable_key_rotation"] is True + assert key["tags"]["data-classification"] == "internal" + assert key_plan.after(ALIAS)["name"] == "alias/crm-agent-eval-cursor" + + +def test_the_key_policy_has_exactly_the_designed_statements(key_plan: Plan) -> None: + assert list(_key_policy_statements(key_plan)) == [ + "EnableIAMUserPermissions", + "DenyCursorKeyUseOutsidePurpose", + "DenyCursorKeyUnusedOperations", + "DenyKeyUseToNonProjectPrincipals", + "DenyKeyAdministrationToNonOperators", + ] + + +def test_the_only_allow_is_the_account_root(key_plan: Plan) -> None: + allows = [s for s in _key_policy_statements(key_plan).values() if s["Effect"] == "Allow"] + assert allows == [ + { + "Sid": "EnableIAMUserPermissions", + "Effect": "Allow", + "Principal": {"AWS": ROOT_ARN}, + "Action": "kms:*", + "Resource": "*", + } + ] + + +def test_no_wildcard_principal_outside_a_deny(key_plan: Plan) -> None: + for sid, statement in _key_policy_statements(key_plan).items(): + principal = statement.get("Principal") + wildcard = principal == "*" or (isinstance(principal, dict) and "*" in principal.values()) + assert not wildcard or statement["Effect"] == "Deny", sid + + +def test_every_context_bound_action_is_refused_outside_the_cursor_purpose(key_plan: Plan) -> None: + statement = _key_policy_statements(key_plan)["DenyCursorKeyUseOutsidePurpose"] + assert statement["Effect"] == "Deny" + assert statement["Principal"] == "*" + assert _as_set(statement["Action"]) == frozenset(CONTEXT_BOUND_ACTIONS) + assert statement["Resource"] == "*" + assert statement["Condition"] == {"StringNotEquals": {PURPOSE_KEY: PURPOSE}} + + +def test_operations_the_codec_never_calls_are_refused_to_everyone(key_plan: Plan) -> None: + statement = _key_policy_statements(key_plan)["DenyCursorKeyUnusedOperations"] + assert statement["Effect"] == "Deny" + assert statement["Principal"] == "*" + assert _as_set(statement["Action"]) == { + "kms:GenerateDataKey*", + "kms:ReEncrypt*", + "kms:CreateGrant", + } + assert statement["Resource"] == "*" + assert "Condition" not in statement + + +def test_key_use_is_refused_to_everyone_but_the_five_roles_and_the_operators( + key_plan: Plan, +) -> None: + statement = _key_policy_statements(key_plan)["DenyKeyUseToNonProjectPrincipals"] + assert statement["Effect"] == "Deny" + assert statement["Principal"] == "*" + assert _as_set(statement["Action"]) == frozenset(KEY_USE_ACTIONS) + assert statement["Condition"] == { + "ArnNotEquals": {"aws:PrincipalArn": [*CURSOR_ROLES, *OPERATORS]}, + "Bool": {"aws:PrincipalIsAWSService": "false"}, + } + + +def test_key_administration_is_refused_to_everyone_but_operators_and_root(key_plan: Plan) -> None: + statement = _key_policy_statements(key_plan)["DenyKeyAdministrationToNonOperators"] + assert statement["Effect"] == "Deny" + assert statement["Principal"] == "*" + assert _as_set(statement["Action"]) == frozenset(KEY_ADMIN_ACTIONS) + assert statement["Condition"] == {"ArnNotEquals": {"aws:PrincipalArn": [*OPERATORS, ROOT_ARN]}} + + +def test_the_key_policy_keeps_the_lockout_check(key_plan: Plan) -> None: + assert key_plan.after(KEY_POLICY)["bypass_policy_lockout_safety_check"] is False + + +def test_a_caller_that_is_not_an_operator_cannot_plan_the_key_policy(tmp_path: Path) -> None: + _skip_unless_terraform() + with pytest.raises(TerraformError, match="not an operator"): + _plan_key(tmp_path / "root", f"arn:aws:iam::{ACCOUNT_ID}:role/someone-else") + + +def test_the_account_root_cannot_plan_the_key_policy(tmp_path: Path) -> None: + _skip_unless_terraform() + with pytest.raises(TerraformError, match="not an operator"): + _plan_key(tmp_path / "root", ROOT_ARN) + + +# --------------------------------------------------------------------------- +# The `lambda_action` cursor grant. +# --------------------------------------------------------------------------- + + +def _plan_lambda_action(work_dir: Path, extra: dict[str, str]) -> Plan: + work_dir.mkdir(parents=True, exist_ok=True) + function_zip = work_dir / "function.zip" + function_zip.write_bytes(b"") + arguments = { + "source": f'"{LAMBDA_ACTION}"', + "function_name": '"crm-agent-eval-search_accounts"', + "handler": '"crm.handlers.search_accounts.handler"', + "filename": f'"{function_zip}"', + "source_code_hash": '"0000000000000000000000000000000000000000000="', + "reserved_concurrent_executions": "5", + "dynamodb_grants": "[]", + "vpc_subnet_ids": json.dumps(["subnet-fixturezonea", "subnet-fixturezoneb"]), + "vpc_security_group_ids": json.dumps(["sg-fixturelambda"]), + "eni_function_code_deny_policy_arn": f'"{eni_deny.POLICY_ARN}"', + **extra, + } + body = "\n".join(f" {key} = {value}" for key, value in arguments.items()) + return plan_root(work_dir, f'module "subject" {{\n{body}\n}}\n') + + +@pytest.fixture(scope="module") +def granted_plan(tmp_path_factory: pytest.TempPathFactory) -> Plan: + _skip_unless_terraform() + return _plan_lambda_action( + tmp_path_factory.mktemp("cursor-grant"), + { + **TABLE_KEY_GRANT, + "cursor_kms_key_arn": f'"{KEY_ARN}"', + "cursor_kms_grant_enabled": "true", + }, + ) + + +def _grant_statements(plan: Plan) -> dict[str, dict[str, Any]]: + grant = plan.after(GRANT) + assert grant["name"] == "crm-agent-eval-search_accounts-dynamodb-kms" + return {s["Sid"]: s for s in json.loads(grant["policy"])["Statement"]} + + +def test_the_grant_is_encrypt_and_decrypt_on_the_one_key_under_the_cursor_context( + granted_plan: Plan, +) -> None: + statements = _grant_statements(granted_plan) + assert set(statements) == {"DecryptDynamoDbTableKey", "SealPaginationCursors"} + statement = statements["SealPaginationCursors"] + assert statement["Effect"] == "Allow" + assert _as_set(statement["Action"]) == {"kms:Encrypt", "kms:Decrypt"} + assert statement["Resource"] == KEY_ARN + assert statement["Condition"] == { + "StringEquals": {PURPOSE_KEY: PURPOSE}, + "ForAllValues:StringEquals": {"kms:EncryptionContextKeys": list(CONTEXT_KEYS)}, + } + assert statements["DecryptDynamoDbTableKey"]["Resource"] == TABLE_KEY_ARN + + +def test_the_granted_context_keys_are_exactly_the_codecs() -> None: + from crm.authz import Identity + from crm.cursor import encryption_context + + identity = Identity(rep_id="rep-1", tenant="demo") + assert tuple(sorted(encryption_context(identity, "op"))) == CONTEXT_KEYS + + +def test_no_cursor_statement_is_rendered_when_disabled(tmp_path: Path) -> None: + _skip_unless_terraform() + plan = _plan_lambda_action(tmp_path / "root", dict(TABLE_KEY_GRANT)) + assert set(_grant_statements(plan)) == {"DecryptDynamoDbTableKey"} + assert "kms:Encrypt" not in plan.after(GRANT)["policy"] + + +def test_an_enabled_grant_without_a_key_is_refused(tmp_path: Path) -> None: + _skip_unless_terraform() + with pytest.raises(TerraformError, match="cursor_kms_key_arn is null"): + _plan_lambda_action( + tmp_path / "root", {**TABLE_KEY_GRANT, "cursor_kms_grant_enabled": "true"} + ) + + +def test_an_enabled_grant_without_the_table_key_grant_is_refused(tmp_path: Path) -> None: + _skip_unless_terraform() + with pytest.raises(TerraformError, match="requires dynamodb_kms_grant_enabled"): + _plan_lambda_action( + tmp_path / "root", + {"cursor_kms_key_arn": f'"{KEY_ARN}"', "cursor_kms_grant_enabled": "true"}, + ) + + +# --------------------------------------------------------------------------- +# Root wiring, read from source. +# --------------------------------------------------------------------------- + + +def _string_list(expression: str) -> list[str]: + return re.findall(r'"([^"]+)"', expression) + + +def _cursor_locals() -> str: + return _locals_block_defining(_code(MAIN_TF), "cursor_tools") + + +def test_the_cursor_tools_local_names_exactly_the_five_paginating_tools() -> None: + match = re.search(r"^ cursor_tools\s*=\s*(\[[^\]]*\])", _cursor_locals(), re.MULTILINE) + assert match is not None + assert sorted(_string_list(match.group(1))) == sorted(CURSOR_TOOLS) + + +def test_the_key_policy_principals_are_the_five_roles_by_static_index() -> None: + match = re.search( + r"^ cursor_key_principal_arns\s*=\s*\[(.*?)\]\n", _cursor_locals(), re.MULTILINE | re.S + ) + assert match is not None + entries = re.findall(r'module\.lambda_action\["([a-z_]+)"\]\.role_arn', match.group(1)) + assert sorted(entries) == sorted(CURSOR_TOOLS) + assert len(entries) == len([e for e in match.group(1).split(",") if e.strip()]) + + +def _lambda_action_call() -> str: + return _block(_code(MAIN_TF), 'module "lambda_action" {') + + +def test_the_key_arn_and_grant_go_only_to_the_cursor_tools() -> None: + call = _lambda_action_call() + assert re.search( + r"contains\(local\.cursor_tools, each\.key\) \? \{ CRM_CURSOR_KMS_KEY_ARN = " + r"aws_kms_key\.cursor\.arn \} : \{\}", + call, + ), "CRM_CURSOR_KMS_KEY_ARN is not set exactly when the tool is a cursor tool" + assert re.search( + r"^ cursor_kms_key_arn\s*= contains\(local\.cursor_tools, each\.key\) \? " + r"aws_kms_key\.cursor\.arn : null$", + call, + re.MULTILINE, + ) + assert re.search( + r"^ cursor_kms_grant_enabled\s*= contains\(local\.cursor_tools, each\.key\)$", + call, + re.MULTILINE, + ) + assert call.count("CRM_CURSOR_KMS_KEY_ARN") == 1 + + +def test_no_other_module_call_receives_the_cursor_key() -> None: + for path in sorted(INFRA.glob("*.tf")): + code = _code(path) + for match in re.finditer(r'^module "([a-z_]+)" \{', code, re.MULTILINE): + if match.group(1) == "lambda_action": + continue + body = _block_at(code, match.start()) + assert "aws_kms_key.cursor" not in body, f"module.{match.group(1)} in {path.name}" + assert "CRM_CURSOR_KMS_KEY_ARN" not in body, f"module.{match.group(1)} in {path.name}" + + +def _handler_module(tool: str) -> str: + match = re.search( + rf'^\s+{tool}\s*=\s*\{{\s*handler\s*=\s*"([\w.]+)\.handler"', _code(MAIN_TF), re.MULTILINE + ) + assert match is not None, f"no local.tools entry for {tool}" + return match.group(1) + + +def _tool_names() -> list[str]: + tools = _locals_block_defining(_code(MAIN_TF), "tools") + return re.findall(r"^\s{4}([a-z_]+)\s*=\s*\{\s*handler\s*=", tools, re.MULTILINE) + + +def _module_tree(dotted: str) -> ast.Module: + return ast.parse((SRC / Path(*dotted.split("."))).with_suffix(".py").read_text("utf-8")) + + +_CODEC: Final = {"encode_cursor", "decode_cursor"} + + +def _search_functions_using_the_codec() -> set[str]: + """Top-level `crm.search` functions that reach the cursor codec through calls in the module.""" + tree = _module_tree("crm.search") + calls: dict[str, set[str]] = {} + for node in tree.body: + if isinstance(node, ast.FunctionDef): + calls[node.name] = { + n.func.id + for n in ast.walk(node) + if isinstance(n, ast.Call) and isinstance(n.func, ast.Name) + } + users = {name for name, called in calls.items() if called & _CODEC} + while True: + more = {name for name, called in calls.items() if called & users} - users + if not more: + return users + users |= more + + +def _uses_the_codec(dotted: str, search_users: set[str]) -> bool: + wanted = {"crm.cursor": _CODEC, "crm.search": search_users} + return any( + isinstance(node, ast.ImportFrom) + and node.module in wanted + and bool({alias.name for alias in node.names} & wanted[node.module]) + for node in ast.walk(_module_tree(dotted)) + ) + + +def test_the_cursor_tools_are_exactly_the_tools_whose_handlers_use_the_codec() -> None: + search_users = _search_functions_using_the_codec() + assert {"search_accounts", "search_opportunities"} <= search_users + users = {t for t in _tool_names() if _uses_the_codec(_handler_module(t), search_users)} + assert len(_tool_names()) > len(CURSOR_TOOLS) + assert users == set(CURSOR_TOOLS) + + +# --------------------------------------------------------------------------- +# CSP sources passed to `module.frontend_cdn`. +# --------------------------------------------------------------------------- + + +def _inline_script_hashes() -> list[str]: + scripts = re.findall(r"", INDEX_HTML.read_text("utf-8"), re.S) + return [ + "sha256-" + base64.b64encode(hashlib.sha256(s.encode("utf-8")).digest()).decode() + for s in scripts + ] + + +def _csp_locals_hcl(index_html: Path) -> str: + block = _substitute( + _locals_block_defining(_code(MAIN_TF), "spa_inline_script_hashes"), + { + "${path.module}/../frontend/index.html": str(index_html), + "var.aws_region": '"us-east-1"', + "module.cognito.domain": '"crm-fixture"', + }, + set(), + ) + return ( + f"{block}\n" + 'resource "terraform_data" "csp" {\n' + " input = {\n" + " hashes = local.spa_inline_script_hashes\n" + " connect = local.spa_connect_src_extra\n" + " }\n" + "}\n" + ) + + +def _planned_csp(work_dir: Path, index_html: Path) -> dict[str, list[str]]: + plan = plan_root(work_dir, _csp_locals_hcl(index_html)) + value = plan.after("terraform_data.csp")["input"] + assert isinstance(value, dict) + return value + + +def test_the_script_hash_is_the_browser_hash_of_the_inline_theme_script(tmp_path: Path) -> None: + _skip_unless_terraform() + expected = _inline_script_hashes() + assert len(expected) == 1, "frontend/index.html no longer holds exactly one inline script" + assert _planned_csp(tmp_path / "root", INDEX_HTML)["hashes"] == expected + + +def test_the_script_hash_follows_an_edited_inline_script(tmp_path: Path) -> None: + _skip_unless_terraform() + edited = tmp_path / "index.html" + edited.write_text( + INDEX_HTML.read_text("utf-8").replace('"crm.theme"', '"crm.theme.v2"', 1), "utf-8" + ) + planned = _planned_csp(tmp_path / "root", edited)["hashes"] + assert planned != _inline_script_hashes() + assert len(planned) == 1 + + +def test_connect_src_is_the_regional_user_pool_endpoint_and_the_hosted_ui_domain( + tmp_path: Path, +) -> None: + _skip_unless_terraform() + assert _planned_csp(tmp_path / "root", INDEX_HTML)["connect"] == [ + "https://cognito-idp.us-east-1.amazonaws.com", + "https://crm-fixture.auth.us-east-1.amazoncognito.com", + ] + + +def test_frontend_cdn_receives_both_csp_inputs_from_the_locals() -> None: + call = _block(_code(MAIN_TF), 'module "frontend_cdn" {') + assert re.search(r"^ csp_script_hashes\s*= local\.spa_inline_script_hashes$", call, re.M) + assert re.search(r"^ csp_connect_src_extra\s*= local\.spa_connect_src_extra$", call, re.M) + + +# --------------------------------------------------------------------------- +# The `lambda_action` config-parameter read grant. +# --------------------------------------------------------------------------- + +PARAMETER_ARN: Final = ( + f"arn:aws:ssm:us-east-1:{ACCOUNT_ID}:parameter/crm-agent-eval/api/allowed-client-ids" +) +LOGS_POLICY: Final = "module.subject.aws_iam_role_policy.logs" + + +def _plan_scratch_lambda_action(work_dir: Path, extra: dict[str, str]) -> Plan: + """Plan a scratch copy whose log-group ARN is a literal, so the logs policy renders.""" + module_dir = work_dir / "lambda_action" + shutil.copytree(LAMBDA_ACTION, module_dir, ignore=shutil.ignore_patterns(".terraform")) + main = module_dir / "main.tf" + text = main.read_text(encoding="utf-8") + assert text.count("${aws_cloudwatch_log_group.this.arn}:*") == 1 + main.write_text( + text.replace( + "${aws_cloudwatch_log_group.this.arn}:*", + f"arn:aws:logs:us-east-1:{ACCOUNT_ID}:log-group:/aws/lambda/fixture:*", + ), + encoding="utf-8", + ) + return _plan_lambda_action(work_dir / "root", {"source": f'"{module_dir}"', **extra}) + + +def _logs_statements(plan: Plan) -> dict[str, dict[str, Any]]: + policy = plan.after(LOGS_POLICY)["policy"] + assert isinstance(policy, str), "the logs policy is not rendered at plan time" + return {s["Sid"]: s for s in json.loads(policy)["Statement"]} + + +def test_the_config_parameter_grant_is_get_parameter_on_exactly_the_named_arns( + tmp_path: Path, +) -> None: + _skip_unless_terraform() + plan = _plan_scratch_lambda_action( + tmp_path, {"config_parameter_arns": json.dumps([PARAMETER_ARN])} + ) + statements = _logs_statements(plan) + assert set(statements) == {"WriteOwnLogGroup", "ReadConfigParameters"} + statement = statements["ReadConfigParameters"] + assert statement["Effect"] == "Allow" + assert statement["Action"] == "ssm:GetParameter" + assert statement["Resource"] == PARAMETER_ARN + assert "Condition" not in statement + + +def test_no_config_parameter_statement_without_parameters(tmp_path: Path) -> None: + _skip_unless_terraform() + assert set(_logs_statements(_plan_scratch_lambda_action(tmp_path, {}))) == {"WriteOwnLogGroup"} + + +@pytest.mark.parametrize( + "arn", + [ + f"arn:aws:ssm:us-east-1:{ACCOUNT_ID}:parameter/*", + f"arn:aws:ssm:us-east-1:{ACCOUNT_ID}:parameter/crm-agent-eval/*", + "*", + f"arn:aws:ssm:*:{ACCOUNT_ID}:parameter/crm-agent-eval/api/allowed-client-ids", + ], +) +def test_a_wildcard_config_parameter_is_refused(tmp_path: Path, arn: str) -> None: + _skip_unless_terraform() + with pytest.raises(TerraformError, match="no wildcard"): + _plan_lambda_action(tmp_path / "root", {"config_parameter_arns": json.dumps([arn])}) + + +def test_approve_queries_only_the_opportunities_account_index(tmp_path: Path) -> None: + """approve_proposal's Query renders on `opportunities/index/gsi_account` alone, never a table.""" + from tests.unit.test_infra_revert_child_check_grants import _render, _table_arn + + grants = _render(tmp_path, "approve_proposal") + query = [g for g in grants if "dynamodb:Query" in g["actions"]] + assert query, "approve_proposal has no Query grant" + assert all(g["actions"] == ["dynamodb:Query"] for g in query), query + assert all(g["include_table_arn"] is False for g in query), query + assert {arn for g in query for arn in g["index_arns"]} == { + f"{_table_arn('opportunities')}/index/gsi_account" + } + for grant in grants: + if "dynamodb:Query" not in grant["actions"]: + assert grant["index_arns"] == [] and grant["include_table_arn"] is True, grant diff --git a/tests/unit/test_infra_eval_sfn.py b/tests/unit/test_infra_eval_sfn.py index eaf38ab..a9db24f 100644 --- a/tests/unit/test_infra_eval_sfn.py +++ b/tests/unit/test_infra_eval_sfn.py @@ -177,14 +177,16 @@ def _offline_state_machine(text: str) -> str: def _fixture_root(work_dir: Path, eval_sfn_text: str | None = None) -> str: """`main.tf`'s locals plus `eval_sfn.tf` (or `eval_sfn_text`), with stubs for every module - neither declares. The `dynamodb_data_plane_role_arns` and `logs_key_user_role_arns` lists are left out: they reference - `module.lambda_action`, which no stub can stand in for.""" + neither declares. The `dynamodb_data_plane_role_arns`, `logs_key_user_role_arns` and + `cursor_key_principal_arns` lists are left out: they reference `module.lambda_action`, which no + stub can stand in for.""" main_locals = [ block for block in _top_level_blocks((INFRA / "main.tf").read_text(encoding="utf-8")) if block.startswith("locals ") and "dynamodb_data_plane_role_arns" not in block and "logs_key_user_role_arns" not in block + and "cursor_key_principal_arns" not in block ] text = EVAL_SFN_TF.read_text("utf-8") if eval_sfn_text is None else eval_sfn_text root = "\n\n".join([*main_locals, _offline_state_machine(text)]) diff --git a/tests/unit/test_infra_inline_policy_budget.py b/tests/unit/test_infra_inline_policy_budget.py index 6c86671..214aee4 100644 --- a/tests/unit/test_infra_inline_policy_budget.py +++ b/tests/unit/test_infra_inline_policy_budget.py @@ -69,6 +69,8 @@ "var.crm_operator_principal_arns": f'["arn:aws:iam::{ACCOUNT}:role/fixture-operator"]', "module.eval_artifacts.bucket_arn": f'"arn:aws:s3:::crm-agent-eval-eval-artifacts-{ACCOUNT}"', "aws_kms_key.eval_artifacts.arn": f'"arn:aws:kms:{REGION}:{ACCOUNT}:key/{_KEY_ID}"', + "aws_kms_key.cursor.arn": f'"arn:aws:kms:{REGION}:{ACCOUNT}:key/{_KEY_ID}"', + '"${path.module}/../frontend/index.html"': f'"{REPO_ROOT / "frontend" / "index.html"}"', "aws_iam_role.agentcore_gateway.arn": ( f'"arn:aws:iam::{ACCOUNT}:role/crm-agent-eval-agentcore-gateway-role"' ), diff --git a/tests/unit/test_infra_user_settings.py b/tests/unit/test_infra_user_settings.py index 99e17a1..75310bf 100644 --- a/tests/unit/test_infra_user_settings.py +++ b/tests/unit/test_infra_user_settings.py @@ -83,12 +83,20 @@ def _statements(policy_json: str) -> list[dict[str, Any]]: return statements if isinstance(statements, list) else [statements] +ALLOWLIST_PARAMETER_NAME: Final = "/crm-agent-eval/api/allowed-client-ids" +ALLOWLIST_PARAMETER_ARN: Final = ( + f"arn:aws:ssm:us-east-1:{ACCOUNT_ID}:parameter{ALLOWLIST_PARAMETER_NAME}" +) + + def _substitutions(zip_path: Path) -> list[tuple[str, str]]: tables = "{ " + ", ".join(f'{t} = "{_table_arn(t)}"' for t in TABLES) + " }" return [ ("${local.name_prefix}", "crm-agent-eval"), ("local.name_prefix", '"crm-agent-eval"'), ("local.eval_lambda_zip", f'"{zip_path}"'), + ("local.api_allowed_client_ids_parameter_name", f'"{ALLOWLIST_PARAMETER_NAME}"'), + ("local.api_allowed_client_ids_parameter_arn", f'["{ALLOWLIST_PARAMETER_ARN}"][0]'), ("module.eni_function_code_deny.policy_arn", f'"{ENI_DENY_ARN}"'), ("module.vpc.lambda_subnet_ids", _hcl_list(SUBNET_IDS)), ("module.vpc.lambda_security_group_ids", _hcl_list(SECURITY_GROUP_IDS)), @@ -141,6 +149,7 @@ def test_environment_is_exactly_what_the_handler_reads(plan: Plan) -> None: (environment,) = plan.after(FUNCTION)["environment"] assert environment["variables"] == { "CRM_TABLE_PREFIX": "crm-agent-eval", + "CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": ALLOWLIST_PARAMETER_NAME, "PYTHONPATH": "/var/task/src", } diff --git a/tests/unit/test_lambda_env_contract.py b/tests/unit/test_lambda_env_contract.py index 59624bb..6224734 100644 --- a/tests/unit/test_lambda_env_contract.py +++ b/tests/unit/test_lambda_env_contract.py @@ -69,10 +69,22 @@ class _Function: _SWEEP_TASK_CONFIG = frozenset({"AGENT_RUNTIME_ARN", "AGENT_RUNTIME_QUALIFIER"}) _SWEEP_CONTROL_CONFIG = frozenset({"EVAL_ARTIFACTS_BUCKET", "EVAL_ARTIFACTS_PREFIX"}) +#: `crm.envelope` reads the API client-allowlist parameter name only on the API Gateway channel, which +#: these functions never serve. +_NOT_API_CHANNEL: frozenset[str] = frozenset({"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER"}) + _FUNCTIONS: tuple[_Function, ...] = ( - _Function("lambda_action_sweep_control", "eval_sfn.tf", _SWEEP_OPTIONAL | _SWEEP_TASK_CONFIG), - _Function("lambda_action_sweep_task", "eval_sfn.tf", _SWEEP_OPTIONAL | _SWEEP_CONTROL_CONFIG), - _Function("lambda_action_chat_target", "mcp_chat_gateway.tf"), + _Function( + "lambda_action_sweep_control", + "eval_sfn.tf", + _SWEEP_OPTIONAL | _SWEEP_TASK_CONFIG | _NOT_API_CHANNEL, + ), + _Function( + "lambda_action_sweep_task", + "eval_sfn.tf", + _SWEEP_OPTIONAL | _SWEEP_CONTROL_CONFIG | _NOT_API_CHANNEL, + ), + _Function("lambda_action_chat_target", "mcp_chat_gateway.tf", _NOT_API_CHANNEL), _Function("lambda_action_user_settings", "user_settings.tf"), _Function("lambda_action_eval_trigger", "main.tf", _EVAL_TRIGGER_OPTIONAL), ) diff --git a/tests/unit/test_listing_scope.py b/tests/unit/test_listing_scope.py index 0275af5..6652832 100644 --- a/tests/unit/test_listing_scope.py +++ b/tests/unit/test_listing_scope.py @@ -16,7 +16,13 @@ from crm.authz import Identity from crm.envelope import IDENTITY_KEY, identity_event from crm.errors import ScopeDenied, ValidationFailed -from crm.handlers import pipeline_aggregate, search_accounts, search_opportunities +from crm.handlers import ( + list_audit_records, + list_proposals, + pipeline_aggregate, + search_accounts, + search_opportunities, +) from crm.search import ACCOUNT_ID_MAX_LENGTH from crm.search import search_accounts as search_accounts_fn from crm.search import search_opportunities as search_opportunities_fn @@ -36,9 +42,20 @@ "search_opportunities": search_opportunities.handler, "search_accounts": search_accounts.handler, "pipeline_aggregate": pipeline_aggregate.handler, + "list_audit_records": list_audit_records.handler, + "list_proposals": list_proposals.handler, } +def _listed_account_ids(tool: str, body: dict[str, Any]) -> list[str]: + """The ``account_id`` each row a listing handler returned is scoped by.""" + if tool == "list_audit_records": + return [str(record["account_id"]) for record in body["audit_records"]] + if tool == "list_proposals": + return [str(proposal["before_snapshot"]["account_id"]) for proposal in body["proposals"]] + return [str(item["account_id"]) for item in body["items"]] + + class _SpyStore: """A store stand-in that records every attribute access and refuses to serve any of them.""" @@ -80,7 +97,8 @@ def _assert_denied(result: dict[str, Any], missing_scope: str) -> None: @pytest.fixture def store() -> Iterator[Store]: - """A moto-backed store seeded with one in-book and one out-of-book account and opportunity.""" + """A moto-backed store seeded with an in-book and an out-of-book account, each with one + opportunity, one audit record and one pending proposal.""" with mock_aws(): client = boto3.client("dynamodb", region_name="us-east-1") create_all_tables(client) @@ -121,6 +139,32 @@ def _seed(store: Store, *, account_id: str, opportunity_id: str) -> None: "stage_close_date": stage_close_date("Discovery", "2026-01-01"), }, ) + store.put_item( + "audit_records", + { + "audit_id": f"audit-{opportunity_id}", + "tenant": _TENANT, + "account_id": account_id, + "target_table": "opportunities", + "target_id": opportunity_id, + "actor_rep_id": _REP, + "status": "applied", + "created_at": "2026-01-01T00:00:00Z", + }, + ) + store.put_item( + "proposals", + { + "proposal_id": f"prop-{opportunity_id}", + "tenant": _TENANT, + "status": "pending", + "actor_rep_id": _REP, + "target_table": "opportunities", + "target_id": opportunity_id, + "created_at": "2026-01-01T00:00:00Z", + "before_snapshot": {"tenant": _TENANT, "account_id": account_id}, + }, + ) # -- empty book ----------------------------------------------------------------------------------- @@ -166,7 +210,7 @@ def test_a_book_caller_gets_its_own_data(tool: str, store: Store) -> None: if tool == "pipeline_aggregate": assert result["body"]["value_rollup"] == 1000 else: - assert [item["account_id"] for item in result["body"]["items"]] == [_IN_BOOK] + assert _listed_account_ids(tool, result["body"]) == [_IN_BOOK] @pytest.mark.parametrize("tool", sorted(_HANDLERS)) @@ -179,10 +223,7 @@ def test_a_full_visibility_caller_with_an_empty_book_gets_every_record( if tool == "pipeline_aggregate": assert result["body"]["value_rollup"] == 2000 else: - assert sorted(item["account_id"] for item in result["body"]["items"]) == [ - _IN_BOOK, - _OUT_OF_BOOK, - ] + assert sorted(_listed_account_ids(tool, result["body"])) == [_IN_BOOK, _OUT_OF_BOOK] # -- explicit account filter ---------------------------------------------------------------------- diff --git a/tests/unit/test_matrix_tier_comparison.py b/tests/unit/test_matrix_tier_comparison.py index 917fdef..c4d9357 100644 --- a/tests/unit/test_matrix_tier_comparison.py +++ b/tests/unit/test_matrix_tier_comparison.py @@ -10,11 +10,13 @@ import csv import dataclasses +import hashlib import io import json import re +from collections.abc import Callable from pathlib import Path -from typing import cast +from typing import Any, cast import pytest @@ -761,3 +763,162 @@ def test_a_pre_spec_archive_renders_the_retry_row_as_dashes() -> None: arms = [arm_from_report_fields(fields) for fields in payload["arms"]] markdown = render_markdown(build_matrix_result(arms)) assert _md_table_rows(markdown, "Supervisor")["Self-corrected retries"] == ["—"] * len(arms) + + +# --------------------------------------------------------------------------------------------- +# Display table (tier_comparison_table) +# --------------------------------------------------------------------------------------------- + +#: sha256 of each fixture's ``## Tier comparison summary`` block as rendered before the display +#: table was extracted; the Markdown must stay byte-identical. +_SUMMARY_BLOCK_SHA256 = { + "three_arm": "5af7d03b8ddbf603dabb48636889a8eea663aabb57820782f4ee4b27ebc0d3b1", + "single_anthropic": "bffeca592f98807ecc8fee4d8779b1a6d744d1feb864a8c5c7c9e3665e07b883", + "single_openai_stub": "e3e915c624ad656c7981066c5aab02364c828648ed12b8e4b44268f53148b08f", + "legacy": "a1c515b7ba2506b83344a363149992b798f9e06da7bd06ee4fe2ad4379398c61", +} + + +def _legacy_matrix() -> MatrixResult: + payload = json.loads(_LEGACY_ARTIFACT.read_text(encoding="utf-8")) + return build_matrix_result([arm_from_report_fields(fields) for fields in payload["arms"]]) + + +def _fixture_matrices() -> dict[str, MatrixResult]: + return { + "three_arm": _three_arm_matrix(), + "single_anthropic": build_matrix_result([_anthropic_arm()]), + "single_openai_stub": build_matrix_result([_openai_arm(SOL, mode="stub", effort="low")]), + "legacy": _legacy_matrix(), + } + + +def _table_as_markdown(table: dict[str, object]) -> str: + """Format a display table the way ``matrix.md`` lays it out, independently of the module.""" + headers = cast(list[str], table["headers"]) + + def _line(cells: list[str]) -> str: + return "| " + " | ".join(cells) + " |" + + lines = [ + "## Tier comparison summary", + "", + "Per-tier figures for each arm, one column per arm in run order; the notes below the " + "tables define each row.", + "", + ] + for section in cast(list[dict[str, object]], table["sections"]): + lines.extend([f"### {section['heading']}", "", _line(headers)]) + lines.append(_line(["---"] * len(headers))) + lines.extend(_line(row) for row in cast(list[list[str]], section["rows"])) + lines.append("") + lines.extend(["Notes:", ""]) + lines.extend(f"- {note}" for note in cast(list[str], table["notes"])) + lines.append("") + return "\n".join(lines) + "\n" + + +def _table(matrix_result: MatrixResult) -> dict[str, object]: + return matrix.tier_comparison_table(tier_comparison(matrix_result)) + + +def _section_rows(table: dict[str, object], tier: str) -> dict[str, list[str]]: + for section in cast(list[dict[str, object]], table["sections"]): + if section["tier"] == tier: + return {row[0]: row[1:] for row in cast(list[list[str]], section["rows"])} + raise AssertionError(f"no section for {tier}") + + +@pytest.mark.parametrize("name", sorted(_SUMMARY_BLOCK_SHA256)) +def test_the_summary_markdown_is_byte_identical_to_the_pre_extraction_render(name: str) -> None: + block = _summary_block(render_markdown(_fixture_matrices()[name])) + assert hashlib.sha256(block.encode("utf-8")).hexdigest() == _SUMMARY_BLOCK_SHA256[name] + + +@pytest.mark.parametrize("name", sorted(_SUMMARY_BLOCK_SHA256)) +def test_the_json_round_tripped_table_formats_to_the_matrix_md_section(name: str) -> None: + matrix_result = _fixture_matrices()[name] + round_tripped = json.loads(render_json(matrix_result))["tier_comparison"] + table = matrix.tier_comparison_table(round_tripped) + assert table == _table(matrix_result) + assert _table_as_markdown(table) == _summary_block(render_markdown(matrix_result)) + + +def test_the_table_has_headers_three_sections_in_order_and_the_notes() -> None: + matrix_result = _three_arm_matrix() + table = _table(matrix_result) + assert list(table) == ["headers", "sections", "notes"] + assert table["headers"] == [ + "Metric", + "anthropic", + f"openai ({ASTRA}, effort medium)", + f"openai ({SOL}, effort low)", + ] + sections = cast(list[dict[str, object]], table["sections"]) + assert [(s["tier"], s["heading"]) for s in sections] == [ + ("supervisor", "Supervisor"), + ("subagent", "Subagent"), + ("tool", "ToolCall"), + ] + assert [list(s) for s in sections] == [["tier", "heading", "rows"]] * 3 + for section in sections: + rows = cast(list[list[str]], section["rows"]) + assert [row[0] for row in rows[: len(_ROW_LABELS)]] == _ROW_LABELS + assert all(len(row) == 4 and all(isinstance(c, str) for c in row) for row in rows) + assert table["notes"] == tier_comparison(matrix_result)["notes"] + + +def test_table_cells_render_null_withheld_and_not_applicable() -> None: + table = _table(_three_arm_matrix()) + supervisor = _section_rows(table, "supervisor") + assert supervisor["Cost per completed task"] == ["0.200000", "withheld", "withheld"] + assert supervisor["Self-corrected retries"] == ["2", "—", "—"] + subagent = _section_rows(table, "subagent") + assert subagent["Task completion rate"][1:] == ["not applicable", "not applicable"] + assert subagent["Task accuracy"][1:] == ["not applicable", "not applicable"] + tool = _section_rows(table, "tool") + assert tool["Cost per completed task"][0] == "—" + assert tool["Self-corrected retries"] == ["not applicable"] * 3 + + +def test_a_pre_spec_archive_table_renders_absent_figures_as_dashes() -> None: + matrix_result = _legacy_matrix() + supervisor = _section_rows(_table(matrix_result), "supervisor") + columns = len(matrix_result.arms) + assert supervisor["Effort"] == ["—"] * columns + assert supervisor["Task completion rate"] == ["—"] * columns + + +def test_a_single_arm_table_has_one_cell_per_row() -> None: + table = _table(build_matrix_result([_anthropic_arm()])) + assert table["headers"] == ["Metric", "anthropic"] + for section in cast(list[dict[str, object]], table["sections"]): + assert all(len(row) == 2 for row in cast(list[list[str]], section["rows"])) + + +def test_an_unexercised_tier_still_renders_its_section() -> None: + subagent = _section_rows(_table(build_matrix_result([_openai_arm()])), "subagent") + assert subagent["Task completion rate"] == ["not applicable"] + assert subagent["Model"] == [SOL] + assert subagent["Delegation outcome: none"] == ["2"] + + +@pytest.mark.parametrize( + "mutate", + [ + lambda s: s.pop("columns"), + lambda s: s.update(columns="x"), + lambda s: s.update(columns=["x"]), + lambda s: s.update(tiers=[]), + lambda s: s["tiers"].pop("tool"), + lambda s: s["tiers"].update(subagent=s["tiers"]["subagent"][:1]), + lambda s: s["tiers"].update(supervisor=["x"] * len(s["columns"])), + lambda s: s.update(notes=[1]), + lambda s: s.pop("notes"), + ], +) +def test_a_malformed_summary_is_refused(mutate: Callable[[dict[str, Any]], object]) -> None: + summary: dict[str, Any] = json.loads(json.dumps(tier_comparison(_three_arm_matrix()))) + mutate(summary) + with pytest.raises(ValueError, match="tier comparison summary"): + matrix.tier_comparison_table(summary) diff --git a/tests/unit/test_pipeline_aggregate_budget.py b/tests/unit/test_pipeline_aggregate_budget.py new file mode 100644 index 0000000..fa5d33d --- /dev/null +++ b/tests/unit/test_pipeline_aggregate_budget.py @@ -0,0 +1,175 @@ +# SPDX-License-Identifier: MIT +"""``pipeline_aggregate`` examines at most the search budget and batch-fetches bodies. + +Runs the handler against a ``moto``-mocked DynamoDB store. The demo-tenant cases pin the totals +the handler produced before the budget and batching were introduced, as sha256 digests of the +canonical JSON body without ``truncated``. +""" + +from __future__ import annotations + +import hashlib +import json +from collections.abc import Iterator, Mapping, Sequence +from typing import Any + +import boto3 +import pytest +from fixtures.generate import seed_tenant +from moto import mock_aws + +from crm.envelope import IDENTITY_KEY, identity_event +from crm.handlers import pipeline_aggregate +from crm.search import EXAMINATION_BUDGET +from crm.store.provisioning import create_all_tables +from crm.store.store import Store + +pytestmark = pytest.mark.filterwarnings("ignore::DeprecationWarning") + +_TENANT = "demo" +_DEMO_BOOK = [f"acct-demo-{index:04d}" for index in range(7)] + +#: Digest of each demo-tenant case's body (``truncated`` removed) as produced before the change. +_PRE_CHANGE_BODY_SHA256 = { + "book": "2f16da3b968fcc006bc4e2537002357671541aff059f87b3bf27b38a4bbb8466", + "full": "77c814dec39c21f38a2a28881ca7df1cb4086be8268514572db9b370d84f5021", + "full_closed": "dadb8885813d27d7b36d43506930ed0a40ddd7036a75381c7177391ee5d31529", + "full_window": "a39e44462a339ead5eef671cc49940f712228023ee83e8dcd32791003964285e", +} + +_CASES: dict[str, tuple[bool, list[str], dict[str, Any]]] = { + "book": (False, _DEMO_BOOK, {}), + "full": (True, [], {}), + "full_closed": (True, [], {"include_closed": True}), + "full_window": (True, [], {"close_after": "2026-01-01", "close_before": "2026-06-30"}), +} + + +class RecordingStore(Store): + """A real :class:`Store` that records tenant-scan page sizes and batch-get key counts, and + refuses any single-item read.""" + + def __init__(self, client: Any) -> None: + super().__init__(client=client) + self.scan_pages: list[int] = [] + self.batch_key_counts: list[int] = [] + + def query_tenant_scan( + self, table: str, **kwargs: Any + ) -> tuple[list[dict[str, object]], dict[str, object] | None]: + page, cursor = super().query_tenant_scan(table, **kwargs) + self.scan_pages.append(len(page)) + return page, cursor + + def batch_get_items( + self, table: str, keys: Sequence[Mapping[str, str]] + ) -> list[dict[str, object]]: + self.batch_key_counts.append(len(keys)) + return super().batch_get_items(table, keys) + + def get_item(self, *args: Any, **kwargs: Any) -> dict[str, object] | None: + raise AssertionError("pipeline_aggregate must not read opportunities one at a time") + + +@pytest.fixture +def store() -> Iterator[RecordingStore]: + with mock_aws(): + client = boto3.client("dynamodb", region_name="us-east-1") + create_all_tables(client) + yield RecordingStore(client) + + +def _event(*, full: bool, book: list[str], args: dict[str, Any]) -> dict[str, Any]: + identity = { + "rep_id": "rep-x", + "book": book, + "full_visibility": full, + "principal_type": "user", + "session_id": "s", + "source": "gateway", + "tenant": _TENANT, + } + return identity_event(IDENTITY_KEY, identity, args) + + +def _seed_opportunities(store: Store, count: int) -> None: + for index in range(count): + store.put_item( + "opportunities", + { + "opportunity_id": f"opp-{index:03d}", + "tenant": _TENANT, + "tenant_account_id": f"{_TENANT}#acct-1", + "tenant_owner_rep_id": f"{_TENANT}#rep-1", + "tenant_stage": f"{_TENANT}#Discovery", + "account_id": "acct-1", + "owner_rep_id": "rep-1", + "name": "Deal", + "name_lower": "deal", + "stage": "Discovery", + "value": 100, + "close_date": "2026-03-01", + }, + ) + + +def _call(store: Store, **kwargs: Any) -> dict[str, Any]: + result = pipeline_aggregate.handler(_event(**kwargs), store=store) + assert result["statusCode"] == 200, result + body: dict[str, Any] = result["body"] + return body + + +def test_demo_tenant_totals_equal_the_pre_change_totals(store: RecordingStore) -> None: + seed_tenant(store, tenant=_TENANT) + for name, (full, book, args) in _CASES.items(): + body = _call(store, full=full, book=book, args=args) + assert body.pop("truncated") is False, name + digest = hashlib.sha256(json.dumps(body, sort_keys=True).encode("utf-8")).hexdigest() + assert digest == _PRE_CHANGE_BODY_SHA256[name], name + + +def test_bodies_are_batch_fetched_never_read_one_at_a_time(store: RecordingStore) -> None: + _seed_opportunities(store, 30) + body = _call(store, full=True, book=[], args={}) + assert body["stage_funnel"]["Discovery"] == 30 + assert body["value_rollup"] == 3000 + assert store.batch_key_counts == [30] + + +def test_examination_stops_at_the_budget_and_reports_truncation( + store: RecordingStore, monkeypatch: pytest.MonkeyPatch +) -> None: + _seed_opportunities(store, 8) + monkeypatch.setattr(pipeline_aggregate, "EXAMINATION_BUDGET", 5) + body = _call(store, full=True, book=[], args={}) + assert body["truncated"] is True + assert sum(store.scan_pages) == 5 + assert body["stage_funnel"]["Discovery"] == 5 + assert body["value_rollup"] == 500 + + +def test_an_examination_within_the_budget_is_not_truncated( + store: RecordingStore, monkeypatch: pytest.MonkeyPatch +) -> None: + _seed_opportunities(store, 8) + monkeypatch.setattr(pipeline_aggregate, "EXAMINATION_BUDGET", 9) + body = _call(store, full=True, book=[], args={}) + assert body["truncated"] is False + assert body["stage_funnel"]["Discovery"] == 8 + + +def test_out_of_scope_rows_count_against_the_budget_but_are_not_fetched( + store: RecordingStore, monkeypatch: pytest.MonkeyPatch +) -> None: + _seed_opportunities(store, 6) + monkeypatch.setattr(pipeline_aggregate, "EXAMINATION_BUDGET", 4) + body = _call(store, full=False, book=["acct-other"], args={}) + assert body["truncated"] is True + assert sum(store.scan_pages) == 4 + assert body["value_rollup"] == 0 + assert store.batch_key_counts == [0] + + +def test_the_handler_uses_the_search_budget() -> None: + assert vars(pipeline_aggregate)["EXAMINATION_BUDGET"] == EXAMINATION_BUDGET == 2000 diff --git a/tests/unit/test_plan_fixtures.py b/tests/unit/test_plan_fixtures.py index 85cd0d1..5e4ccaa 100644 --- a/tests/unit/test_plan_fixtures.py +++ b/tests/unit/test_plan_fixtures.py @@ -24,15 +24,15 @@ #: sha256 of `json.dumps(build(name), sort_keys=True)` per name. EXPECTED_SHA256 = { - "compliant": "a2cc7227c942d6e294b2928d394576e65e2fe72f99e70d192fd6dc354a8ac61d", + "compliant": "8a49dc2252edd5de77bbd9d3237f1ae5c4b612505d880f53d112e8668f56f5c1", "compliant_gateway_role_known_arn": ( - "9f71bc3d07cfe92020e320c80a6bb7edec63ed7d06d7b6afc625469b9e464a1c" + "4a1840000a30c4559e190210a109b0b780587b030cf88e4a8f3e2d03d9b9502f" ), "violation_log_group_no_kms": ( - "341139fe5a24a6b267e34bbe0dc1dfad0f25f483333522296a87938417350e4c" + "74e646684ecc007e2f923d7c730940c033c958bd3bbd7373585076ebdc558cb9" ), "violation_relay_function_url_buffered": ( - "9780bf24ec342bea22d30b7afc003759b9c835bed880bb887cfa02c97d86dc81" + "7519edb3245bc94723dfce9ea299ac0b764c7efbe000c4bae41444a8ede84666" ), } diff --git a/tests/unit/test_plan_security_baseline.py b/tests/unit/test_plan_security_baseline.py index a33505f..a264853 100644 --- a/tests/unit/test_plan_security_baseline.py +++ b/tests/unit/test_plan_security_baseline.py @@ -245,6 +245,14 @@ def test_covers_every_registered_control(self) -> None: #: together with the gate's entries. PENDING_RECAPTURE_LAGGING_COUNTS: frozenset[str] = frozenset() +#: Grants declared in `FIXTURE_STALE_GRANTS` until the compliant fixture is re-captured; emptied +#: together with the gate's entries. +PENDING_RECAPTURE_STALE_GRANTS: frozenset[str] = frozenset() + +#: Grants declared in `FIXTURE_PENDING_GRANTS` until the compliant fixture is re-captured; emptied +#: together with the gate's entries. +PENDING_RECAPTURE_PENDING_GRANTS: frozenset[str] = frozenset() + SOURCE_DERIVED_CONTROLS: dict[str, str] = { "no_json_syntax_terraform": "Its subject is the file listing of `infra/`, not a plan, so no plan " "fixture can violate it. `TestNoJsonSyntaxTerraform` plants a `.tf.json` in a tmp `infra/` and " @@ -6116,6 +6124,13 @@ def test_no_fixture_lag_declaration_survives_the_re_capture(self) -> None: for k, v in gate.FIXTURE_LAGGING_COUNTS.items() if k not in PENDING_RECAPTURE_LAGGING_COUNTS } + assert set(gate.FIXTURE_STALE_GRANTS) == PENDING_RECAPTURE_STALE_GRANTS + assert set(gate.FIXTURE_PENDING_GRANTS) == PENDING_RECAPTURE_PENDING_GRANTS + for name, pending in ( + ("FIXTURE_STALE_GRANTS", PENDING_RECAPTURE_STALE_GRANTS), + ("FIXTURE_PENDING_GRANTS", PENDING_RECAPTURE_PENDING_GRANTS), + ): + declarations[name] = {k: v for k, v in getattr(gate, name).items() if k not in pending} assert {name: value for name, value in declarations.items() if value} == {} lag = [ f @@ -6137,7 +6152,9 @@ def test_a_planted_stale_grant_is_absorbed_only_while_declared( failed = self._failed_subjects(self._findings("dynamodb_leading_keys_isolation", document)) assert "approve_proposal -> accounts (action coverage)" in failed, failed monkeypatch.setattr( - gate, "FIXTURE_STALE_GRANTS", {"approve_proposal:accounts:dynamodb:PutItem": "planted"} + gate, + "FIXTURE_STALE_GRANTS", + {**gate.FIXTURE_STALE_GRANTS, "approve_proposal:accounts:dynamodb:PutItem": "planted"}, ) findings = self._findings("dynamodb_leading_keys_isolation", document) assert not self._failed_subjects(findings), self._failed_subjects(findings) @@ -6173,7 +6190,13 @@ def test_a_planted_pending_grant_is_absorbed_only_while_declared( monkeypatch.setattr( gate, "FIXTURE_PENDING_GRANTS", - {"eval-trigger:eval_runs:dynamodb:Query": ("planted", "eval_trigger_eval_runs_grants")}, + { + **gate.FIXTURE_PENDING_GRANTS, + "eval-trigger:eval_runs:dynamodb:Query": ( + "planted", + "eval_trigger_eval_runs_grants", + ), + }, ) findings = self._findings("dynamodb_leading_keys_isolation", document) assert not self._failed_subjects(findings), self._failed_subjects(findings) @@ -7694,11 +7717,11 @@ def test_a_one_sided_gate_edit_is_a_mismatch( class TestStoreKeyPolicyCount: - """`aws_kms_key_policy` expects 3, and the committed fixture plans 3 with no lagging entry.""" + """`aws_kms_key_policy` expects 4, and the committed fixture plans 4.""" - def test_the_expected_and_declared_counts_are_three(self) -> None: - assert gate.EXPECTED_RESOURCE_COUNTS["aws_kms_key_policy"].fixed == 3 - assert gate.DECLARED_INFRA_BLOCK_COUNTS['resource "aws_kms_key_policy"'][0] == 3 + def test_the_expected_and_declared_counts_are_four(self) -> None: + assert gate.EXPECTED_RESOURCE_COUNTS["aws_kms_key_policy"].fixed == 4 + assert gate.DECLARED_INFRA_BLOCK_COUNTS['resource "aws_kms_key_policy"'][0] == 4 rows = { f.resource: f.status for f in gate.check_declared_infra_block_counts(gate.Plan(resource_changes=[])) @@ -7713,23 +7736,30 @@ def _count_row(self, plan: Any) -> Any: ] return row - def test_the_recaptured_fixture_plans_three_and_the_count_passes(self) -> None: + def test_the_fixture_plans_four_and_the_count_passes(self) -> None: planned = sum( 1 for r in load_plan("compliant").resource_changes if r.get("type") == "aws_kms_key_policy" ) - assert planned == 3 + assert planned == 4 assert "aws_kms_key_policy" not in gate.FIXTURE_LAGGING_COUNTS assert self._count_row(load_plan("compliant")).status == "pass" - def test_a_plan_with_two_or_four_fails(self) -> None: + def _with_extra(self, document: dict[str, Any], count: int) -> Any: + policy = next(r for r in document["resource_changes"] if r["type"] == "aws_kms_key_policy") + extra = [ + copy.deepcopy(policy) | {"address": f"aws_kms_key_policy.planted_{index}"} + for index in range(count) + ] + return _plan_of(document | {"resource_changes": [*document["resource_changes"], *extra]}) + + def test_a_plan_with_four_passes_and_three_or_five_fails(self) -> None: document = plan_fixtures.build("compliant") policy = next(r for r in document["resource_changes"] if r["type"] == "aws_kms_key_policy") - fourth = copy.deepcopy(policy) | {"address": "aws_kms_key_policy.planted_fourth"} - more = [*document["resource_changes"], fourth] fewer = [r for r in document["resource_changes"] if r is not policy] - assert self._count_row(_plan_of(document | {"resource_changes": more})).status == "fail" + assert self._count_row(_plan_of(document)).status == "pass" + assert self._count_row(self._with_extra(document, 1)).status == "fail" assert self._count_row(_plan_of(document | {"resource_changes": fewer})).status == "fail" def test_a_lagging_declaration_defers_only_the_count_it_declares( @@ -7741,16 +7771,17 @@ def test_a_lagging_declaration_defers_only_the_count_it_declares( document | {"resource_changes": [r for r in document["resource_changes"] if r is not policy]} ) - monkeypatch.setattr(gate, "FIXTURE_LAGGING_COUNTS", {"aws_kms_key_policy": (2, "lagging")}) + monkeypatch.setattr(gate, "FIXTURE_LAGGING_COUNTS", {"aws_kms_key_policy": (3, "lagging")}) assert self._count_row(fewer).status == "deferred" assert self._count_row(load_plan("compliant")).status == "pass" + assert self._count_row(self._with_extra(document, 1)).status == "fail" - def test_a_reintroduced_lagging_entry_is_stale_against_the_recaptured_fixture( + def test_a_wrong_lagging_count_is_stale_against_the_fixture( self, monkeypatch: pytest.MonkeyPatch ) -> None: row = "(declared-lagging) aws_kms_key_policy" assert row not in {f.resource for f in gate.check_fixture_currency()} - monkeypatch.setattr(gate, "FIXTURE_LAGGING_COUNTS", {"aws_kms_key_policy": (2, "stale")}) + monkeypatch.setattr(gate, "FIXTURE_LAGGING_COUNTS", {"aws_kms_key_policy": (3, "stale")}) assert {f.resource: f.status for f in gate.check_fixture_currency()}[row] == "fail" diff --git a/tests/unit/test_proposal_decision_channel.py b/tests/unit/test_proposal_decision_channel.py index 9b59b56..6201806 100644 --- a/tests/unit/test_proposal_decision_channel.py +++ b/tests/unit/test_proposal_decision_channel.py @@ -20,6 +20,7 @@ from crm.handlers._common import idempotent_id from crm.store.provisioning import create_all_tables from crm.store.store import Store +from tests.conftest import TEST_API_CLIENT_ID pytestmark = pytest.mark.filterwarnings("ignore::DeprecationWarning") @@ -49,7 +50,8 @@ def _gateway_event(arguments: dict[str, Any], *, principal_type: str = "user") - def _apigw_event(arguments: dict[str, Any]) -> dict[str, Any]: - context = {"authorizer": {"jwt": {"claims": dict(_CLAIMS)}}, "requestId": "req-1"} + claims = {**_CLAIMS, "token_use": "id", "aud": TEST_API_CLIENT_ID} + context = {"authorizer": {"jwt": {"claims": claims}}, "requestId": "req-1"} return identity_event(REQUEST_CONTEXT_KEY, context, arguments) diff --git a/tests/unit/test_proposal_integrity.py b/tests/unit/test_proposal_integrity.py new file mode 100644 index 0000000..d0943ca --- /dev/null +++ b/tests/unit/test_proposal_integrity.py @@ -0,0 +1,446 @@ +# SPDX-License-Identifier: MIT +"""Proposal integrity re-checked at approve and rebase, against a `moto`-mocked DynamoDB. + +Covers the shared primary-contact reference check (create, submit, approve), the delete cascade +rules re-run at approve, and the stage-transition check at approve and rebase. Every refusal leaves +the target record and the proposal unchanged. +""" + +from __future__ import annotations + +import uuid +from collections.abc import Iterator +from typing import Any + +import boto3 +import pytest +from moto import mock_aws + +from crm.authz import Identity +from crm.domain.references import require_primary_contact_in_account +from crm.envelope import IDENTITY_KEY, identity_event +from crm.errors import ValidationFailed +from crm.handlers import ( + approve_proposal, + create_opportunity, + rebase_proposal, + reject_proposal, + submit_proposal, +) +from crm.store.keys import derive +from crm.store.provisioning import create_all_tables +from crm.store.store import Store + +pytestmark = pytest.mark.filterwarnings("ignore::DeprecationWarning") + +_TENANT = "demo" +_REP = "rep-1" +_ACCOUNT = "acct-1" +_OTHER_ACCOUNT = "acct-2" +_OPPORTUNITY = "opp-1" +_IDENTITY = Identity(rep_id=_REP, tenant=_TENANT, book=frozenset({_ACCOUNT}), source="gateway") + + +@pytest.fixture +def store() -> Iterator[Store]: + with mock_aws(): + client = boto3.client("dynamodb", region_name="us-east-1") + create_all_tables(client) + yield Store(client=client) + + +def _key() -> str: + return uuid.uuid4().hex[:32] + + +def _event(args: dict[str, Any]) -> dict[str, Any]: + return identity_event( + IDENTITY_KEY, + { + "rep_id": _REP, + "book": [_ACCOUNT, _OTHER_ACCOUNT], + "full_visibility": False, + "principal_type": "user", + "session_id": "sess-1", + "source": "gateway", + "tenant": _TENANT, + }, + args, + ) + + +def _seed_account(store: Store, account_id: str = _ACCOUNT) -> None: + store.put_item( + "accounts", + derive( + "accounts", + {"account_id": account_id, "tenant": _TENANT, "owner_rep_id": _REP, "name": "Acme"}, + ), + ) + + +def _seed_contact( + store: Store, contact_id: str = "cont-1", account_id: str = _ACCOUNT, tenant: str = _TENANT +) -> None: + store.put_item( + "contacts", + derive( + "contacts", + { + "contact_id": contact_id, + "tenant": tenant, + "account_id": account_id, + "name": "Jane Doe", + "status": "active", + "created_at": "2026-01-01T00:00:00+00:00", + }, + ), + ) + + +def _seed_opportunity(store: Store, **overrides: object) -> None: + item: dict[str, object] = { + "opportunity_id": _OPPORTUNITY, + "tenant": _TENANT, + "account_id": _ACCOUNT, + "owner_rep_id": _REP, + "name": "Acme Renewal", + "stage": "Discovery", + "value": 1000, + "primary_contact_id": None, + "created_at": "2026-01-01T00:00:00+00:00", + "updated_at": "2026-01-01T00:00:00+00:00", + } + item.update(overrides) + store.put_item("opportunities", derive("opportunities", item)) + + +def _opportunity(store: Store) -> dict[str, object]: + item = store.get_item("opportunities", {"opportunity_id": _OPPORTUNITY}) + assert item is not None + return item + + +def _proposal(store: Store, proposal_id: str) -> dict[str, object]: + item = store.get_item("proposals", {"proposal_id": proposal_id}) + assert item is not None + return item + + +def _submit( + store: Store, + *, + target_table: str = "opportunities", + target_id: str = _OPPORTUNITY, + operation: str = "update", + payload: dict[str, object] | None = None, +) -> dict[str, Any]: + args: dict[str, Any] = { + "target_table": target_table, + "target_id": target_id, + "operation": operation, + "reason": "integrity", + "transaction_key": _key(), + } + if payload is not None: + args["after_payload"] = payload + result: dict[str, Any] = submit_proposal.handler(_event(args), store=store) + return result + + +def _submitted_id(result: dict[str, Any]) -> str: + assert result["statusCode"] == 200, result + return str(result["body"]["proposal"]["proposal_id"]) + + +def _approve(store: Store, proposal_id: str) -> dict[str, Any]: + result: dict[str, Any] = approve_proposal.handler( + _event({"proposal_id": proposal_id, "transaction_key": _key()}), store=store + ) + return result + + +def _rebase(store: Store, proposal_id: str) -> dict[str, Any]: + result: dict[str, Any] = rebase_proposal.handler( + _event({"proposal_id": proposal_id, "transaction_key": _key()}), store=store + ) + return result + + +def _assert_refused(result: dict[str, Any], *, status: int, source: str) -> None: + assert result["statusCode"] == status, result + assert result["error"]["source"] == source, result + + +def _row_count(store: Store, table: str) -> int: + return len(store._client.scan(TableName=store.physical_name(table))["Items"]) + + +def _audit_count(store: Store) -> int: + return _row_count(store, "audit_records") + + +# --- require_primary_contact_in_account ------------------------------------------------------- + + +@pytest.mark.parametrize("contact_id", [None, ""]) +def test_absent_or_cleared_contact_is_accepted_without_a_contact( + store: Store, contact_id: object +) -> None: + require_primary_contact_in_account(store, _IDENTITY, _ACCOUNT, contact_id) + + +def test_contact_under_the_same_account_is_accepted(store: Store) -> None: + _seed_contact(store) + require_primary_contact_in_account(store, _IDENTITY, _ACCOUNT, "cont-1") + + +@pytest.mark.parametrize( + ("contact_account", "contact_tenant", "contact_id"), + [ + (_OTHER_ACCOUNT, _TENANT, "cont-1"), + (_ACCOUNT, "other-tenant", "cont-1"), + (_ACCOUNT, _TENANT, "cont-missing"), + ], + ids=["cross_account", "cross_tenant", "dangling"], +) +def test_contact_outside_the_account_is_refused_with_the_given_source( + store: Store, contact_account: str, contact_tenant: str, contact_id: str +) -> None: + _seed_contact(store, account_id=contact_account, tenant=contact_tenant) + with pytest.raises(ValidationFailed) as raised: + require_primary_contact_in_account( + store, _IDENTITY, _ACCOUNT, contact_id, source="after_payload.primary_contact_id" + ) + assert raised.value.source == "after_payload.primary_contact_id" + + +# --- create_opportunity ----------------------------------------------------------------------- + + +def _create(store: Store, primary_contact_id: object) -> dict[str, Any]: + result: dict[str, Any] = create_opportunity.handler( + _event( + { + "account_id": _ACCOUNT, + "name": "New Deal", + "primary_contact_id": primary_contact_id, + "transaction_key": _key(), + } + ), + store=store, + ) + return result + + +def test_create_refuses_a_cross_account_primary_contact(store: Store) -> None: + _seed_account(store) + _seed_contact(store, account_id=_OTHER_ACCOUNT) + _assert_refused(_create(store, "cont-1"), status=400, source="primary_contact_id") + + +def test_create_accepts_a_same_account_primary_contact(store: Store) -> None: + _seed_account(store) + _seed_contact(store) + result = _create(store, "cont-1") + assert result["statusCode"] == 200, result + assert result["body"]["opportunity"]["primary_contact_id"] == "cont-1" + + +def test_create_treats_an_empty_primary_contact_as_absent(store: Store) -> None: + _seed_account(store) + result = _create(store, "") + assert result["statusCode"] == 200, result + + +# --- submit_proposal: primary contact --------------------------------------------------------- + + +@pytest.mark.parametrize("contact_id", ["cont-other", "cont-missing"], ids=["cross", "dangling"]) +def test_submit_refuses_a_primary_contact_outside_the_account( + store: Store, contact_id: str +) -> None: + _seed_opportunity(store) + _seed_contact(store, contact_id="cont-other", account_id=_OTHER_ACCOUNT) + + result = _submit(store, payload={"primary_contact_id": contact_id}) + + _assert_refused(result, status=400, source="after_payload.primary_contact_id") + assert _row_count(store, "proposals") == 0 + + +@pytest.mark.parametrize("contact_id", ["cont-1", ""], ids=["same_account", "cleared"]) +def test_submit_accepts_a_same_account_or_cleared_primary_contact( + store: Store, contact_id: str +) -> None: + _seed_opportunity(store, primary_contact_id="cont-1") + _seed_contact(store) + _submitted_id(_submit(store, payload={"primary_contact_id": contact_id})) + + +# --- approve_proposal: primary contact -------------------------------------------------------- + + +def test_approve_refuses_a_contact_moved_to_another_account_after_submit(store: Store) -> None: + _seed_opportunity(store) + _seed_contact(store) + proposal_id = _submitted_id(_submit(store, payload={"primary_contact_id": "cont-1"})) + _seed_contact(store, account_id=_OTHER_ACCOUNT) + + result = _approve(store, proposal_id) + + _assert_refused(result, status=400, source="after_payload.primary_contact_id") + assert _opportunity(store)["primary_contact_id"] is None + assert _proposal(store, proposal_id)["status"] == "pending" + + +def test_approve_refuses_a_contact_deleted_after_submit(store: Store) -> None: + _seed_opportunity(store) + _seed_contact(store) + proposal_id = _submitted_id(_submit(store, payload={"primary_contact_id": "cont-1"})) + store.delete_item("contacts", {"contact_id": "cont-1"}) + + result = _approve(store, proposal_id) + + _assert_refused(result, status=400, source="after_payload.primary_contact_id") + assert _opportunity(store)["primary_contact_id"] is None + + +def test_approve_applies_a_same_account_primary_contact(store: Store) -> None: + _seed_opportunity(store) + _seed_contact(store) + proposal_id = _submitted_id(_submit(store, payload={"primary_contact_id": "cont-1"})) + + assert _approve(store, proposal_id)["statusCode"] == 200 + assert _opportunity(store)["primary_contact_id"] == "cont-1" + + +# --- approve_proposal: delete cascades -------------------------------------------------------- + + +def test_approve_refuses_an_account_delete_once_an_open_opportunity_exists(store: Store) -> None: + _seed_account(store) + _seed_opportunity(store, stage="Closed Won") + proposal_id = _submitted_id( + _submit(store, target_table="accounts", target_id=_ACCOUNT, operation="delete") + ) + _seed_opportunity(store, opportunity_id="opp-open", stage="Negotiation") + + result = _approve(store, proposal_id) + + _assert_refused(result, status=400, source="account_id") + assert store.get_item("accounts", {"account_id": _ACCOUNT}) is not None + assert _proposal(store, proposal_id)["status"] == "pending" + + +def test_approve_refuses_a_contact_delete_once_the_contact_is_referenced(store: Store) -> None: + _seed_contact(store) + _seed_opportunity(store) + proposal_id = _submitted_id( + _submit(store, target_table="contacts", target_id="cont-1", operation="delete") + ) + _seed_opportunity(store, primary_contact_id="cont-1") + + result = _approve(store, proposal_id) + + _assert_refused(result, status=400, source="contact_id") + assert store.get_item("contacts", {"contact_id": "cont-1"}) is not None + + +def test_approve_applies_an_account_delete_with_only_closed_opportunities(store: Store) -> None: + _seed_account(store) + _seed_opportunity(store, stage="Closed Lost") + proposal_id = _submitted_id( + _submit(store, target_table="accounts", target_id=_ACCOUNT, operation="delete") + ) + + assert _approve(store, proposal_id)["statusCode"] == 200 + assert store.get_item("accounts", {"account_id": _ACCOUNT}) is None + + +def test_a_decided_proposal_reports_already_decided_not_a_cascade_refusal(store: Store) -> None: + _seed_account(store) + proposal_id = _submitted_id( + _submit(store, target_table="accounts", target_id=_ACCOUNT, operation="delete") + ) + rejected = reject_proposal.handler( + _event({"proposal_id": proposal_id, "transaction_key": _key()}), store=store + ) + assert rejected["statusCode"] == 200, rejected + _seed_opportunity(store, stage="Negotiation") + + result = _approve(store, proposal_id) + + assert result["statusCode"] == 409, result + assert result["error"]["reason"] == "already_decided" + + +# --- stage transition at approve and rebase --------------------------------------------------- + + +def _plant_snapshot(store: Store, proposal_id: str) -> None: + """Make the proposal's before-snapshot match the record, as an unchecked rebase would.""" + store.put_item( + "proposals", {**_proposal(store, proposal_id), "before_snapshot": _opportunity(store)} + ) + + +@pytest.mark.parametrize( + ("closed_stage", "requested"), + [("Closed Won", "Qualification"), ("Closed Won", "Closed Lost")], + ids=["reopen", "closed_lateral"], +) +def test_approve_refuses_a_refused_move_from_the_current_stage( + store: Store, closed_stage: str, requested: str +) -> None: + _seed_opportunity(store, stage="Negotiation") + proposal_id = _submitted_id(_submit(store, payload={"stage": requested})) + _seed_opportunity(store, stage=closed_stage) + _plant_snapshot(store, proposal_id) + audits_before = _audit_count(store) + + result = _approve(store, proposal_id) + + _assert_refused(result, status=400, source="after_payload.stage") + assert _opportunity(store)["stage"] == closed_stage + assert _proposal(store, proposal_id)["status"] == "pending" + assert _audit_count(store) == audits_before + + +@pytest.mark.parametrize( + ("closed_stage", "requested"), + [("Closed Won", "Qualification"), ("Closed Won", "Closed Lost")], + ids=["reopen", "closed_lateral"], +) +def test_rebase_refuses_a_refused_move_before_updating_the_snapshot( + store: Store, closed_stage: str, requested: str +) -> None: + _seed_opportunity(store, stage="Negotiation") + proposal_id = _submitted_id(_submit(store, payload={"stage": requested})) + snapshot_before = _proposal(store, proposal_id)["before_snapshot"] + _seed_opportunity(store, stage=closed_stage) + audits_before = _audit_count(store) + + result = _rebase(store, proposal_id) + + _assert_refused(result, status=400, source="after_payload.stage") + assert _proposal(store, proposal_id)["before_snapshot"] == snapshot_before + assert _audit_count(store) == audits_before + + +def test_a_regression_after_rebase_is_still_approved(store: Store) -> None: + """A racing advance, a fields_changed refusal, a rebase, then the approved regression.""" + _seed_opportunity(store, stage="Discovery") + proposal_id = _submitted_id(_submit(store, payload={"stage": "Qualification"})) + _seed_opportunity(store, stage="Negotiation") + + refused = _approve(store, proposal_id) + assert refused["statusCode"] == 409, refused + assert refused["error"]["reason"] == "fields_changed" + + rebased = _rebase(store, proposal_id) + assert rebased["statusCode"] == 200, rebased + + approved = _approve(store, proposal_id) + assert approved["statusCode"] == 200, approved + assert _opportunity(store)["stage"] == "Qualification" diff --git a/tests/unit/test_proposal_payload_allowlist.py b/tests/unit/test_proposal_payload_allowlist.py index 4157e7e..e99fa10 100644 --- a/tests/unit/test_proposal_payload_allowlist.py +++ b/tests/unit/test_proposal_payload_allowlist.py @@ -46,6 +46,7 @@ from crm.store.schema import table_schema from crm.store.store import Store from crm.toolspec.definitions import TABLES, allowlist_for, high_risk_fields_for +from tests.conftest import TEST_API_CLIENT_ID pytestmark = pytest.mark.filterwarnings("ignore::DeprecationWarning") @@ -99,7 +100,9 @@ def _identity_block(channel: str) -> dict[str, Any]: } if channel == AGENT_IDENTITY_KEY: return {"claims": claims} - return {"authorizer": {"jwt": {"claims": claims}}} + return { + "authorizer": {"jwt": {"claims": {**claims, "token_use": "id", "aud": TEST_API_CLIENT_ID}}} + } def _event(channel: str, arguments: dict[str, Any]) -> dict[str, Any]: diff --git a/tests/unit/test_rotate_mcp_client_secret.py b/tests/unit/test_rotate_mcp_client_secret.py index 1e2f0c7..1c9d31b 100644 --- a/tests/unit/test_rotate_mcp_client_secret.py +++ b/tests/unit/test_rotate_mcp_client_secret.py @@ -1003,3 +1003,117 @@ def test_an_unreadable_or_empty_old_secret_file_is_a_usage_error( assert run.rc == 2 assert "--old-secret-file" in run.err assert run.sessions == [] + + +def _output_members(operation: str) -> dict[str, Any]: + model = botocore.session.Session().get_service_model("cognito-idp") + return dict(model.operation_model(operation).output_shape.members) + + +def test_the_fixtures_follow_the_installed_cognito_output_shapes() -> None: + added = _output_members("AddUserPoolClientSecret") + assert list(added) == ["ClientSecretDescriptor"] + descriptor = set(added["ClientSecretDescriptor"].members) + assert {"ClientSecretId", "ClientSecretValue", "ClientSecretCreateDate"} <= descriptor + listed = _output_members("ListUserPoolClientSecrets") + assert set(listed["ClientSecrets"].member.members) == descriptor + + +class _FlatteningIdp: + """Passes every call to the stubbed client; flattens the Add response the way a reshape would.""" + + def __init__(self, inner: Any) -> None: + self._inner = inner + + def __getattr__(self, name: str) -> Any: + return getattr(self._inner, name) + + def add_user_pool_client_secret(self, **kwargs: Any) -> dict[str, Any]: + response = self._inner.add_user_pool_client_secret(**kwargs) + return dict(response.pop("ClientSecretDescriptor")) + + +class _FlatteningSession(StubbedSession): + def client(self, name: str, region_name: str | None = None) -> Any: + real = super().client(name, region_name) + return _FlatteningIdp(real) if name == "cognito-idp" else real + + +@pytest.fixture +def flattening_session() -> Iterator[StubbedSession]: + stubbed = _FlatteningSession() + yield stubbed + for stub in stubbed.stubs.values(): + stub.deactivate() + + +def test_an_unreadable_add_response_deletes_the_new_secret_and_writes_no_file( + aws_config: None, + tmp_path: Path, + capsys: pytest.CaptureFixture[str], + flattening_session: StubbedSession, +) -> None: + session = flattening_session + _expect_identity(session) + _expect_list(session, [OLD_ID]) + _expect_add(session) + _expect_list(session, [OLD_ID, NEW_ID]) + _expect_delete(session, NEW_ID) + endpoint = _happy_endpoint() + + run = _run(tmp_path, capsys, session, endpoint) + + assert run.rc != 0 + session.assert_drained() + assert "step add" in run.err and f"deleted {NEW_ID}" in run.err + assert f"old secret {OLD_ID} intact" in run.err + assert not run.secret_out.exists() + assert endpoint.seen == [] + _assert_no_secret_printed(run) + + +def test_an_unreadable_add_response_whose_rollback_fails_names_the_remaining_secret( + aws_config: None, + tmp_path: Path, + capsys: pytest.CaptureFixture[str], + flattening_session: StubbedSession, +) -> None: + session = flattening_session + _expect_identity(session) + _expect_list(session, [OLD_ID]) + _expect_add(session) + _expect_list(session, [OLD_ID, NEW_ID]) + _expect_delete_error(session, NEW_ID) + + run = _run(tmp_path, capsys, session, _happy_endpoint()) + + assert run.rc != 0 + session.assert_drained() + assert "ALSO failed" in run.err and f"{NEW_ID} ALSO failed" in run.err + assert not run.secret_out.exists() + _assert_no_secret_printed(run) + + +def test_an_unreadable_add_response_whose_lookup_fails_warns_of_a_possible_orphan( + aws_config: None, + tmp_path: Path, + capsys: pytest.CaptureFixture[str], + flattening_session: StubbedSession, +) -> None: + session = flattening_session + _expect_identity(session) + _expect_list(session, [OLD_ID]) + _expect_add(session) + session.idp.add_client_error( + "list_user_pool_client_secrets", + service_error_code="TooManyRequestsException", + expected_params=dict(POOL), + ) + + run = _run(tmp_path, capsys, session, _happy_endpoint()) + + assert run.rc != 0 + session.assert_drained() + assert "may remain active" in run.err + assert not run.secret_out.exists() + _assert_no_secret_printed(run) diff --git a/tests/unit/test_runs_lock.py b/tests/unit/test_runs_lock.py index ff0d373..d01a133 100644 --- a/tests/unit/test_runs_lock.py +++ b/tests/unit/test_runs_lock.py @@ -32,6 +32,7 @@ NOW = datetime(2026, 10, 8, 12, 0, tzinfo=UTC) MACHINE = "arn:aws:states:us-east-1:123456789012:stateMachine:eval_sweep" ARN = "arn:aws:states:us-east-1:123456789012:execution:eval_sweep:r1" +_ADMIN = Identity(rep_id="rep-admin", full_visibility=True) def identity() -> Identity: @@ -305,18 +306,18 @@ def test_a_lock_with_no_record_is_released_only_once_stale(self, store: Store) - def test_unlock_refuses_a_running_execution(self, store: Store) -> None: _started(store) with pytest.raises(Conflict, match="still running"): - runs.unlock(store, Sfn("RUNNING"), now=NOW) + runs.unlock(store, Sfn("RUNNING"), identity=_ADMIN, now=NOW) assert runs.read_lock(store) is not None def test_unlock_refuses_a_fresh_queued_holder(self, store: Store) -> None: _started(store, arn=None) with pytest.raises(Conflict, match="starting"): - runs.unlock(store, Sfn(), now=NOW + timedelta(seconds=5)) + runs.unlock(store, Sfn(), identity=_ADMIN, now=NOW + timedelta(seconds=5)) assert runs.read_lock(store) is not None def test_unlock_releases_after_an_aborted_execution(self, store: Store) -> None: _started(store) - assert runs.unlock(store, Sfn("ABORTED"), now=NOW) == { + assert runs.unlock(store, Sfn("ABORTED"), identity=_ADMIN, now=NOW) == { "released": True, "holder_run_id": "r1", } @@ -330,7 +331,7 @@ def test_unlock_reports_not_released_when_another_caller_released_first( _started(store) monkeypatch.setattr(runs, "reconcile_lock", lambda *_a, **_k: runs.read_lock(store)) monkeypatch.setattr(runs, "release_lock", lambda *_a, **_k: False) - assert runs.unlock(store, Sfn("ABORTED"), now=NOW) == { + assert runs.unlock(store, Sfn("ABORTED"), identity=_ADMIN, now=NOW) == { "released": False, "holder_run_id": "r1", } @@ -338,12 +339,15 @@ def test_unlock_reports_not_released_when_another_caller_released_first( def test_unlock_releases_a_succeeded_execution_that_never_finalized(self, store: Store) -> None: _started(store) - assert runs.unlock(store, Sfn("SUCCEEDED"), now=NOW)["released"] is True + assert runs.unlock(store, Sfn("SUCCEEDED"), identity=_ADMIN, now=NOW)["released"] is True assert runs.read_lock(store) is None assert runs.require_run(store, "r1").status == "failed" def test_unlock_with_no_lock_is_a_no_op(self, store: Store) -> None: - assert runs.unlock(store, Sfn(), now=NOW) == {"released": False, "holder_run_id": None} + assert runs.unlock(store, Sfn(), identity=_ADMIN, now=NOW) == { + "released": False, + "holder_run_id": None, + } class TestDailyLiveCap: diff --git a/tests/unit/test_runtime_entrypoint.py b/tests/unit/test_runtime_entrypoint.py index 33f5346..949f50c 100644 --- a/tests/unit/test_runtime_entrypoint.py +++ b/tests/unit/test_runtime_entrypoint.py @@ -13,12 +13,19 @@ from pathlib import Path import pytest +import yaml from agents.budget import CHAT_BUDGET +from agents.cancellation import InMemoryCancellationStore, SessionOwner +from agents.conversation_history import InMemoryConversationHistory from agents.events import AgentEvent from agents.runtime_entrypoint import ( + MAX_EVENTS_PER_SESSION, + MAX_ROUND_OUTPUT_TOKENS, + PROMPT_MAX_CHARS, InMemorySessionStore, RuntimeInvocation, + SessionStore, build_supervisor_turn, decode_invocation, format_sse_line, @@ -31,13 +38,23 @@ from providers.capabilities import CapabilityMatrix, Family, load_capability_matrix from providers.stub import StubProvider from providers.tier_tuning import TIERS, WIRE_SCHEMA_VERSION, TurnTuning +from tests.conftest import TEST_API_CLIENT_ID REPO_ROOT = Path(__file__).resolve().parents[2] _APIGW_PAYLOAD = { "requestContext": { "requestId": "req-1", - "authorizer": {"jwt": {"claims": {"custom:rep_id": "rep-1", "custom:book": "acc-1,acc-2"}}}, + "authorizer": { + "jwt": { + "claims": { + "custom:rep_id": "rep-1", + "custom:book": "acc-1,acc-2", + "token_use": "id", + "aud": TEST_API_CLIENT_ID, + } + } + }, }, "prompt": "What is the status of Acme?", "session_id": "session-abc", @@ -248,13 +265,45 @@ def test_decode_invocation_succeeds_and_carries_prompt_and_session_id() -> None: assert invocation.identity.rep_id == "rep-1" +def test_decode_invocation_accepts_a_prompt_of_exactly_the_cap() -> None: + matrix = load_capability_matrix() + invocation = decode_invocation({**_APIGW_PAYLOAD, "prompt": "x" * PROMPT_MAX_CHARS}, matrix) + assert len(invocation.prompt) == PROMPT_MAX_CHARS + + +def test_decode_invocation_rejects_a_prompt_one_character_over_the_cap() -> None: + """An over-long prompt is a validation failure naming the prompt, before any turn is built.""" + matrix = load_capability_matrix() + with pytest.raises(ValidationFailed) as exc_info: + decode_invocation({**_APIGW_PAYLOAD, "prompt": "x" * (PROMPT_MAX_CHARS + 1)}, matrix) + assert exc_info.value.source == "agent.invocation.prompt" + assert str(PROMPT_MAX_CHARS) in str(exc_info.value) + + +def test_decode_invocation_counts_code_points_not_utf16_units() -> None: + """A prompt of cap-many astral characters is at the cap, not twice over it.""" + matrix = load_capability_matrix() + invocation = decode_invocation( + {**_APIGW_PAYLOAD, "prompt": "\U0001f600" * PROMPT_MAX_CHARS}, matrix + ) + assert len(invocation.prompt) == PROMPT_MAX_CHARS + + def test_decode_invocation_falls_back_to_identity_session_id_when_payload_omits_one() -> None: """A payload with no top-level session_id uses the identity's own session id instead.""" matrix = load_capability_matrix() payload = { "requestContext": { "requestId": "req-9", - "authorizer": {"jwt": {"claims": {"custom:rep_id": "rep-2"}}}, + "authorizer": { + "jwt": { + "claims": { + "custom:rep_id": "rep-2", + "token_use": "id", + "aud": TEST_API_CLIENT_ID, + } + } + }, }, "prompt": "hello", } @@ -397,6 +446,180 @@ def test_in_memory_session_store_sequence_numbers_are_stable_and_monotonic() -> assert seq2 == 2 +def _texts(events: tuple[AgentEvent, ...]) -> list[str | None]: + return [event.text for event in events] + + +def _fill(store: InMemorySessionStore, session_id: str, count: int) -> None: + for index in range(1, count + 1): + store.append(session_id, AgentEvent(kind="completed", text=f"e{index}")) + + +def test_in_memory_session_store_drops_the_oldest_events_past_its_bound() -> None: + """Appending past `max_events` keeps only the newest `max_events` events.""" + store = InMemorySessionStore(max_events=3) + _fill(store, "sess-b", 5) + + assert _texts(store.events_after("sess-b", sequence=0)) == ["e3", "e4", "e5"] + + +def test_in_memory_session_store_keeps_counting_sequences_across_drops() -> None: + """A dropped event's sequence number is never reused.""" + store = InMemorySessionStore(max_events=2) + _fill(store, "sess-b", 4) + + assert store.last_sequence("sess-b") == 4 + assert store.append("sess-b", AgentEvent(kind="completed", text="e5")) == 5 + + +def test_in_memory_session_store_events_after_is_exact_inside_the_window() -> None: + """Resuming from any sequence whose successors are all retained returns exactly those.""" + store = InMemorySessionStore(max_events=3) + _fill(store, "sess-b", 6) + + assert _texts(store.events_after("sess-b", sequence=3)) == ["e4", "e5", "e6"] + assert _texts(store.events_after("sess-b", sequence=4)) == ["e5", "e6"] + assert store.events_after("sess-b", sequence=6) == () + + +def test_in_memory_session_store_bounds_each_session_independently() -> None: + """One session's volume never drops another session's events.""" + store = InMemorySessionStore(max_events=2) + _fill(store, "busy", 10) + _fill(store, "quiet", 2) + + assert _texts(store.events_after("quiet", sequence=0)) == ["e1", "e2"] + + +@pytest.mark.parametrize("bad", [0, -1, True]) +def test_in_memory_session_store_rejects_a_non_positive_bound(bad: int) -> None: + with pytest.raises(ValueError, match="max_events"): + InMemorySessionStore(max_events=bad) + + +def test_in_memory_session_store_defaults_to_the_per_session_bound() -> None: + assert InMemorySessionStore().max_events == MAX_EVENTS_PER_SESSION + + +def test_run_turn_replays_a_whole_turn_that_exactly_fills_the_bound() -> None: + """A turn recording exactly `max_events` events resumes from 0 with nothing lost.""" + store = InMemorySessionStore(max_events=4) + invocation = _fake_invocation(session_id="sess-full") + turn = [AgentEvent(kind="completed", text=f"e{index}") for index in range(1, 5)] + list(run_turn(invocation, iter(turn), store=store, resume_from=0)) + + replayed = list(run_turn(invocation, iter([]), store=store, resume_from=0)) + + assert [json.loads(line[len("data: ") : -2])["text"] for line in replayed] == [ + "e1", + "e2", + "e3", + "e4", + ] + + +def test_run_turn_resumes_the_latest_turn_after_earlier_turns_were_dropped() -> None: + """Later turns push earlier ones out; resuming inside the latest turn is still exact.""" + store = InMemorySessionStore(max_events=3) + invocation = _fake_invocation(session_id="sess-many") + for turn_number in range(1, 4): + turn = [AgentEvent(kind="completed", text=f"t{turn_number}e{i}") for i in range(1, 4)] + list( + run_turn( + invocation, iter(turn), store=store, resume_from=store.last_sequence("sess-many") + ) + ) + + replayed = list(run_turn(invocation, iter([]), store=store, resume_from=7)) + + assert [json.loads(line[len("data: ") : -2])["text"] for line in replayed] == ["t3e2", "t3e3"] + + +def _sse_texts(lines: list[str]) -> list[str]: + return [json.loads(line[len("data: ") : -2])["text"] for line in lines] + + +def _run_fresh_turn( + store: SessionStore, invocation: RuntimeInvocation, texts: list[str] +) -> list[str]: + turn = iter([AgentEvent(kind="completed", text=text) for text in texts]) + resume_from = store.last_sequence(invocation.session_id) + return list(run_turn(invocation, turn, store=store, resume_from=resume_from)) + + +def test_run_turn_keeps_only_the_latest_turn_however_many_turns_ran() -> None: + """Across-turn growth is bounded to one turn: a fresh turn drops every earlier turn's events.""" + store = InMemorySessionStore() + invocation = _fake_invocation(session_id="sess-turns") + for turn_number in range(1, 6): + _run_fresh_turn(store, invocation, [f"t{turn_number}e{i}" for i in range(1, 5)]) + + assert store.last_sequence("sess-turns") == 20 + assert _texts(store.events_after("sess-turns", sequence=0)) == ["t5e1", "t5e2", "t5e3", "t5e4"] + + +def test_run_turn_resume_inside_a_later_turn_returns_every_event_after_the_cursor() -> None: + """Sequence numbers continue across turns, so a cursor inside the latest turn resumes exactly.""" + store = InMemorySessionStore() + invocation = _fake_invocation(session_id="sess-resume") + _run_fresh_turn(store, invocation, ["t1e1", "t1e2", "t1e3"]) + _run_fresh_turn(store, invocation, ["t2e1", "t2e2", "t2e3", "t2e4"]) + + replayed = list(run_turn(invocation, iter([]), store=store, resume_from=4)) + + assert _sse_texts(replayed) == ["t2e2", "t2e3", "t2e4"] + + +def test_begin_turn_keeps_the_sequence_counter_and_ignores_an_unknown_session() -> None: + store = InMemorySessionStore() + store.begin_turn("never-seen") + _fill(store, "sess-c", 3) + + store.begin_turn("sess-c") + + assert store.events_after("sess-c", sequence=0) == () + assert store.last_sequence("sess-c") == 3 + assert store.append("sess-c", AgentEvent(kind="completed", text="next")) == 4 + + +def test_a_fresh_turn_leaves_the_history_and_cancellation_stores_untouched() -> None: + """Dropping a session's earlier events never clears its conversation history or cancel marker.""" + store = InMemorySessionStore() + history = InMemoryConversationHistory() + cancellation = InMemoryCancellationStore() + invocation = _fake_invocation(session_id="sess-side") + owner = SessionOwner.of(invocation.identity) + history.record_turn("sess-side", identity=invocation.identity, prompt="p1", answer="a1") + cancellation.register_turn("sess-side", owner=owner) + cancellation.request_cancellation("sess-side", requester=owner) + + _run_fresh_turn(store, invocation, ["t1e1"]) + _run_fresh_turn(store, invocation, ["t2e1"]) + + assert [ + turn.prompt for turn in history.history_for("sess-side", identity=invocation.identity) + ] == ["p1"] + assert cancellation.is_cancelled("sess-side") + + +def _configured_max_output_tokens(node: object) -> list[int]: + if isinstance(node, dict): + found = [v for k, v in node.items() if k == "max_output_tokens" and isinstance(v, int)] + return found + [n for v in node.values() for n in _configured_max_output_tokens(v)] + if isinstance(node, list): + return [n for v in node for n in _configured_max_output_tokens(v)] + return [] + + +def test_round_output_cap_covers_every_configured_model() -> None: + """The per-round output cap the bound is built from is at least every model's own cap.""" + config = yaml.safe_load((REPO_ROOT / "config" / "model_capabilities.yaml").read_text()) + caps = _configured_max_output_tokens(config) + + assert caps + assert max(caps) <= MAX_ROUND_OUTPUT_TOKENS + + # -------------------------------------------------------------------------------------- # End-to-end smoke: decode -> build turn -> stream one event set through SSE framing. # No live model call; StubProvider only. diff --git a/tests/unit/test_runtime_server.py b/tests/unit/test_runtime_server.py index d35dd4f..19f2817 100644 --- a/tests/unit/test_runtime_server.py +++ b/tests/unit/test_runtime_server.py @@ -42,6 +42,7 @@ from crm.toolspec.definitions import BY_NAME from providers.base import ModelProvider, ProviderEvent, ResolvedInvocation from providers.tier_tuning import WIRE_SCHEMA_VERSION +from tests.conftest import TEST_API_CLIENT_ID def _identity_block(claims: dict[str, Any], *, session_id: str | None = None) -> dict[str, Any]: @@ -1278,7 +1279,15 @@ def test_the_offline_identity_seam_is_unreachable_over_http(client: TestClient) seam_payload: dict[str, Any] = { "requestContext": { "requestId": "req-1", - "authorizer": {"jwt": {"claims": {CLAIM_REP_ID: "rep-seam"}}}, + "authorizer": { + "jwt": { + "claims": { + CLAIM_REP_ID: "rep-seam", + "token_use": "id", + "aud": TEST_API_CLIENT_ID, + } + } + }, }, "prompt": "hello", "session_id": "s1", diff --git a/tests/unit/test_scan_residue_coverage.py b/tests/unit/test_scan_residue_coverage.py index b2c8b00..a1ad1be 100644 --- a/tests/unit/test_scan_residue_coverage.py +++ b/tests/unit/test_scan_residue_coverage.py @@ -46,6 +46,10 @@ "cloudfront", f"arn:aws:cloudfront::{_ACCT}:origin-request-policy/p-1", ), + "aws_cloudfront_response_headers_policy": ( + "cloudfront", + f"arn:aws:cloudfront::{_ACCT}:response-headers-policy/p-1", + ), "aws_cloudfront_vpc_origin": ("cloudfront", f"arn:aws:cloudfront::{_ACCT}:vpcorigin/vo-1"), "aws_cloudtrail": ("cloudtrail", f"arn:aws:cloudtrail:{_R}:{_ACCT}:trail/crm-agent-eval"), "aws_cloudwatch_log_group": ( @@ -142,6 +146,10 @@ "listed by name with arn None, so not matchable by ARN; any tag hit stays " "tagged-unscanned residue (fail-safe, never stale)" ), + "aws_cloudfront_response_headers_policy": ( + "listed by name with arn None, so not matchable by ARN; any tag hit stays " + "tagged-unscanned residue (fail-safe, never stale)" + ), } diff --git a/tests/unit/test_sdk_transport.py b/tests/unit/test_sdk_transport.py index 4dfbf81..5f647d9 100644 --- a/tests/unit/test_sdk_transport.py +++ b/tests/unit/test_sdk_transport.py @@ -1,5 +1,5 @@ # SPDX-License-Identifier: MIT -"""The shared SDK transport: attempt recording, deadline, lock-down, logger levels. +"""The shared SDK transport: attempt recording, deadline, lock-down, environment, logger levels. Retry, credential and logging assertions drive the real vendor SDK clients over an ``httpx2.MockTransport``. No network is reached and no AWS call is made. @@ -7,10 +7,13 @@ from __future__ import annotations +import ast import asyncio import dataclasses import logging from collections.abc import AsyncGenerator, AsyncIterator, Callable, Iterator +from contextlib import contextmanager +from pathlib import Path from typing import Any import anthropic @@ -24,9 +27,11 @@ from opentelemetry.sdk.trace import TracerProvider from opentelemetry.sdk.trace.export import SimpleSpanProcessor from opentelemetry.sdk.trace.export.in_memory_span_exporter import InMemorySpanExporter +from scripts import check_lambda_zip_imports +from agents import runtime_server from eval.live import is_retryable_error -from providers import sdk_transport +from providers import sdk_loggers, sdk_transport from providers.base import ProviderEvent, RetriedAttempt from providers.sdk_transport import ( MODEL_CALL_DEADLINE_SECONDS, @@ -65,7 +70,16 @@ "AWS_BEDROCK_BASE_URL", "ANTHROPIC_BEDROCK_BASE_URL", ) -QUIETED_LOGGERS = ("anthropic", "openai", "httpx2", "httpcore2") +QUIETED_LOGGERS = ( + "anthropic", + "openai", + "httpx2", + "httpcore2", + "botocore", + "boto3", + "urllib3", + "s3transfer", +) Handler = Callable[[httpx2.Request], httpx2.Response] @@ -722,6 +736,212 @@ def test_client_build_restores_warning_after_an_sdk_lowered_the_level() -> None: assert {logging.getLogger(n).level for n in QUIETED_LOGGERS} == {logging.WARNING} +def test_sdk_loggers_cover_the_boto3_family_and_its_http_stack() -> None: + assert set(sdk_transport.SDK_LOGGERS) == set(QUIETED_LOGGERS) + + +@contextmanager +def _isolated_root_logging() -> Iterator[None]: + """Run with no root handler and every quieted logger at NOTSET; restore all of it afterwards. + + Entered inside the test body, since pytest attaches its own root handlers per test phase. + """ + root = logging.getLogger() + saved_handlers = list(root.handlers) + saved_root_level = root.level + saved_levels = {name: logging.getLogger(name).level for name in QUIETED_LOGGERS} + root.handlers.clear() + for name in QUIETED_LOGGERS: + logging.getLogger(name).setLevel(logging.NOTSET) + try: + yield + finally: + root.handlers[:] = saved_handlers + root.setLevel(saved_root_level) + for name, level in saved_levels.items(): + logging.getLogger(name).setLevel(level) + + +def _effective_levels_below_warning() -> dict[str, str]: + return { + name: logging.getLevelName(logging.getLogger(name).getEffectiveLevel()) + for name in QUIETED_LOGGERS + if logging.getLogger(name).getEffectiveLevel() < logging.WARNING + } + + +def test_runtime_debug_logging_leaves_every_sdk_logger_at_warning( + monkeypatch: pytest.MonkeyPatch, +) -> None: + monkeypatch.setenv("LOG_LEVEL", "DEBUG") + with _isolated_root_logging(): + runtime_server.configure_logging() + + assert logging.getLogger().level == logging.DEBUG + assert _effective_levels_below_warning() == {} + + +def test_runtime_debug_logging_quiets_sdk_loggers_when_a_root_handler_already_exists( + monkeypatch: pytest.MonkeyPatch, +) -> None: + monkeypatch.setenv("LOG_LEVEL", "DEBUG") + with _isolated_root_logging(): + logging.getLogger().addHandler(logging.NullHandler()) + logging.getLogger().setLevel(logging.DEBUG) + + runtime_server.configure_logging() + + assert _effective_levels_below_warning() == {} + + +def test_control_a_debug_root_alone_lowers_every_sdk_logger() -> None: + with _isolated_root_logging(): + logging.basicConfig(level=logging.DEBUG) + + assert set(_effective_levels_below_warning()) == set(QUIETED_LOGGERS) + + +def test_no_botocore_debug_record_reaches_the_root_after_runtime_debug_logging( + monkeypatch: pytest.MonkeyPatch, +) -> None: + monkeypatch.setenv("LOG_LEVEL", "DEBUG") + with _isolated_root_logging(): + runtime_server.configure_logging() + handler = _Capture() + logging.getLogger().addHandler(handler) + + logging.getLogger("botocore.endpoint").debug("Sending http request: body=secret") + logging.getLogger("urllib3.connectionpool").debug("https://example.invalid:443 GET /") + + assert handler.records == [] + + +_SRC = Path(__file__).resolve().parents[2] / "src" +_ADAPTERS = frozenset({"providers.anthropic_adapter", "providers.openai_adapter"}) + + +def _source_file(module: str) -> Path | None: + candidate = _SRC.joinpath(*module.split(".")) + if candidate.with_suffix(".py").is_file(): + return candidate.with_suffix(".py") + if (candidate / "__init__.py").is_file(): + return candidate / "__init__.py" + return None + + +def _first_party_closure(root: str, *, stop_at: frozenset[str] = frozenset()) -> set[str]: + """Every first-party module `root` can import, function-body imports included. + + Parsed with the zip gate's own import collector; modules in `stop_at` are not entered. + """ + seen: set[str] = set() + pending = [root] + while pending: + module = pending.pop() + path = _source_file(module) + if module in seen or module in stop_at or path is None: + continue + seen.add(module) + package = module if path.name == "__init__.py" else module.rpartition(".")[0] + parents = [".".join(module.split(".")[:i]) for i in range(1, module.count(".") + 1)] + targets = check_lambda_zip_imports._import_targets(ast.parse(path.read_text()), package) + pending += parents + [target for target, _optional in targets] + return seen + + +def _eval_trigger_zip_handler_modules() -> list[str]: + specs = check_lambda_zip_imports.expected_zips() + return sorted({spec.module for spec in specs if spec.zip_name == "eval_trigger.zip"}) + + +def test_no_eval_trigger_zip_handler_reaches_the_sdk_transport_except_via_an_adapter() -> None: + handlers = _eval_trigger_zip_handler_modules() + assert "crm.handlers.eval_trigger" in handlers + reaching = [ + handler + for handler in handlers + if "providers.sdk_transport" in _first_party_closure(handler, stop_at=_ADAPTERS) + ] + assert reaching == [] + + +def test_control_the_closure_walk_reaches_the_sdk_transport_through_an_adapter() -> None: + assert "providers.sdk_transport" in _first_party_closure("providers.anthropic_adapter") + + +def test_the_runtime_server_reaches_the_logger_set_but_not_the_sdk_transport() -> None: + closure = _first_party_closure("agents.runtime_server", stop_at=_ADAPTERS) + assert "providers.sdk_loggers" in closure + assert "providers.sdk_transport" not in closure + + +def test_sdk_transport_re_exports_the_logger_set_and_quieting() -> None: + assert sdk_transport.SDK_LOGGERS is sdk_loggers.SDK_LOGGERS + assert sdk_transport.quiet_sdk_loggers is sdk_loggers.quiet_sdk_loggers + + +# --- Environment lock-down ------------------------------------------------------------------------ + +_PROXY_ENV_VARS = ("HTTPS_PROXY", "HTTP_PROXY", "ALL_PROXY", "https_proxy", "all_proxy") + + +def _close(client: httpx2.AsyncClient) -> None: + asyncio.run(client.aclose()) + + +def _mounted_proxies(client: httpx2.AsyncClient) -> dict[str, object]: + return { + str(pattern.pattern): transport + for pattern, transport in client._mounts.items() + if transport + } + + +@pytest.fixture +def proxy_env(monkeypatch: pytest.MonkeyPatch) -> None: + for name in ("NO_PROXY", "no_proxy"): + monkeypatch.delenv(name, raising=False) + for name in _PROXY_ENV_VARS: + monkeypatch.setenv(name, "http://proxy.example.invalid:3128") + + +def test_shared_client_does_not_trust_the_environment() -> None: + client = build_http_client() + try: + assert client.trust_env is False + finally: + _close(client) + + +@pytest.mark.usefixtures("proxy_env") +def test_proxy_environment_variables_mount_no_proxy_on_the_shared_client() -> None: + client = build_http_client() + try: + assert _mounted_proxies(client) == {} + finally: + _close(client) + + +@pytest.mark.usefixtures("proxy_env") +def test_control_a_default_client_mounts_the_environment_proxy() -> None: + client = httpx2.AsyncClient() + try: + assert "all://" in _mounted_proxies(client) + finally: + _close(client) + + +def test_ssl_cert_file_from_the_environment_is_not_loaded( + monkeypatch: pytest.MonkeyPatch, tmp_path: Path +) -> None: + monkeypatch.setenv("SSL_CERT_FILE", str(tmp_path / "absent-ca-bundle.pem")) + + _close(build_http_client()) + + with pytest.raises(FileNotFoundError): + httpx2.AsyncClient() + + # --- Exhausted-error rendering -------------------------------------------------------------------- _STATUS_BY_CLASS = { diff --git a/tests/unit/test_search_accounts.py b/tests/unit/test_search_accounts.py index 92ed2fe..a0e8517 100644 --- a/tests/unit/test_search_accounts.py +++ b/tests/unit/test_search_accounts.py @@ -256,3 +256,32 @@ def test_an_empty_owner_filter_is_a_validation_error_not_a_crash(store: Store) - with pytest.raises(ValidationFailed) as raised: search_accounts(store, identity, owner_rep_id="") assert raised.value.source == "owner_rep_id" + + +def test_out_of_book_accounts_below_the_budget_are_neither_counted_nor_cause_truncation( + store: Store, +) -> None: + for index in range(5): + _seed_account(store, account_id=f"acct-out-{index}") + scoped = Identity(rep_id=_OWNER, book=frozenset({"acct-in-book"}), tenant=_TENANT) + + result = search_accounts(store, scoped, limit=1) + + assert result.items == [] + assert result.examined_count == 0 + assert result.truncated is False + assert result.next_cursor is None + + +def test_a_search_accounts_cursor_replayed_by_another_rep_is_refused( + store: Store, identity: Identity +) -> None: + _seed_many(store, EXAMINATION_BUDGET + 10) + first = search_accounts(store, identity, query="cascadia") + assert first.next_cursor is not None + other = Identity(rep_id="rep-2", full_visibility=True, tenant=_TENANT) + + with pytest.raises(ValidationFailed) as refused: + search_accounts(store, other, query="cascadia", cursor=first.next_cursor) + + assert refused.value.source == "cursor" diff --git a/tests/unit/test_search_ceiling.py b/tests/unit/test_search_ceiling.py index abc5f68..ca0426b 100644 --- a/tests/unit/test_search_ceiling.py +++ b/tests/unit/test_search_ceiling.py @@ -6,6 +6,7 @@ from __future__ import annotations +import base64 from collections.abc import Iterator import boto3 @@ -13,8 +14,9 @@ from moto import mock_aws from crm.authz import Identity +from crm.cursor import bound_operation, decode_cursor, encode_cursor from crm.errors import ScopeDenied, ValidationFailed -from crm.search import EXAMINATION_BUDGET, decode_cursor, encode_cursor, search_opportunities +from crm.search import EXAMINATION_BUDGET, search_opportunities from crm.store.provisioning import create_all_tables from crm.store.store import Store @@ -81,6 +83,11 @@ def _seed_many(store: Store, count: int, **kwargs: object) -> None: _seed_opportunity(store, opportunity_id=f"opp-{i:05d}", **kwargs) # type: ignore[arg-type] +def _seed_many_named(store: Store, count: int, *, prefix: str, name: str) -> None: + for i in range(count): + _seed_opportunity(store, opportunity_id=f"{prefix}-{i:05d}", name=name) + + # -- basic contract ------------------------------------------------------------------------------ @@ -246,20 +253,61 @@ def test_limit_reached_before_budget_still_marks_truncated_when_index_not_exhaus assert result.truncated is True -def test_limit_truncation_with_no_cursor_is_still_never_silent( +def test_a_limit_cut_on_an_exhausted_index_still_issues_a_cursor_to_the_withheld_matches( store: Store, identity: Identity ) -> None: - """A limit-truncated page from an exhausted index has ``next_cursor`` None and ``truncated`` - True.""" + """A limit-truncated page from an exhausted index is ``truncated`` and carries a cursor.""" _seed_many(store, 20, name="Acme Renewal") result = search_opportunities(store, identity, query="acme", limit=5) assert result.truncated is True - assert result.next_cursor is None + assert result.next_cursor is not None assert len(result.items) == 5 +@pytest.mark.parametrize("limit", [1, 3, 7, 199, 201]) +def test_limited_paging_returns_every_match_exactly_once( + store: Store, identity: Identity, limit: int +) -> None: + _seed_many(store, 230, name="Acme Renewal") + _seed_many_named(store, 40, prefix="other", name="Globex Expansion") + + seen: list[str] = [] + cursor: str | None = None + for _ in range(300): + result = search_opportunities(store, identity, query="acme", limit=limit, cursor=cursor) + assert len(result.items) <= limit + seen.extend(str(item["opportunity_id"]) for item in result.items) + cursor = result.next_cursor + if cursor is None: + break + + assert cursor is None + assert len(seen) == len(set(seen)) + assert sorted(seen) == [f"opp-{i:05d}" for i in range(230)] + + +def test_limited_paging_with_out_of_book_rows_returns_every_in_scope_match_once( + store: Store, +) -> None: + for index in range(12): + account = _IN_BOOK if index % 3 == 0 else _OUT_OF_BOOK + _seed_opportunity(store, opportunity_id=f"opp-mix-{index:02d}", account_id=account) + scoped = Identity(rep_id=_OWNER, book=frozenset({_IN_BOOK}), tenant=_TENANT) + + seen: list[str] = [] + cursor: str | None = None + for _ in range(50): + result = search_opportunities(store, scoped, limit=1, cursor=cursor) + seen.extend(str(item["opportunity_id"]) for item in result.items) + cursor = result.next_cursor + if cursor is None: + break + + assert sorted(seen) == [f"opp-mix-{index:02d}" for index in range(0, 12, 3)] + + def test_limit_not_reached_and_index_exhausted_is_not_truncated( store: Store, identity: Identity ) -> None: @@ -272,40 +320,145 @@ def test_limit_not_reached_and_index_exhausted_is_not_truncated( assert result.next_cursor is None -# -- cursor encoding ------------------------------------------------------------------------------ +# -- cursor binding ------------------------------------------------------------------------------- -def test_encode_and_decode_cursor_round_trip() -> None: - page_key: dict[str, object] = { - "opportunity_id": {"S": "opp-1"}, - "tenant_stage": {"S": "demo#Discovery"}, - } +def test_search_rejects_a_malformed_cursor_argument(store: Store, identity: Identity) -> None: + with pytest.raises(ValidationFailed) as refused: + search_opportunities(store, identity, cursor="garbage") - token = encode_cursor(page_key) - decoded = decode_cursor(token) + assert refused.value.source == "cursor" - assert decoded == page_key +def test_a_next_cursor_does_not_carry_the_page_key_in_the_clear( + store: Store, identity: Identity +) -> None: + _seed_many(store, EXAMINATION_BUDGET + 10, name="Acme Renewal") -def test_decode_cursor_rejects_a_malformed_token() -> None: - with pytest.raises(ValidationFailed) as exc_info: - decode_cursor("not-a-valid-cursor!!!") + first = search_opportunities(store, identity, query="acme") - assert exc_info.value.source == "cursor" + assert first.next_cursor is not None + decoded = decode_cursor( + first.next_cursor, + identity=identity, + operation=bound_operation("search_opportunities", "gsi_tenant", _TENANT), + ) + assert decoded is not None + raw = base64.urlsafe_b64decode(first.next_cursor.encode("ascii")) + for attribute in decoded.values(): + for value in attribute.values(): + assert str(value).encode("utf-8") not in raw -def test_decode_cursor_rejects_a_token_that_decodes_to_a_non_mapping() -> None: - import base64 +@pytest.mark.parametrize( + "replayer", + [ + Identity(rep_id="rep-2", full_visibility=True, tenant=_TENANT), + Identity(rep_id=_OWNER, full_visibility=True, tenant="eval-other"), + ], + ids=["other-rep", "other-tenant"], +) +def test_a_cursor_replayed_by_another_caller_is_a_cursor_validation_failure( + store: Store, identity: Identity, replayer: Identity +) -> None: + _seed_many(store, EXAMINATION_BUDGET + 10, name="Acme Renewal") + first = search_opportunities(store, identity, query="acme") + assert first.next_cursor is not None - token = base64.urlsafe_b64encode(b'"just a string"').decode("ascii") + with pytest.raises(ValidationFailed) as refused: + search_opportunities(store, replayer, query="acme", cursor=first.next_cursor) - with pytest.raises(ValidationFailed): - decode_cursor(token) + assert refused.value.source == "cursor" -def test_search_rejects_a_malformed_cursor_argument(store: Store, identity: Identity) -> None: - with pytest.raises(ValidationFailed): - search_opportunities(store, identity, cursor="garbage") +def test_a_cursor_from_another_operation_is_a_cursor_validation_failure( + store: Store, identity: Identity +) -> None: + foreign = encode_cursor( + {"opportunity_id": {"S": "opp-00001"}, "tenant": {"S": _TENANT}}, + identity=identity, + operation="search_accounts", + ) + + with pytest.raises(ValidationFailed) as refused: + search_opportunities(store, identity, cursor=foreign) + + assert refused.value.source == "cursor" + + +@pytest.mark.parametrize( + "replay_filters", + [{}, {"stage": "Negotiation"}, {"owner_rep_id": "rep-2"}, {"account_id": "acct-2"}], + ids=["no-filter", "other-stage", "owner-index", "account-index"], +) +def test_a_cursor_replayed_with_different_index_selecting_filters_is_refused( + store: Store, identity: Identity, replay_filters: dict[str, str] +) -> None: + _seed_many(store, EXAMINATION_BUDGET + 10, name="Acme Renewal") + first = search_opportunities(store, identity, query="acme", stage="Discovery") + assert first.next_cursor is not None + + with pytest.raises(ValidationFailed) as refused: + search_opportunities( + store, + identity, + query="acme", + cursor=first.next_cursor, + stage=replay_filters.get("stage"), + owner_rep_id=replay_filters.get("owner_rep_id"), + account_id=replay_filters.get("account_id"), + ) + + assert refused.value.source == "cursor" + + +def test_a_cursor_replayed_with_the_same_filters_and_a_different_query_resumes( + store: Store, identity: Identity +) -> None: + _seed_many(store, EXAMINATION_BUDGET + 10, name="Acme Renewal") + first = search_opportunities(store, identity, query="acme", stage="Discovery") + assert first.next_cursor is not None + + second = search_opportunities( + store, identity, query="renewal", stage="Discovery", cursor=first.next_cursor + ) + + assert second.examined_count == 10 + + +# -- scope-filtered metadata ---------------------------------------------------------------------- + +_IN_BOOK = "acct-in-book" +_OUT_OF_BOOK = "acct-out-of-book" + + +def test_out_of_book_rows_below_the_budget_are_neither_counted_nor_cause_truncation( + store: Store, +) -> None: + for index in range(5): + _seed_opportunity(store, opportunity_id=f"opp-out-{index}", account_id=_OUT_OF_BOOK) + scoped = Identity(rep_id=_OWNER, book=frozenset({_IN_BOOK}), tenant=_TENANT) + + result = search_opportunities(store, scoped, limit=1) + + assert result.items == [] + assert result.examined_count == 0 + assert result.truncated is False + assert result.next_cursor is None + + +def test_examined_count_counts_only_in_scope_rows(store: Store) -> None: + for index in range(5): + _seed_opportunity(store, opportunity_id=f"opp-out-{index}", account_id=_OUT_OF_BOOK) + for index in range(2): + _seed_opportunity(store, opportunity_id=f"opp-in-{index}", account_id=_IN_BOOK) + scoped = Identity(rep_id=_OWNER, book=frozenset({_IN_BOOK}), tenant=_TENANT) + + result = search_opportunities(store, scoped, limit=1) + + assert [item["account_id"] for item in result.items] == [_IN_BOOK] + assert result.examined_count == 2 + assert result.truncated is True # -- the account filter and the returned fields ----------------------------- @@ -407,3 +560,52 @@ def test_an_empty_filter_is_a_validation_error_not_a_crash( with pytest.raises(ValidationFailed) as raised: search_opportunities(store, identity, **{field: ""}) # type: ignore[arg-type] assert raised.value.source == field + + +# -- store: client-side SDK failures map into the taxonomy ---------------------------------------- + + +@pytest.mark.parametrize( + "query", + [ + lambda store, key: store.query_gsi( + "opportunities", "gsi_tenant", partition_value=_TENANT, exclusive_start_key=key + ), + lambda store, key: store.query_tenant_scan( + "opportunities", tenant=_TENANT, exclusive_start_key=key + ), + ], + ids=["query_gsi", "query_tenant_scan"], +) +def test_a_parameter_the_sdk_rejects_is_an_internal_error_not_a_raw_sdk_error_or_a_400( + store: Store, query: object +) -> None: + from crm.errors import CrmError + + with pytest.raises(CrmError) as failed: + query(store, {"x": "y"}) # type: ignore[operator] + + assert type(failed.value) is CrmError + assert failed.value.http_status == 500 + + +@pytest.mark.parametrize("failure", ["unreachable", "read-timeout"]) +def test_an_unreachable_or_timed_out_endpoint_is_a_retryable_service_busy( + store: Store, monkeypatch: pytest.MonkeyPatch, failure: str +) -> None: + from botocore.exceptions import EndpointConnectionError, ReadTimeoutError + + from crm.errors import ServiceBusy + + def unreachable(**_: object) -> object: + if failure == "unreachable": + raise EndpointConnectionError(endpoint_url="https://dynamodb.invalid") + raise ReadTimeoutError(endpoint_url="https://dynamodb.invalid") + + monkeypatch.setattr(store._client, "query", unreachable) + + with pytest.raises(ServiceBusy) as failed: + store.query_tenant_scan("opportunities", tenant=_TENANT) + + assert failed.value.next_step == "retry_later" + assert "dynamodb.invalid" not in failed.value.message diff --git a/tests/unit/test_smoke_api_routes.py b/tests/unit/test_smoke_api_routes.py index f21e49b..af680ca 100644 --- a/tests/unit/test_smoke_api_routes.py +++ b/tests/unit/test_smoke_api_routes.py @@ -29,12 +29,14 @@ from crm.auth import pre_token_generation from crm.authz import ADMIN_GROUP +from crm.envelope import API_ALLOWED_CLIENT_IDS_PARAMETER_ENV from crm.handlers import eval_trigger as eval_trigger_handler from crm.store.provisioning import create_all_tables from crm.store.store import Store from crm.toolspec.definitions import ALL_TOOLS from eval.trigger import EVAL_ADMIN_SCOPE from eval.verification import CheckResult +from tests.conftest import TEST_API_CLIENT_ID from tests.unit import _jwks_test_key as test_key API_ENDPOINT = "https://abc123.execute-api.us-east-1.amazonaws.com" @@ -672,7 +674,9 @@ def _eval_trigger_v1_event(body: str, claims: Mapping[str, Any]) -> dict[str, An "path": "/eval_trigger", "httpMethod": "POST", "headers": {"content-type": "application/json"}, - "requestContext": {"authorizer": {"claims": dict(claims)}}, + "requestContext": { + "authorizer": {"claims": {**claims, "token_use": "id", "aud": TEST_API_CLIENT_ID}} + }, "body": body, "isBase64Encoded": False, } @@ -1456,3 +1460,511 @@ def test_update_contact_body_targets_an_active_seeded_contact_in_the_first_accou assert target["status"] == "active", target assert target["account_id"] == seeded_in_scope_account_id(tenant) assert "status" not in body["fields"] + + +# --------------------------------------------------------------------------- +# The deployed app-client allowlist and the direct-invoke audience probe. +# --------------------------------------------------------------------------- + +ALLOWLIST_PARAMETER = "/crm-x/api/allowed-client-ids" +FOREIGN_CLIENT_ID = "mcp-oauth-client-test" +ACCOUNT = "123456789012" +RUNTIME_ROLE = f"arn:aws:iam::{ACCOUNT}:role/crm-x-runtime" +RELAY_ROLE = f"arn:aws:iam::{ACCOUNT}:role/crm-x-relay" +PARAMETER_ARN = f"arn:aws:ssm:us-east-1:{ACCOUNT}:parameter/crm-x/api/allowed-client-ids" +IDENTITY_TOOLS = ["get_account", "search_accounts", "eval_trigger"] + + +def _function_name(tool: str) -> str: + return f"crm-x-{tool}" + + +def _role_of(tool: str) -> str: + return f"arn:aws:iam::{ACCOUNT}:role/crm-x-{tool}" + + +class _ApiWithIntegrations(FakeApiGatewayV2Client): + """The v1 fake plus `get_integration`, one Lambda proxy integration per route.""" + + def get_integration(self, **kwargs: Any) -> dict[str, Any]: + index = int(str(kwargs["resourceId"]).removeprefix("res")) + tool = self._route_keys[index].split(" ", 1)[1].lstrip("/") + function_arn = f"arn:aws:lambda:us-east-1:{ACCOUNT}:function:{_function_name(tool)}" + return { + "type": "AWS_PROXY", + "uri": "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/" + f"{function_arn}/invocations", + } + + +class _Payload: + def __init__(self, body: bytes) -> None: + self._body = body + + def read(self) -> bytes: + return self._body + + +class _FakeLambda: + """`get_function_configuration` per tool function, and an `invoke` that applies an allowlist.""" + + def __init__( + self, + *, + env_overrides: Mapping[str, Mapping[str, str | None]] | None = None, + admitted: frozenset[str] = frozenset({test_key.CLIENT_ID}), + function_error_for: frozenset[str] = frozenset(), + refusal_code: str = "authentication_failed", + ) -> None: + self._env_overrides = dict(env_overrides or {}) + self._admitted = admitted + self._function_error_for = function_error_for + self._refusal_code = refusal_code + self.invoked: list[dict[str, Any]] = [] + + def get_function_configuration(self, **kwargs: Any) -> dict[str, Any]: + name = str(kwargs["FunctionName"]) + tool = name.removeprefix("crm-x-") + variables: dict[str, str] = {API_ALLOWED_ENV: ALLOWLIST_PARAMETER} + for key, value in self._env_overrides.get(tool, {}).items(): + if value is None: + variables.pop(key, None) + else: + variables[key] = value + return { + "FunctionName": name, + "FunctionArn": f"arn:aws:lambda:us-east-1:{ACCOUNT}:function:{name}", + "Role": _role_of(tool), + "Environment": {"Variables": variables}, + } + + def invoke(self, **kwargs: Any) -> dict[str, Any]: + event = json.loads(kwargs["Payload"]) + self.invoked.append(event) + claims = event["requestContext"]["authorizer"]["claims"] + client = claims.get("aud") if claims.get("token_use") == "id" else claims.get("client_id") + response: dict[str, Any] = {} + if client in self._admitted: + body: dict[str, Any] = {"statusCode": 200, "body": json.dumps({"account": {}})} + if client in self._function_error_for: + response["FunctionError"] = "Unhandled" + else: + body = { + "statusCode": 401, + "body": json.dumps({"error": {"code": self._refusal_code, "message": "x"}}), + } + response["Payload"] = _Payload(json.dumps(body).encode()) + return response + + +class _FakeSsm: + def __init__( + self, + *, + value: str = test_key.CLIENT_ID, + parameter_type: str = "String", + tags: list[dict[str, str]] | None = None, + ) -> None: + self._value = value + self._type = parameter_type + self._tags = [{"Key": "data-classification", "Value": "internal"}] if tags is None else tags + + def get_parameter(self, **kwargs: Any) -> dict[str, Any]: + assert kwargs["Name"] == ALLOWLIST_PARAMETER, kwargs + return { + "Parameter": {"Name": ALLOWLIST_PARAMETER, "Value": self._value, "Type": self._type} + } + + def list_tags_for_resource(self, **kwargs: Any) -> dict[str, Any]: + assert kwargs == {"ResourceType": "Parameter", "ResourceId": ALLOWLIST_PARAMETER}, kwargs + return {"TagList": list(self._tags)} + + +class _FakeIam: + """Allows exactly `ssm:GetParameter` on the parameter for the API roles, plus any extra grant.""" + + def __init__( + self, + *, + extra_allowed: set[tuple[str, str, str]] | None = None, + withheld: set[str] | None = None, + missing_context: bool = False, + ) -> None: + self._extra = set(extra_allowed or set()) + self._withheld = set(withheld or set()) + self._missing_context = missing_context + self.calls: list[dict[str, Any]] = [] + + def simulate_principal_policy(self, **kwargs: Any) -> dict[str, Any]: + self.calls.append(kwargs) + role = str(kwargs["PolicySourceArn"]) + (resource,) = kwargs["ResourceArns"] + api_role = role in {_role_of(tool) for tool in IDENTITY_TOOLS} + results = [] + for action in kwargs["ActionNames"]: + allowed = ( + api_role + and role not in self._withheld + and action == "ssm:GetParameter" + and resource == PARAMETER_ARN + ) or (role, action, resource) in self._extra + results.append( + { + "EvalActionName": action, + "EvalDecision": "allowed" if allowed else "implicitDeny", + "MissingContextValues": ["aws:SourceIp"] if self._missing_context else [], + } + ) + return {"EvaluationResults": results} + + +class _FakeLogs: + def __init__(self, reasons: list[str] | None = None) -> None: + self._reasons = ( + ["authentication_failed: token aud is not an admitted app client"] + if reasons is None + else reasons + ) + self.calls = 0 + + def filter_log_events(self, **_kwargs: Any) -> dict[str, Any]: + self.calls += 1 + return { + "events": [ + { + "message": "2026-11-06T00:00:00Z\tINFO\t" + + json.dumps({"event": "crm_error", "reason": r}) + } + for r in self._reasons + ] + } + + +API_ALLOWED_ENV = API_ALLOWED_CLIENT_IDS_PARAMETER_ENV + + +def _identity_ctx( + *, + lambda_client: _FakeLambda | None = None, + ssm: _FakeSsm | None = None, + iam: _FakeIam | None = None, + logs: _FakeLogs | None = None, + route_keys: list[str] | None = None, +) -> Any: + return context_for_test( + outputs={ + "api_id": API_ID, + "cloudfront_domain_name": CLOUDFRONT_DOMAIN, + **COGNITO_OUTPUTS, + "cognito_mcp_oauth_client_id": FOREIGN_CLIENT_ID, + "agentcore_runtime_role_arn": RUNTIME_ROLE, + "agent_relay_role_arn": RELAY_ROLE, + }, + clients={ + "apigateway": _ApiWithIntegrations( + route_keys=route_keys or [f"POST /{tool}" for tool in IDENTITY_TOOLS] + ), + "lambda": lambda_client or _FakeLambda(), + "ssm": ssm or _FakeSsm(), + "iam": iam or _FakeIam(), + "logs": logs or _FakeLogs(), + }, + ) + + +def _allowlist_rows(ctx: Any) -> list[CheckResult]: + lambda_client = ctx.client("lambda") + names = api_routes.integrated_function_names(ctx.client("apigateway"), API_ID) + functions = [ + api_routes._describe_function(lambda_client, name) for name in sorted(set(names.values())) + ] + return list(api_routes.allowlist_checks(ctx, functions)) + + +def _failing(rows: list[CheckResult]) -> set[tuple[str, str]]: + return {(row.resource, row.check) for row in rows if row.status == "fail"} + + +class TestAllowlistChecks: + def test_the_deployed_shape_passes_every_row(self) -> None: + rows = _allowlist_rows(_identity_ctx()) + assert _failing(rows) == set() + checks_seen = {row.check for row in rows} + assert checks_seen == { + "resolve_integrated_functions", + "allowlist_parameter_env_set", + "legacy_allowlist_env_absent", + "allowlist_parameter_env_consistent", + "allowlist_parameter_value_is_spa_client", + "allowlist_parameter_type_string", + "allowlist_parameter_tagged", + "ssm_get_parameter_allowed", + "ssm_read_grant_is_exact_parameter", + "ssm_parameter_write_denied", + "ssm_get_parameter_denied_non_api_role", + } + + def test_the_integrated_set_comes_from_the_deployed_integrations(self) -> None: + names = api_routes.integrated_function_names( + _ApiWithIntegrations(route_keys=["POST /get_account", "POST /eval_trigger"]), API_ID + ) + assert names == { + "POST /get_account": _function_name("get_account"), + "POST /eval_trigger": _function_name("eval_trigger"), + } + + def test_no_integrated_function_fails_rather_than_passing_over_nothing(self) -> None: + rows = list(api_routes.allowlist_checks(_identity_ctx(), [])) + assert [(r.check, r.status) for r in rows] == [("resolve_integrated_functions", "fail")] + + def test_a_function_without_the_parameter_variable_fails_its_row_only(self) -> None: + ctx = _identity_ctx( + lambda_client=_FakeLambda(env_overrides={"search_accounts": {API_ALLOWED_ENV: None}}) + ) + assert _failing(_allowlist_rows(ctx)) == { + (f"function:{_function_name('search_accounts')}", "allowlist_parameter_env_set") + } + + def test_the_legacy_direct_variable_fails_its_row_only(self) -> None: + legacy = api_routes.LEGACY_ALLOWED_CLIENT_IDS_ENV + ctx = _identity_ctx( + lambda_client=_FakeLambda(env_overrides={"eval_trigger": {legacy: "x"}}) + ) + assert _failing(_allowlist_rows(ctx)) == { + (f"function:{_function_name('eval_trigger')}", "legacy_allowlist_env_absent") + } + + def test_functions_naming_different_parameters_fail_consistency(self) -> None: + ctx = _identity_ctx( + lambda_client=_FakeLambda(env_overrides={"get_account": {API_ALLOWED_ENV: "/other"}}) + ) + assert _failing(_allowlist_rows(ctx)) == { + (api_routes.RESOURCE_CLASS, "allowlist_parameter_env_consistent") + } + + @pytest.mark.parametrize( + "value", + [f"{test_key.CLIENT_ID},{FOREIGN_CLIENT_ID}", FOREIGN_CLIENT_ID, f" {test_key.CLIENT_ID}"], + ) + def test_a_parameter_value_other_than_the_spa_client_fails_its_row_only( + self, value: str + ) -> None: + ctx = _identity_ctx(ssm=_FakeSsm(value=value)) + assert _failing(_allowlist_rows(ctx)) == { + (f"parameter:{ALLOWLIST_PARAMETER}", "allowlist_parameter_value_is_spa_client") + } + + def test_a_string_list_parameter_fails_its_row_only(self) -> None: + ctx = _identity_ctx(ssm=_FakeSsm(parameter_type="StringList")) + assert _failing(_allowlist_rows(ctx)) == { + (f"parameter:{ALLOWLIST_PARAMETER}", "allowlist_parameter_type_string") + } + + def test_an_untagged_parameter_fails_its_row_only(self) -> None: + ctx = _identity_ctx(ssm=_FakeSsm(tags=[{"Key": "service", "Value": "crm"}])) + assert _failing(_allowlist_rows(ctx)) == { + (f"parameter:{ALLOWLIST_PARAMETER}", "allowlist_parameter_tagged") + } + + def test_an_api_role_without_the_read_grant_fails_its_row_only(self) -> None: + ctx = _identity_ctx(iam=_FakeIam(withheld={_role_of("get_account")})) + assert _failing(_allowlist_rows(ctx)) == { + ("role:crm-x-get_account", "ssm_get_parameter_allowed") + } + + def test_an_allowed_read_with_missing_context_is_not_a_pass(self) -> None: + failing = _failing(_allowlist_rows(_identity_ctx(iam=_FakeIam(missing_context=True)))) + assert failing == { + (f"role:crm-x-{tool}", "ssm_get_parameter_allowed") for tool in IDENTITY_TOOLS + } + + @pytest.mark.parametrize( + ("action", "resource"), + [ + ("ssm:GetParameter", f"arn:aws:ssm:us-east-1:{ACCOUNT}:parameter/crm-x/api/other"), + ("ssm:GetParameter", f"arn:aws:ssm:us-east-1:{ACCOUNT}:parameter/crm-x/*"), + ("ssm:GetParameters", PARAMETER_ARN), + ("ssm:GetParametersByPath", PARAMETER_ARN), + ], + ) + def test_a_wider_read_grant_fails_the_exactness_row_only( + self, action: str, resource: str + ) -> None: + iam = _FakeIam(extra_allowed={(_role_of("search_accounts"), action, resource)}) + assert _failing(_allowlist_rows(_identity_ctx(iam=iam))) == { + ("role:crm-x-search_accounts", "ssm_read_grant_is_exact_parameter") + } + + @pytest.mark.parametrize("action", api_routes.SSM_WRITE_ACTIONS) + @pytest.mark.parametrize("role", [RUNTIME_ROLE, _role_of("eval_trigger")]) + def test_a_write_grant_fails_the_write_row_only(self, action: str, role: str) -> None: + iam = _FakeIam(extra_allowed={(role, action, PARAMETER_ARN)}) + assert _failing(_allowlist_rows(_identity_ctx(iam=iam))) == { + (f"role:{role.rsplit('/', 1)[-1]}", "ssm_parameter_write_denied") + } + + def test_a_non_api_role_that_can_read_fails_its_row_only(self) -> None: + iam = _FakeIam(extra_allowed={(RELAY_ROLE, "ssm:GetParameter", PARAMETER_ARN)}) + assert _failing(_allowlist_rows(_identity_ctx(iam=iam))) == { + ("role:crm-x-relay", "ssm_get_parameter_denied_non_api_role") + } + + def test_the_parameter_arn_is_built_from_the_functions_account_and_region(self) -> None: + iam = _FakeIam() + _allowlist_rows(_identity_ctx(iam=iam)) + resources = {arn for call in iam.calls for arn in call["ResourceArns"]} + assert PARAMETER_ARN in resources + + +def _audience_function() -> api_routes.IntegratedFunction: + return api_routes._describe_function(_FakeLambda(), _function_name("get_account")) + + +def _audience_rows(ctx: Any, sleeps: list[float] | None = None) -> list[CheckResult]: + recorded = sleeps if sleeps is not None else [] + claims = test_key.id_token_claims( + **{"custom:tenant": SMOKE_TENANT, "custom:rep_id": "rep-1", "custom:book": "rep-1"} + ) + return list( + api_routes.audience_probe_checks( + ctx, + function=_audience_function(), + claims=claims, + tenant=SMOKE_TENANT, + sleep=recorded.append, + clock=lambda: 1_700_000_000.0, + ) + ) + + +AUDIENCE_RESOURCE = f"function:{_function_name('get_account')}" + + +class TestAudienceProbe: + def test_the_deployed_shape_passes_every_row(self) -> None: + lambda_client = _FakeLambda() + rows = _audience_rows(_identity_ctx(lambda_client=lambda_client)) + assert [(r.check, r.status) for r in rows] == [ + ("audience_foreign_id_token_refused", "pass"), + ("audience_spa_id_token_admitted", "pass"), + ("audience_foreign_access_token_refused", "pass"), + ("audience_refusal_logged_with_reason", "pass"), + ] + + def test_the_variants_differ_only_in_the_app_client_claims(self) -> None: + lambda_client = _FakeLambda() + _audience_rows(_identity_ctx(lambda_client=lambda_client)) + stripped = [ + { + k: v + for k, v in event["requestContext"]["authorizer"]["claims"].items() + if k not in {"aud", "client_id", "token_use"} + } + for event in lambda_client.invoked + ] + assert len(stripped) == 3 and stripped[0] == stripped[1] == stripped[2] + bodies = {event["body"] for event in lambda_client.invoked} + assert len(bodies) == 1 + + def test_a_lambda_admitting_any_client_fails_both_refusal_rows(self) -> None: + lambda_client = _FakeLambda(admitted=frozenset({test_key.CLIENT_ID, FOREIGN_CLIENT_ID})) + assert _failing(_audience_rows(_identity_ctx(lambda_client=lambda_client))) == { + (AUDIENCE_RESOURCE, "audience_foreign_id_token_refused"), + (AUDIENCE_RESOURCE, "audience_foreign_access_token_refused"), + } + + def test_a_lambda_refusing_the_spa_client_fails_the_admitted_row_only(self) -> None: + lambda_client = _FakeLambda(admitted=frozenset()) + assert _failing(_audience_rows(_identity_ctx(lambda_client=lambda_client))) == { + (AUDIENCE_RESOURCE, "audience_spa_id_token_admitted") + } + + def test_a_function_error_with_a_200_payload_is_not_admitted(self) -> None: + lambda_client = _FakeLambda(function_error_for=frozenset({test_key.CLIENT_ID})) + assert _failing(_audience_rows(_identity_ctx(lambda_client=lambda_client))) == { + (AUDIENCE_RESOURCE, "audience_spa_id_token_admitted") + } + + def test_a_401_with_another_error_code_is_not_the_audience_refusal(self) -> None: + lambda_client = _FakeLambda(refusal_code="internal_error") + assert _failing(_audience_rows(_identity_ctx(lambda_client=lambda_client))) == { + (AUDIENCE_RESOURCE, "audience_foreign_id_token_refused"), + (AUDIENCE_RESOURCE, "audience_foreign_access_token_refused"), + } + + @pytest.mark.parametrize( + "reasons", + [ + [], + ["internal_error: parameter=/crm-x/api/allowed-client-ids throttled"], + ["authentication_failed: parameter=/x token aud is not an admitted app client"], + ], + ) + def test_a_refusal_not_logged_as_the_client_check_fails_the_log_row_only( + self, reasons: list[str] + ) -> None: + sleeps: list[float] = [] + logs = _FakeLogs(reasons) + rows = _audience_rows(_identity_ctx(logs=logs), sleeps) + assert _failing(rows) == {(AUDIENCE_RESOURCE, "audience_refusal_logged_with_reason")} + assert logs.calls == api_routes.LOG_POLL_ATTEMPTS + assert len(sleeps) == api_routes.LOG_POLL_ATTEMPTS - 1 + + +def test_main_runs_the_deployed_identity_checks(monkeypatch: pytest.MonkeyPatch) -> None: + """`main` passes `deployed_identity_checks=True`, so the allowlist rows are never silently off.""" + seen: dict[str, Any] = {} + + def fake_checks(_ctx: Any, **kwargs: Any) -> list[CheckResult]: + seen.update(kwargs) + return [] + + def fake_run_main(_argv: Any, **kwargs: Any) -> int: + list(kwargs["checks"](object())) + return 0 + + monkeypatch.setattr(api_routes, "checks", fake_checks) + monkeypatch.setattr(api_routes, "run_main", fake_run_main) + assert api_routes.main([]) == 0 + assert seen.get("deployed_identity_checks") is True + + +def test_the_audience_probe_runs_inside_the_seeded_tenant_lifecycle() -> None: + """With the identity checks on, the probe rows land between seed and teardown.""" + events: list[str] = [] + + class _Lifecycle(_RecordingLifecycle): + def seed(self, tenant: str) -> None: + events.append("seed") + super().seed(tenant) + + def teardown(self, tenant: str) -> dict[str, int]: + events.append("teardown") + return super().teardown(tenant) + + lifecycle = _Lifecycle() + + def caller(_m: str, _u: str, headers: Mapping[str, str], _b: str) -> HttpResult: + return (200, "{}") if headers.get("Authorization") else (401, "") + + rows = [] + for row in checks( + _identity_ctx(), + http_caller=caller, + token=_fake_token(SMOKE_TENANT), + seeder=lifecycle.seed, + teardown=lifecycle.teardown, + deployed_identity_checks=True, + sleep=lambda _s: None, + ): + if row.check.startswith("audience_"): + events.append(row.check) + rows.append(row) + assert events[0] == "seed" and events[-1] == "teardown" + assert [e for e in events if e.startswith("audience_")] == [ + "audience_foreign_id_token_refused", + "audience_spa_id_token_admitted", + "audience_foreign_access_token_refused", + "audience_refusal_logged_with_reason", + ] + assert {r.check for r in rows} >= {"allowlist_parameter_value_is_spa_client"} diff --git a/tests/unit/test_smoke_cloudfront.py b/tests/unit/test_smoke_cloudfront.py index 3f7d0a5..fd1399b 100644 --- a/tests/unit/test_smoke_cloudfront.py +++ b/tests/unit/test_smoke_cloudfront.py @@ -8,18 +8,23 @@ from __future__ import annotations +import base64 +import hashlib +from collections.abc import Iterable from typing import Any import pytest from scripts.smoke.cloudfront import ( _UNAUTHENTICATED_API_METHOD, _UNAUTHENTICATED_API_PATH, + HeaderCaller, + HeaderResult, HttpCaller, HttpMethodCaller, HttpResult, TlsProbeResult, - checks, ) +from scripts.smoke.cloudfront import checks as _module_checks from scripts.smoke.harness import CheckResult, ResourceClassResult, context_for_test DOMAIN_NAME = "d111111abcdef8.cloudfront.net" @@ -38,6 +43,57 @@ RELAY_FUNCTION_HOST = "abcdefghij1234567890.lambda-url.us-east-1.on.aws" OAC_ID = "E2QWERTYUIOP" +#: The module's custom response-headers policy, attached to every behaviour. +RESPONSE_HEADERS_POLICY_ID = "a1b2c3d4-0000-4000-8000-0000f00d0001" +#: AWS-managed `Managed-SecurityHeadersPolicy`, which carries no CSP. +MANAGED_SECURITY_HEADERS_POLICY_ID = "67f7725c-6f97-4210-82d7-5512b31e9d03" +COGNITO_DOMAIN = "crm-agent-eval-fixture" +REGION = "us-east-1" + +#: The inline theme script the served document carries, and its CSP hash source. +THEME_SCRIPT = "\n (function () { document.documentElement.setAttribute('data-theme', 'light'); })();\n " +THEME_SCRIPT_HASH = ( + "'sha256-" + base64.b64encode(hashlib.sha256(THEME_SCRIPT.encode()).digest()).decode() + "'" +) +SERVED_INDEX = ( + f"" + '
' +) + + +def _csp( + *, + script_src: Iterable[str] = ("'self'", THEME_SCRIPT_HASH), + connect_src: Iterable[str] = ( + "'self'", + f"https://cognito-idp.{REGION}.amazonaws.com", + f"https://{COGNITO_DOMAIN}.auth.{REGION}.amazoncognito.com", + ), + replace: dict[str, str] | None = None, + drop: Iterable[str] = (), + extra: Iterable[str] = (), +) -> str: + """The designed CSP, with any directive replaced (`name -> 'name sources'`) or dropped.""" + directives = { + "default-src": "default-src 'self'", + "script-src": "script-src " + " ".join(script_src), + "style-src": "style-src 'self' 'unsafe-inline'", + "img-src": "img-src 'self' data:", + "font-src": "font-src 'self' data:", + "connect-src": "connect-src " + " ".join(connect_src), + "frame-ancestors": "frame-ancestors 'none'", + "base-uri": "base-uri 'none'", + "object-src": "object-src 'none'", + "form-action": "form-action 'self'", + } + directives.update(replace or {}) + for name in drop: + del directives[name] + return "; ".join([*directives.values(), *extra]) + + +HEALTHY_CSP = _csp() + CACHING_DISABLED_POLICY_ID = "4135ea2d-6df8-44a3-9df3-4b5a84be39ad" CACHING_OPTIMIZED_POLICY_ID = "658327ea-f89d-4fab-a63d-7e88639e58f6" ALL_VIEWER_EXCEPT_HOST_POLICY_ID = "b689b0a8-53d0-40ab-baf2-68738e2966ac" @@ -96,6 +152,7 @@ def _default_behavior(target_origin_id: str = "s3-frontend-origin") -> dict[str, return { "TargetOriginId": target_origin_id, "CachePolicyId": CACHING_OPTIMIZED_POLICY_ID, + "ResponseHeadersPolicyId": RESPONSE_HEADERS_POLICY_ID, } @@ -112,6 +169,7 @@ def _custom_behavior( "PathPattern": path_pattern, "TargetOriginId": target_origin_id, "CachePolicyId": cache_policy_id, + "ResponseHeadersPolicyId": RESPONSE_HEADERS_POLICY_ID, } if origin_request_policy_id is not None: behavior["OriginRequestPolicyId"] = origin_request_policy_id @@ -175,10 +233,48 @@ class FakeCloudFrontClient: """Minimal stand-in for a boto3 `cloudfront` client, keyed to what `checks()` calls.""" def __init__( - self, *, distribution_config: dict[str, Any], domain_name: str = DOMAIN_NAME + self, + *, + distribution_config: dict[str, Any], + domain_name: str = DOMAIN_NAME, + policy_csp: str | None = HEALTHY_CSP, + csp_override: bool = True, + frame_option: str = "DENY", + custom_policy_ids: tuple[str, ...] = (RESPONSE_HEADERS_POLICY_ID,), ) -> None: self._distribution_config = distribution_config self._domain_name = domain_name + self._policy_csp = policy_csp + self._csp_override = csp_override + self._frame_option = frame_option + self._custom_policy_ids = custom_policy_ids + + def list_response_headers_policies(self, **kwargs: Any) -> dict[str, Any]: + assert kwargs.get("Type") == "custom" + return { + "ResponseHeadersPolicyList": { + "Items": [ + {"Type": "custom", "ResponseHeadersPolicy": {"Id": policy_id}} + for policy_id in self._custom_policy_ids + ] + } + } + + def get_response_headers_policy(self, **kwargs: Any) -> dict[str, Any]: + security: dict[str, Any] = { + "FrameOptions": {"FrameOption": self._frame_option, "Override": True}, + } + if self._policy_csp is not None: + security["ContentSecurityPolicy"] = { + "ContentSecurityPolicy": self._policy_csp, + "Override": self._csp_override, + } + return { + "ResponseHeadersPolicy": { + "Id": kwargs["Id"], + "ResponseHeadersPolicyConfig": {"SecurityHeadersConfig": security}, + } + } def list_distributions(self, **_kwargs: Any) -> dict[str, Any]: return { @@ -197,6 +293,7 @@ def _outputs() -> dict[str, str]: "api_endpoint": API_ENDPOINT, "agentcore_gateway_url": AGENTCORE_URL, "agent_relay_function_url": RELAY_FUNCTION_URL, + "cognito_domain": COGNITO_DOMAIN, } @@ -220,10 +317,15 @@ def method_caller(url: str, method: str) -> HttpResult: return method_caller -def _make_ctx(distribution_config: dict[str, Any]) -> Any: +def _make_ctx(distribution_config: dict[str, Any], **client_kwargs: Any) -> Any: return context_for_test( outputs=_outputs(), - clients={"cloudfront": FakeCloudFrontClient(distribution_config=distribution_config)}, + clients={ + "cloudfront": FakeCloudFrontClient( + distribution_config=distribution_config, **client_kwargs + ) + }, + region=REGION, ) @@ -250,6 +352,54 @@ def _refused_probe(_domain_name: str) -> TlsProbeResult: return True +def _header_caller( + *, + csp_by_path: dict[str, str | None] | None = None, + report_only_by_path: dict[str, str] | None = None, + status_by_path: dict[str, int] | None = None, + transport_failure_paths: Iterable[str] = (), + index_body: str = SERVED_INDEX, +) -> HeaderCaller: + """A served-header fake: `/` is the SPA, `/api/*` 401 and `/agent/*` 401, each with the CSP.""" + from urllib.parse import urlsplit + + failing = set(transport_failure_paths) + + def caller(url: str, method: str) -> HeaderResult: + path = urlsplit(url).path + if path in failing: + return f"transport error calling {method} {url}: connection reset" + if path == "/": + status, body = 200, index_body + elif path.startswith("/api/"): + assert method == _UNAUTHENTICATED_API_METHOD + status, body = 401, '{"message":"Unauthorized"}' + elif path.startswith("/agent/"): + status, body = 401, '{"error":"unauthorized"}' + else: + raise AssertionError(f"unexpected header probe {method} {url}") + status = (status_by_path or {}).get(path, status) + headers: dict[str, str] = {} + csp = (csp_by_path or {}).get(path, HEALTHY_CSP) + if csp is not None: + headers["content-security-policy"] = csp + report_only = (report_only_by_path or {}).get(path) + if report_only is not None: + headers["content-security-policy-report-only"] = report_only + return status, headers, body + + return caller + + +_healthy_header_caller = _header_caller() + + +def checks(ctx: Any, **kwargs: Any) -> Iterable[CheckResult]: + """`scripts.smoke.cloudfront.checks` with the healthy served-header fake unless one is given.""" + kwargs.setdefault("http_header_caller", _healthy_header_caller) + return _module_checks(ctx, **kwargs) + + def test_oac_only_origin_passes_with_oac_configured() -> None: ctx = _make_ctx(_distribution_config()) @@ -869,6 +1019,10 @@ def test_api_behavior_routed_to_wrong_origin_is_detected() -> None: assert findings[0].status == "fail" +#: Behaviour-scoped checks that read the served response rather than the distribution config. +_LIVE_RESPONSE_CHECKS = frozenset({"unauthenticated_api_still_refused", "csp_header_enforced"}) + + def test_missing_api_behavior_fails_naming_the_path_pattern() -> None: """A missing behaviour must fail, naming the path pattern, across all three checks.""" config = _distribution_config(include_api_behavior=False) @@ -883,11 +1037,11 @@ def test_missing_api_behavior_fails_naming_the_path_pattern() -> None: ) ) - # `unauthenticated_api_still_refused` reads the live response, not the config. + # `unauthenticated_api_still_refused` and `csp_header_enforced` read the live response. behavior_checks = [ r for r in results - if r.resource == "behavior:/api/*" and r.check != "unauthenticated_api_still_refused" + if r.resource == "behavior:/api/*" and r.check not in _LIVE_RESPONSE_CHECKS ] assert len(behavior_checks) == 3 assert all(r.status == "fail" for r in behavior_checks) @@ -907,7 +1061,11 @@ def test_missing_agent_behavior_fails_naming_the_path_pattern() -> None: ) ) - behavior_checks = [r for r in results if r.resource == "behavior:/agent/*"] + behavior_checks = [ + r + for r in results + if r.resource == "behavior:/agent/*" and r.check not in _LIVE_RESPONSE_CHECKS + ] # Origin, caching, Authorization, no path-rewrite function, and compression off. assert len(behavior_checks) == 5 assert all(r.status == "fail" for r in behavior_checks) @@ -1405,3 +1563,254 @@ def test_an_absent_compress_field_fails_rather_than_reading_as_disabled() -> Non ) assert _one(results, "behavior:/agent/*", "compression_disabled").status == "fail" + + +# --------------------------------------------------------------------------- +# The response-headers policy and the served Content-Security-Policy. +# --------------------------------------------------------------------------- + +#: Every row the CSP and response-headers-policy checks emit, as `(resource, check)`. +CSP_ROWS: frozenset[tuple[str, str]] = frozenset( + { + ("distribution", "one_response_headers_policy_on_every_behaviour"), + ("distribution", "response_headers_policy_enforces_csp"), + ("behavior:/*", "csp_header_enforced"), + ("behavior:/api/*", "csp_header_enforced"), + ("behavior:/agent/*", "csp_header_enforced"), + ("distribution", "served_csp_identical_and_equal_to_policy"), + ("distribution", "served_csp_matches_design"), + ("distribution", "served_csp_connect_src_allows_cognito"), + ("distribution", "served_csp_allows_every_inline_script"), + } +) + + +def _csp_results( + *, + config: dict[str, Any] | None = None, + header_caller: HeaderCaller | None = None, + **client_kwargs: Any, +) -> dict[tuple[str, str], CheckResult]: + """Run `checks()` and return the CSP rows, asserting each appears exactly once.""" + ctx = _make_ctx(config if config is not None else _distribution_config(), **client_kwargs) + results = list( + checks( + ctx, + http_caller=_healthy_caller, + http_method_caller=_as_method_caller(_healthy_caller), + tls_probe=_refused_probe, + http_header_caller=header_caller or _healthy_header_caller, + ) + ) + return {key: _one(results, *key) for key in CSP_ROWS} + + +def _failing(rows: dict[tuple[str, str], CheckResult]) -> set[tuple[str, str]]: + return {key for key, result in rows.items() if result.status != "pass"} + + +def test_a_healthy_distribution_passes_every_csp_row() -> None: + rows = _csp_results() + assert _failing(rows) == set(), {k: r.detail for k, r in rows.items() if r.status != "pass"} + + +def test_every_csp_probe_reads_the_header_from_the_behaviour_it_names() -> None: + """`/`, an unauthenticated `/api/*` call and an unauthenticated `/agent/*` call are probed.""" + seen: list[tuple[str, str]] = [] + + def recording(url: str, method: str) -> HeaderResult: + seen.append((url, method)) + return _healthy_header_caller(url, method) + + _csp_results(header_caller=recording) + paths = [url.removeprefix(f"https://{DOMAIN_NAME}") for url, _ in seen] + assert paths[0] == "/" + assert paths[1] == _UNAUTHENTICATED_API_PATH and seen[1][1] == _UNAUTHENTICATED_API_METHOD + assert paths[2].startswith("/agent/") + assert len(seen) == 3 + + +@pytest.mark.parametrize( + ("path", "resource"), + [ + ("/", "behavior:/*"), + (_UNAUTHENTICATED_API_PATH, "behavior:/api/*"), + ("/agent/csp-probe", "behavior:/agent/*"), + ], +) +def test_a_behaviour_serving_no_csp_fails_exactly_its_own_row(path: str, resource: str) -> None: + rows = _csp_results(header_caller=_header_caller(csp_by_path={path: None})) + expected = {(resource, "csp_header_enforced")} + if resource == "behavior:/*": + # Every distribution-level row reads the `/` header, so each reports it absent. + expected |= {key for key in CSP_ROWS if key[0] == "distribution" and "served" in key[1]} + assert _failing(rows) == expected + + +def test_a_report_only_header_is_not_an_enforced_csp() -> None: + caller = _header_caller( + csp_by_path={"/agent/csp-probe": None}, + report_only_by_path={"/agent/csp-probe": HEALTHY_CSP}, + ) + rows = _csp_results(header_caller=caller) + assert _failing(rows) == {("behavior:/agent/*", "csp_header_enforced")} + assert "Report-Only" in rows[("behavior:/agent/*", "csp_header_enforced")].detail + + +def test_an_unauthenticated_probe_that_succeeds_fails_its_row() -> None: + rows = _csp_results( + header_caller=_header_caller(status_by_path={_UNAUTHENTICATED_API_PATH: 200}) + ) + assert _failing(rows) == {("behavior:/api/*", "csp_header_enforced")} + + +def test_a_transport_failure_on_a_probe_is_reported_not_raised() -> None: + rows = _csp_results(header_caller=_header_caller(transport_failure_paths=["/agent/csp-probe"])) + assert _failing(rows) == {("behavior:/agent/*", "csp_header_enforced")} + assert "transport error" in rows[("behavior:/agent/*", "csp_header_enforced")].detail + + +def test_a_behaviour_serving_a_different_csp_fails_the_identity_row() -> None: + other = _csp(replace={"img-src": "img-src 'self'"}) + rows = _csp_results(header_caller=_header_caller(csp_by_path={"/agent/csp-probe": other})) + assert _failing(rows) == {("distribution", "served_csp_identical_and_equal_to_policy")} + + +def test_a_served_csp_that_differs_from_the_policy_fails_the_identity_row() -> None: + rows = _csp_results(policy_csp=_csp(replace={"img-src": "img-src 'self'"})) + assert _failing(rows) == {("distribution", "served_csp_identical_and_equal_to_policy")} + + +@pytest.mark.parametrize( + "broken", + [ + _csp(script_src=("'self'", THEME_SCRIPT_HASH, "'unsafe-eval'")), + _csp(script_src=("'self'", THEME_SCRIPT_HASH, "'unsafe-inline'")), + _csp(replace={"default-src": "default-src 'self' 'unsafe-eval'"}), + _csp(drop=["frame-ancestors"]), + _csp(replace={"object-src": "object-src 'self'"}), + _csp(extra=["worker-src 'self'"]), + _csp(connect_src=("'self'", "https://*.amazonaws.com")), + _csp(script_src=("'self'", THEME_SCRIPT_HASH, "https://cdn.example.test")), + _csp(extra=["default-src 'self'"]), + ], + ids=[ + "unsafe-eval", + "unsafe-inline-in-script-src", + "unsafe-eval-elsewhere", + "missing-frame-ancestors", + "object-src-not-none", + "extra-directive", + "wildcard-connect-origin", + "script-src-host-source", + "repeated-directive", + ], +) +def test_a_served_csp_off_the_design_fails_exactly_the_design_row(broken: str) -> None: + rows = _csp_results( + header_caller=_header_caller( + csp_by_path=dict.fromkeys(["/", _UNAUTHENTICATED_API_PATH, "/agent/csp-probe"], broken) + ), + policy_csp=broken, + ) + failing = _failing(rows) + assert ("distribution", "served_csp_matches_design") in failing + if "unsafe-eval" in broken: + assert "allows 'unsafe-eval'" in rows[("distribution", "served_csp_matches_design")].detail + # A wildcard origin also drops the Cognito origins; a script host leaves the hash intact. + assert ( + failing + - { + ("distribution", "served_csp_matches_design"), + ("distribution", "served_csp_connect_src_allows_cognito"), + } + == set() + ), failing + + +@pytest.mark.parametrize( + "connect_src", + [ + ("'self'", f"https://{COGNITO_DOMAIN}.auth.{REGION}.amazoncognito.com"), + ("'self'", f"https://cognito-idp.{REGION}.amazonaws.com"), + ( + "'self'", + "https://cognito-idp.us-west-2.amazonaws.com", + f"https://{COGNITO_DOMAIN}.auth.{REGION}.amazoncognito.com", + ), + ], + ids=["no-user-pool-endpoint", "no-hosted-ui-domain", "wrong-region"], +) +def test_a_connect_src_without_a_cognito_origin_fails_exactly_that_row( + connect_src: tuple[str, ...], +) -> None: + broken = _csp(connect_src=connect_src) + caller = _header_caller( + csp_by_path=dict.fromkeys(["/", _UNAUTHENTICATED_API_PATH, "/agent/csp-probe"], broken) + ) + rows = _csp_results(header_caller=caller, policy_csp=broken) + assert _failing(rows) == {("distribution", "served_csp_connect_src_allows_cognito")} + + +def test_a_served_inline_script_whose_hash_is_not_in_script_src_fails() -> None: + edited = SERVED_INDEX.replace("'light'", "'dark'") + rows = _csp_results(header_caller=_header_caller(index_body=edited)) + assert _failing(rows) == {("distribution", "served_csp_allows_every_inline_script")} + assert ( + "browsers refuse" in rows[("distribution", "served_csp_allows_every_inline_script")].detail + ) + + +def test_a_second_inline_script_without_a_hash_fails() -> None: + extra = SERVED_INDEX.replace("", "") + rows = _csp_results(header_caller=_header_caller(index_body=extra)) + assert _failing(rows) == {("distribution", "served_csp_allows_every_inline_script")} + + +def test_a_document_with_no_inline_script_fails_rather_than_passing_vacuously() -> None: + bare = SERVED_INDEX.replace(f"", "") + rows = _csp_results(header_caller=_header_caller(index_body=bare)) + assert _failing(rows) == {("distribution", "served_csp_allows_every_inline_script")} + + +def test_a_behaviour_without_the_shared_policy_fails_the_policy_rows() -> None: + config = _distribution_config( + agent_behavior={ + **_custom_behavior("/agent/*", "agent-relay-origin", compress=False), + "ResponseHeadersPolicyId": MANAGED_SECURITY_HEADERS_POLICY_ID, + } + ) + rows = _csp_results(config=config) + assert _failing(rows) == { + ("distribution", "one_response_headers_policy_on_every_behaviour"), + ("distribution", "response_headers_policy_enforces_csp"), + } + assert ( + "/agent/*" + in rows[("distribution", "one_response_headers_policy_on_every_behaviour")].detail + ) + + +def test_a_behaviour_with_no_response_headers_policy_fails_the_policy_rows() -> None: + behaviour = _custom_behavior("/api/*", "api-gateway-origin") + del behaviour["ResponseHeadersPolicyId"] + rows = _csp_results(config=_distribution_config(api_behavior=behaviour)) + assert ("distribution", "one_response_headers_policy_on_every_behaviour") in _failing(rows) + + +@pytest.mark.parametrize( + ("client_kwargs", "fragment"), + [ + ({"custom_policy_ids": ()}, "not a custom policy"), + ({"policy_csp": None}, "no Content-Security-Policy"), + ({"csp_override": False}, "Override"), + ({"frame_option": "SAMEORIGIN"}, "DENY"), + ], + ids=["managed-policy", "no-csp", "override-off", "frame-sameorigin"], +) +def test_a_policy_property_broken_fails_exactly_the_policy_row( + client_kwargs: dict[str, Any], fragment: str +) -> None: + rows = _csp_results(**client_kwargs) + assert _failing(rows) == {("distribution", "response_headers_policy_enforces_csp")} + assert fragment in rows[("distribution", "response_headers_policy_enforces_csp")].detail diff --git a/tests/unit/test_smoke_cognito_claims.py b/tests/unit/test_smoke_cognito_claims.py index 3e54519..0d55d6b 100644 --- a/tests/unit/test_smoke_cognito_claims.py +++ b/tests/unit/test_smoke_cognito_claims.py @@ -85,6 +85,28 @@ def _compliant_pool(**overrides: Any) -> dict[str, Any]: return pool +def _spa_client(*, enable_token_revocation: object = True) -> dict[str, Any]: + client: dict[str, Any] = {"UserPoolId": _USER_POOL_ID, "ClientId": _SPA_CLIENT_ID} + if enable_token_revocation is not _OMIT: + client["EnableTokenRevocation"] = enable_token_revocation + return {"UserPoolClient": client} + + +_OMIT = object() + + +def _add_pool( + stubber: Stubber, pool: Mapping[str, Any], *, spa_client: Mapping[str, Any] | None = None +) -> None: + """Queue `describe_user_pool` then the SPA client's `describe_user_pool_client`, in call order.""" + stubber.add_response("describe_user_pool", {"UserPool": dict(pool)}, {"UserPoolId": ANY}) + stubber.add_response( + "describe_user_pool_client", + dict(spa_client) if spa_client is not None else _spa_client(), + {"UserPoolId": _USER_POOL_ID, "ClientId": _SPA_CLIENT_ID}, + ) + + def _outputs() -> dict[str, str]: return {"cognito_user_pool_id": _USER_POOL_ID, "cognito_spa_client_id": _SPA_CLIENT_ID} @@ -93,7 +115,7 @@ def _run_checks_with_describe( pool: Mapping[str, Any], *, username: str = "", password: str = "" ) -> list[Any]: client, stubber = _idp_client() - stubber.add_response("describe_user_pool", {"UserPool": dict(pool)}, {"UserPoolId": ANY}) + _add_pool(stubber, dict(pool)) with stubber: ctx = context_for_test(outputs=_outputs(), clients={"cognito-idp": client}) return list(checks(ctx, username=username, password=password)) @@ -249,7 +271,7 @@ def _run_signup_probe( readback_error_code: str = "UserNotFoundException", ) -> list[Any]: client, stubber = _idp_client() - stubber.add_response("describe_user_pool", {"UserPool": _compliant_pool()}, {"UserPoolId": ANY}) + _add_pool(stubber, _compliant_pool()) if expect_cleanup: stubber.add_response( "admin_delete_user", {}, {"UserPoolId": _USER_POOL_ID, "Username": ANY} @@ -337,7 +359,7 @@ def test_self_signup_readback_error_other_than_user_not_found_fails_naming_the_c def test_self_signup_other_error_code_is_a_fail_naming_the_code(code: str) -> None: """An unrelated error must never read as a refusal: that would pass for the wrong reason.""" client, stubber = _idp_client() - stubber.add_response("describe_user_pool", {"UserPool": _compliant_pool()}, {"UserPoolId": ANY}) + _add_pool(stubber, _compliant_pool()) stubber.add_client_error( "admin_delete_user", service_error_code="UserNotFoundException", @@ -365,7 +387,7 @@ def sign_up(self, **_kwargs: Any) -> Any: raise TimeoutError("read timed out") client, stubber = _idp_client() - stubber.add_response("describe_user_pool", {"UserPool": _compliant_pool()}, {"UserPoolId": ANY}) + _add_pool(stubber, _compliant_pool()) stubber.add_response("admin_delete_user", {}, {"UserPoolId": _USER_POOL_ID, "Username": ANY}) stubber.add_client_error( "admin_get_user", @@ -409,7 +431,7 @@ def _checks_with_token( expected_book: frozenset[str] = frozenset(), ) -> list[Any]: client, stubber = _idp_client() - stubber.add_response("describe_user_pool", {"UserPool": _compliant_pool()}, {"UserPoolId": ANY}) + _add_pool(stubber, _compliant_pool()) password = _password() stubber.add_response( "admin_initiate_auth", @@ -544,7 +566,7 @@ def test_no_username_password_skips_token_checks_but_runs_pool_checks() -> None: def test_admin_initiate_auth_no_id_token_fails_with_actionable_detail() -> None: client, stubber = _idp_client() - stubber.add_response("describe_user_pool", {"UserPool": _compliant_pool()}, {"UserPoolId": ANY}) + _add_pool(stubber, _compliant_pool()) password = _password() stubber.add_response( "admin_initiate_auth", @@ -706,6 +728,10 @@ def _provisioned_claims(**overrides: Any) -> dict[str, Any]: return claims +#: A stand-in refresh token; the stubbed client never inspects it. +_REFRESH_TOKEN = "refresh-" + "x" * 24 + + class _FakeProvisioner: """A `SmokeUserProvisioner` double: configurable failure, and records that cleanup ran.""" @@ -715,10 +741,12 @@ def __init__( provision_error: Exception | None = None, claims: Mapping[str, Any] | None = None, cleanup_status: str = "pass", + refresh_token: str = _REFRESH_TOKEN, ) -> None: self._provision_error = provision_error self._claims = dict(claims) if claims is not None else _provisioned_claims() self._cleanup_status = cleanup_status + self._refresh_token = refresh_token self.cleaned_up = False def provision(self) -> ProvisionedSmokeUser: @@ -731,6 +759,7 @@ def provision(self) -> ProvisionedSmokeUser: book=_PROVISIONED_BOOK, id_token=test_key.id_token(**self._claims), detail="MFA-completed ID token issued on attempt 1", + refresh_token=self._refresh_token, ) def cleanup(self) -> Any: @@ -743,9 +772,50 @@ def cleanup(self) -> Any: ) -def _checks_with_provisioner(provisioner: Any) -> list[Any]: +def _queue_revocation( + stubber: Stubber, + *, + revoke_error: str | None = None, + refresh_outcome: str | None = "NotAuthorizedException", +) -> None: + """Queue `revoke_token` then `initiate_auth REFRESH_TOKEN_AUTH`, as the provisioned path calls + them. `refresh_outcome=None` answers the refresh with fresh tokens (revocation did not hold).""" + revoke_params = {"Token": _REFRESH_TOKEN, "ClientId": _SPA_CLIENT_ID} + if revoke_error is not None: + stubber.add_client_error( + "revoke_token", service_error_code=revoke_error, expected_params=revoke_params + ) + return + stubber.add_response("revoke_token", {}, revoke_params) + refresh_params = { + "AuthFlow": "REFRESH_TOKEN_AUTH", + "ClientId": _SPA_CLIENT_ID, + "AuthParameters": {"REFRESH_TOKEN": _REFRESH_TOKEN}, + } + if refresh_outcome is None: + stubber.add_response( + "initiate_auth", + {"AuthenticationResult": {"IdToken": "still-valid", "AccessToken": "still-valid"}}, + refresh_params, + ) + else: + stubber.add_client_error( + "initiate_auth", service_error_code=refresh_outcome, expected_params=refresh_params + ) + + +def _checks_with_provisioner( + provisioner: Any, + *, + spa_client: Mapping[str, Any] | None = None, + revoke_error: str | None = None, + refresh_outcome: str | None = "NotAuthorizedException", + queue_revocation: bool = True, +) -> list[Any]: client, stubber = _idp_client() - stubber.add_response("describe_user_pool", {"UserPool": _compliant_pool()}, {"UserPoolId": ANY}) + _add_pool(stubber, _compliant_pool(), spa_client=spa_client) + if queue_revocation: + _queue_revocation(stubber, revoke_error=revoke_error, refresh_outcome=refresh_outcome) with stubber: ctx = context_for_test(outputs=_outputs(), clients={"cognito-idp": client}) return list( @@ -775,7 +845,7 @@ def test_provisioned_run_reports_issue_and_decode_as_a_real_pass_never_a_skip() def test_provisioning_failure_is_a_fail_not_a_skip_and_still_cleans_up() -> None: """A provisioning failure fails `issue_and_decode` and cleanup still runs.""" provisioner = _FakeProvisioner(provision_error=RuntimeError("MFA_SETUP never completed")) - results = _checks_with_provisioner(provisioner) + results = _checks_with_provisioner(provisioner, queue_revocation=False) by_check = {r.check: r for r in results} assert by_check["issue_and_decode"].status == "fail" assert "MFA_SETUP never completed" in by_check["issue_and_decode"].detail @@ -811,7 +881,7 @@ def test_a_failing_cleanup_is_reported_as_a_failure_not_swallowed() -> None: def test_undecodable_token_fails_and_still_cleans_up() -> None: provisioner = _FakeProvisioner() client, stubber = _idp_client() - stubber.add_response("describe_user_pool", {"UserPool": _compliant_pool()}, {"UserPoolId": ANY}) + _add_pool(stubber, _compliant_pool()) def explode(_token: str) -> dict[str, Any]: raise ValueError("signature verification failed") @@ -1092,3 +1162,84 @@ def _user_pool_id(self) -> str: assert first != second for username in (first, second): assert username.startswith(f"smoke-{shared.run_id}-") and username.endswith("@example.test") + + +# --------------------------------------------------------------------------- +# SPA client token revocation: enabled on the client, and a revoked refresh token is refused. +# --------------------------------------------------------------------------- + +_REVOCATION_ROWS = ("token_revocation_enabled", "revoked_refresh_token_refused") + + +def _failing_revocation_rows(results: list[Any]) -> set[str]: + by_check = {r.check: r for r in results} + return {check for check in _REVOCATION_ROWS if by_check[check].status != "pass"} + + +def test_a_revocation_enabled_client_and_a_refused_revoked_token_pass_both_rows() -> None: + results = _checks_with_provisioner(_FakeProvisioner()) + assert _failing_revocation_rows(results) == set(), [ + (r.check, r.detail) for r in results if r.check in _REVOCATION_ROWS + ] + by_check = {r.check: r for r in results} + assert by_check["issue_and_decode"].status == "pass" + assert by_check["cognito_user_deleted"].status == "pass" + + +@pytest.mark.parametrize("value", [False, _OMIT], ids=["false", "absent"]) +def test_token_revocation_not_enabled_reds_exactly_its_row(value: object) -> None: + results = _checks_with_provisioner( + _FakeProvisioner(), spa_client=_spa_client(enable_token_revocation=value) + ) + assert _failing_revocation_rows(results) == {"token_revocation_enabled"} + + +@pytest.mark.parametrize( + ("kwargs", "provisioner_kwargs"), + [ + ({"refresh_outcome": None}, {}), + ({"refresh_outcome": "InvalidParameterException"}, {}), + ({"refresh_outcome": "TooManyRequestsException"}, {}), + ({"revoke_error": "UnsupportedTokenTypeException"}, {}), + ({"queue_revocation": False}, {"refresh_token": ""}), + ], + ids=["refresh-accepted", "other-error", "throttled", "revoke-failed", "no-refresh-token"], +) +def test_a_revocation_that_did_not_hold_reds_exactly_its_row( + kwargs: dict[str, Any], provisioner_kwargs: dict[str, Any] +) -> None: + provisioner = _FakeProvisioner(**provisioner_kwargs) + results = _checks_with_provisioner(provisioner, **kwargs) + assert _failing_revocation_rows(results) == {"revoked_refresh_token_refused"} + assert provisioner.cleaned_up + + +def test_the_revocation_probe_runs_before_cleanup() -> None: + results = _checks_with_provisioner(_FakeProvisioner()) + order = [r.check for r in results] + assert order.index("revoked_refresh_token_refused") < order.index("cognito_user_deleted") + + +def test_a_pre_provisioned_user_skips_the_revocation_probe_with_a_reason() -> None: + results = _checks_with_token(_COMPLETE_CLAIMS) + by_check = {r.check: r for r in results} + assert by_check["revoked_refresh_token_refused"].status == "skip" + assert "live entry point" in by_check["revoked_refresh_token_refused"].detail + assert by_check["token_revocation_enabled"].status == "pass" + + +def test_the_live_provisioner_carries_the_issued_refresh_token() -> None: + provisioner = LiveSmokeUserProvisioner(context_for_test(outputs=_outputs())) + client, stubber = _idp_client() + stubber.add_response( + "admin_initiate_auth", + {"AuthenticationResult": {"IdToken": "id", "RefreshToken": _REFRESH_TOKEN}}, + {"UserPoolId": ANY, "ClientId": ANY, "AuthFlow": ANY, "AuthParameters": ANY}, + ) + with stubber: + provisioner._ctx = context_for_test(outputs=_outputs(), clients={"cognito-idp": client}) + id_token, _secret = provisioner._one_auth_attempt( + username="u", password=_password(), secret=None + ) + assert id_token == "id" + assert provisioner._refresh_token == _REFRESH_TOKEN diff --git a/tests/unit/test_smoke_eval_sfn.py b/tests/unit/test_smoke_eval_sfn.py index bf0cb7d..29db98d 100644 --- a/tests/unit/test_smoke_eval_sfn.py +++ b/tests/unit/test_smoke_eval_sfn.py @@ -91,6 +91,22 @@ def _matrix() -> dict[str, Any]: } +def _tier_table(arms: int) -> dict[str, Any]: + """A `tier_comparison_table` in `eval.matrix.tier_comparison_table`'s shape for `arms` arms.""" + return { + "headers": ["Metric", *(f"arm-{index}" for index in range(arms))], + "sections": [ + {"tier": tier, "heading": heading, "rows": [["Model", *(["m"] * arms)]]} + for tier, heading in ( + ("supervisor", "Supervisor"), + ("subagent", "Subagent"), + ("tool", "ToolCall"), + ) + ], + "notes": [], + } + + class FakeEvalApi: """A stateful `/api/eval_trigger`: each `status` advances a running sweep by `step` tasks.""" @@ -130,9 +146,12 @@ def __call__( return 200, dict(run) if action == "artefact_url": key = str(body["key"]) - if key not in run.get("artifacts", {}).get("raw", []): + recorded = run.get("artifacts", {}) + if key not in recorded.get("raw", []) and key != recorded.get("matrix_md"): return 404, {"error": {"code": "not_found", "message": "no such artefact"}} url = f"https://artifacts-bucket.s3.amazonaws.com/eval-artifacts/{run['run_id']}/{key}?X-Amz-Signature=sig" + if body.get("download") is True: + url += "&response-content-disposition=attachment" return 200, {"run_id": run["run_id"], "key": key, "url": url, "expires_in": 300} if action == "cancel": if run["is_terminal"]: @@ -172,7 +191,8 @@ def _finish(self, run: dict[str, Any], status: str) -> None: is_terminal=True, teardown_status="ok", matrix=_matrix(), - artifacts={"raw": ["raw/arm-0.json", "raw/arm-1.json"]}, + artifacts={"raw": ["raw/arm-0.json", "raw/arm-1.json"], "matrix_md": "matrix.md"}, + tier_comparison_table=_tier_table(len(_FAMILIES)), cost_spent_usd=0.5 if run["mode"] == "live" else 0.0, ) if self.lock == run["run_id"]: @@ -392,6 +412,32 @@ def __call__(self, url: str) -> tuple[int, str | None]: return self.http_status, self.http_code +class FakeArtefactGet: + """S3's answer to an https GET of a presigned artefact URL: the same bytes either way, with + `Content-Disposition: attachment` when the URL asked for it.""" + + def __init__( + self, + *, + disposition: str | None = 'attachment; filename="matrix-run.md"', + download_body: bytes = b"# matrix\n", + plain_body: bytes = b"# matrix\n", + status: int = 200, + ) -> None: + self.disposition = disposition + self.download_body = download_body + self.plain_body = plain_body + self.status = status + self.urls: list[str] = [] + + def __call__(self, url: str) -> tuple[int, Mapping[str, str], bytes]: + self.urls.append(url) + if "response-content-disposition" in url: + headers = {"content-disposition": self.disposition} if self.disposition else {} + return self.status, headers, self.download_body + return 200, {}, self.plain_body + + def _run( api: FakeEvalApi, *, @@ -399,6 +445,7 @@ def _run( store: FakeStore | None = None, provisioner: FakeProvisioner | None = None, fetch: FakeFetch | None = None, + artefact_get: FakeArtefactGet | None = None, ) -> dict[str, CheckResult]: clock = Clock() results = list( @@ -411,6 +458,7 @@ def _run( clock=clock, sleeper=clock.sleep, fetch=fetch or FakeFetch(), + artefact_get=artefact_get or FakeArtefactGet(), ) ) by_check = {r.check: r for r in results} @@ -437,6 +485,9 @@ def _run( "artefact_url_https_get_succeeds", "artefact_url_plain_http_denied", "artefact_url_tampered_key_denied", + "status_carries_tier_comparison_table", + "matrix_md_download_is_attachment", + "matrix_md_download_bytes_match_artefact", "rehearsal_tenant_empty", "tenant_emptied_by_the_workers_own_role", "demo_tenant_untouched", @@ -2308,3 +2359,141 @@ def close(self) -> None: responses.append(_Response(200, b"AccessDenied")) assert mod.fetch_status("https://bucket.s3.amazonaws.com/k?X-Amz-Signature=s") == (200, None) assert responses[-1].read_calls == 0 + + +# -- tier_comparison_table and the matrix.md download ------------------------------------- + + +_DOWNLOAD_ROWS = ( + "status_carries_tier_comparison_table", + "matrix_md_download_is_attachment", + "matrix_md_download_bytes_match_artefact", +) + + +def _failing_download_rows(rows: Mapping[str, CheckResult]) -> set[str]: + return {check for check in _DOWNLOAD_ROWS if rows[check].status != "pass"} + + +def test_the_tier_table_and_download_rows_pass_on_a_correct_run() -> None: + get = FakeArtefactGet() + rows = _run(FakeEvalApi(), artefact_get=get) + assert _failing_download_rows(rows) == set(), {c: rows[c].detail for c in _DOWNLOAD_ROWS} + assert len(get.urls) == 2 + assert "response-content-disposition" in get.urls[0] + assert "response-content-disposition" not in get.urls[1] + + +class _TableApi(FakeEvalApi): + def __init__(self, table: object) -> None: + super().__init__() + self.table = table + + def _finish(self, run: dict[str, Any], status: str) -> None: + super()._finish(run, status) + if self.table is _ABSENT: + run.pop("tier_comparison_table") + else: + run["tier_comparison_table"] = self.table + + +_ABSENT = object() + + +def _narrow_rows() -> dict[str, Any]: + table = _tier_table(len(_FAMILIES)) + table["sections"][1]["rows"] = [["Model", "m"]] + return table + + +def _reordered() -> dict[str, Any]: + table = _tier_table(len(_FAMILIES)) + table["sections"].reverse() + return table + + +@pytest.mark.parametrize( + "table", + [ + _ABSENT, + "not-a-table", + _tier_table(len(_FAMILIES) - 1), + _tier_table(len(_FAMILIES) + 1), + {**_tier_table(len(_FAMILIES)), "headers": ["Tier", "arm-0", "arm-1"]}, + _narrow_rows(), + _reordered(), + ], + ids=[ + "absent", + "not-object", + "one-column-short", + "one-column-extra", + "no-metric", + "narrow-row", + "reordered", + ], +) +def test_a_broken_tier_table_reds_exactly_its_row(table: object) -> None: + rows = _run(_TableApi(table)) + assert _failing_download_rows(rows) == {"status_carries_tier_comparison_table"} + + +@pytest.mark.parametrize( + ("get", "reddened"), + [ + (FakeArtefactGet(disposition=None), {"matrix_md_download_is_attachment"}), + (FakeArtefactGet(disposition="inline"), {"matrix_md_download_is_attachment"}), + (FakeArtefactGet(download_body=b"other"), {"matrix_md_download_bytes_match_artefact"}), + ( + FakeArtefactGet(download_body=b"", plain_body=b""), + {"matrix_md_download_bytes_match_artefact"}, + ), + ( + FakeArtefactGet(status=403), + {"matrix_md_download_is_attachment", "matrix_md_download_bytes_match_artefact"}, + ), + ], + ids=["no-disposition", "inline", "different-bytes", "empty-bytes", "download-refused"], +) +def test_a_broken_download_reds_exactly_its_row(get: FakeArtefactGet, reddened: set[str]) -> None: + rows = _run(FakeEvalApi(), artefact_get=get) + assert _failing_download_rows(rows) == reddened + + +def test_the_download_flag_is_sent_and_a_refusal_fetches_nothing() -> None: + class NoDownloadApi(FakeEvalApi): + def __call__( + self, route: str, token: str | None, body: Mapping[str, Any] + ) -> tuple[int, dict[str, Any]]: + if body.get("action") == "artefact_url" and body.get("download") is True: + self.calls.append(dict(body)) + return 400, {"error": {"code": "validation_failed", "message": "download"}} + return super().__call__(route, token, body) + + get = FakeArtefactGet() + api = NoDownloadApi() + rows = _run(api, artefact_get=get) + assert _failing_download_rows(rows) == { + "matrix_md_download_is_attachment", + "matrix_md_download_bytes_match_artefact", + } + assert get.urls == [] + assert any(c.get("download") is True and c.get("key") == "matrix.md" for c in api.calls) + + +def test_a_run_without_a_matrix_md_artefact_fails_both_download_rows() -> None: + class NoMarkdownApi(FakeEvalApi): + def _finish(self, run: dict[str, Any], status: str) -> None: + super()._finish(run, status) + run["artifacts"].pop("matrix_md") + + rows = _run(NoMarkdownApi()) + assert _failing_download_rows(rows) == { + "matrix_md_download_is_attachment", + "matrix_md_download_bytes_match_artefact", + } + + +def test_get_artefact_refuses_a_non_https_url() -> None: + with pytest.raises(ValueError, match="non-https"): + mod.get_artefact("http://bucket.s3.amazonaws.com/k") diff --git a/tests/unit/test_smoke_gateway_tools.py b/tests/unit/test_smoke_gateway_tools.py index facd673..a3b0d17 100644 --- a/tests/unit/test_smoke_gateway_tools.py +++ b/tests/unit/test_smoke_gateway_tools.py @@ -8,6 +8,7 @@ from __future__ import annotations import copy +import functools import json import time from collections.abc import Mapping @@ -20,11 +21,12 @@ _OUT_OF_BOOK_ACCOUNT_INDEX, _SERVICE_BOOK_SIZE, McpResult, + RawResult, ServicePrincipalFixture, _live_table_prefix, _require_disposable_tenant, - checks, ) +from scripts.smoke.gateway_tools import checks as _module_checks from scripts.smoke.harness import CheckResult, context_for_test from scripts.smoke.verified_claims import ( USE_ACCESS, @@ -177,6 +179,22 @@ def _get_account_result(self, arguments: Mapping[str, Any]) -> McpResult: return _tool_call_success(rep_id=_FORGED_REP_ID) if allowed else _scope_denied(account_id) +class _FakeRawCaller: + """A raw-body Gateway fake: refuses a JSON-RPC array body the way the interceptor does.""" + + def __init__(self, reply: RawResult | None = None) -> None: + self.reply = reply if reply is not None else _rpc_refusal() + self.calls: list[tuple[str, str | None]] = [] + + def __call__(self, body: str, token: str | None) -> RawResult: + self.calls.append((body, token)) + return self.reply + + +#: `scripts.smoke.gateway_tools.checks` with the refusing raw-body fake unless one is given. +checks = functools.partial(_module_checks, raw_caller=_FakeRawCaller()) + + def _run(caller: _FakeCaller, **kwargs: Any) -> list[CheckResult]: ctx = context_for_test(outputs=_OUTPUTS) return list(checks(ctx, mcp_caller=caller, **kwargs)) @@ -1685,3 +1703,173 @@ def refuse_open(request: Any, timeout: float) -> Any: monkeypatch.setattr(gateway_tools, "open_https", refuse_open) with pytest.raises(RuntimeError, match=_SECRET_ENV): gateway_tools.mint_machine_token(_secret_ctx("")) + + +# -------------------------------------------------------------------------------------- +# A JSON-RPC array body answers no tool call +# -------------------------------------------------------------------------------------- + +_ARRAY_ROW = "array_body_answers_no_tool_call" +_ARRAY_ROWS = (_ARRAY_ROW, "array_body_reaches_no_tool") + + +def _array_rows(raw: _FakeRawCaller, *, token: str | None = "tok") -> dict[str, CheckResult]: # nosec B107 # test placeholder, not a credential + caller = _FakeCaller(tools_list=_tools_list_result()) + results = _run(caller, token=token, raw_caller=raw) + rows = { + check: [r for r in results if r.resource == "gateway_tools" and r.check == check] + for check in _ARRAY_ROWS + } + for check, matches in rows.items(): + assert len(matches) == 1, (check, matches) + return {check: matches[0] for check, matches in rows.items()} + + +def test_the_old_interceptor_refusal_row_is_gone() -> None: + caller = _FakeCaller(tools_list=_tools_list_result()) + results = _run(caller, token="tok", raw_caller=_FakeRawCaller()) # nosec B106 # test placeholder, not a credential + assert not [r for r in results if r.check == "array_body_refused_by_interceptor"] + + +def test_an_error_reply_passes_records_its_code_and_no_tool_is_deferred() -> None: + rows = _array_rows(_FakeRawCaller()) + assert rows[_ARRAY_ROW].status == "pass" + assert "error.code=-32001" in rows[_ARRAY_ROW].detail + assert rows["array_body_reaches_no_tool"].status == "defer" + assert rows["array_body_reaches_no_tool"].defer_reason == "no_per_request_invocation_signal" + + +def test_the_array_body_is_one_well_formed_tool_call_sent_with_the_token() -> None: + raw = _FakeRawCaller() + _array_rows(raw) + assert len(raw.calls) == 1 + body, token = raw.calls[0] + assert token == "tok" # nosec B105 # test placeholder, not a credential + decoded = json.loads(body) + assert isinstance(decoded, list) and len(decoded) == 1 + (call,) = decoded + assert call["method"] == "tools/call" + assert call["params"]["arguments"]["account_id"] == _IN_BOOK_ACCOUNT + + +@pytest.mark.parametrize( + ("reply", "recorded"), + [ + ( + {"jsonrpc": "2.0", "id": None, "error": {"code": -32600, "message": "Invalid Request"}}, + "error.code=-32600", + ), + ([_rpc_refusal()], "array[1]"), + ({"jsonrpc": "2.0", "id": "smoke-array-body", "result": {}}, "result:object{}"), + ([], "array[0]"), + ( + { + "jsonrpc": "2.0", + "id": "smoke-array-body", + "result": { + "isError": True, + "content": [ + {"type": "text", "text": "InternalServerException - Tool execution failed"} + ], + }, + }, + "result.isError=True", + ), + ( + [ + {"jsonrpc": "2.0", "id": "a", "result": {"isError": True, "content": []}}, + _rpc_refusal(), + ], + "array[2]", + ), + ], + ids=[ + "other-error-code", + "batch-of-errors", + "result-without-tool-output", + "empty-batch", + "gateway-tool-error", + "batch-tool-error-and-rpc-error", + ], +) +def test_a_reply_without_tool_output_passes_and_records_its_shape( + reply: RawResult, recorded: str +) -> None: + rows = _array_rows(_FakeRawCaller(reply)) + assert rows[_ARRAY_ROW].status == "pass", rows[_ARRAY_ROW].detail + assert recorded in rows[_ARRAY_ROW].detail + + +@pytest.mark.parametrize( + ("reply", "fragment"), + [ + ([_tool_call_success()], "tool-call output"), + (_tool_call_success(), "tool-call output"), + ( + {"jsonrpc": "2.0", "id": "x", "result": {"structuredContent": {"a": 1}}}, + "structuredContent", + ), + ( + {"jsonrpc": "2.0", "id": "x", "result": {"isError": False, "content": []}}, + "without `isError: true`", + ), + ({"jsonrpc": "2.0", "id": "x", "result": {"content": [{"type": "text"}]}}, "content"), + ( + [ + {"jsonrpc": "2.0", "id": "a", "result": {"isError": True, "content": []}}, + _tool_call_success(), + ], + "tool-call output", + ), + ("transport error calling https://gateway.example.invalid/mcp: reset", "transport"), + (["not-an-object"], "not a JSON object"), + ], + ids=[ + "batch-answered", + "answered", + "structured", + "is-error-false", + "content-without-is-error", + "batch-one-refused-one-answered", + "transport", + "scalar", + ], +) +def test_a_reply_with_tool_output_or_none_to_judge_fails_only_the_array_row( + reply: RawResult, fragment: str +) -> None: + rows = _array_rows(_FakeRawCaller(reply)) + assert rows[_ARRAY_ROW].status == "fail" + assert fragment in rows[_ARRAY_ROW].detail + assert rows["array_body_reaches_no_tool"].status == "defer" + + +def test_a_gateway_tool_error_reply_records_no_error_text() -> None: + reply = { + "jsonrpc": "2.0", + "id": "smoke-array-body", + "result": { + "isError": True, + "content": [ + {"type": "text", "text": "InternalServerException - Tool execution failed"} + ], + }, + } + detail = _array_rows(_FakeRawCaller(reply))[_ARRAY_ROW].detail + assert "InternalServerException" not in detail + assert "Tool execution failed" not in detail + + +def test_the_recorded_shape_carries_no_reply_values() -> None: + rows = _array_rows(_FakeRawCaller([_tool_call_success(rep_id="rep-secret-value")])) + detail = rows[_ARRAY_ROW].detail + assert "rep-secret-value" not in detail + assert _IN_BOOK_ACCOUNT not in detail + assert "Authentication failed" not in _array_rows(_FakeRawCaller())[_ARRAY_ROW].detail + + +def test_no_token_fails_the_array_body_row_without_sending_it() -> None: + raw = _FakeRawCaller() + rows = _array_rows(raw, token=None) + assert rows[_ARRAY_ROW].status == "fail" + assert raw.calls == [] diff --git a/tests/unit/test_smoke_harness.py b/tests/unit/test_smoke_harness.py index 47c751a..078a3b9 100644 --- a/tests/unit/test_smoke_harness.py +++ b/tests/unit/test_smoke_harness.py @@ -2153,3 +2153,24 @@ def test_the_direct_urlopen_scan_control_finds_a_planted_call() -> None: planted = "import urllib.request\nurllib.request.urlopen('https://x', timeout=1)\n" assert _direct_urlopen_calls(planted) == [2] assert _direct_urlopen_calls("from urllib.request import urlopen\nurlopen('x')\n") == [2] + + +def test_is_timeout_follows_the_cause_chain_of_a_re_raised_transport_error() -> None: + """A taxonomy error raised `from` a botocore transport error is still a timeout.""" + + class EndpointConnectionError(Exception): + """Named to match botocore's type, which is how `is_timeout` recognises it.""" + + class StoreBusyError(Exception): + """Stands in for the store layer's retryable taxonomy error.""" + + def _raise() -> None: + try: + raise EndpointConnectionError("unreachable") + except EndpointConnectionError as exc: + raise StoreBusyError("busy") from exc + + with pytest.raises(StoreBusyError) as raised: + _raise() + assert harness.is_timeout(raised.value) is True + assert harness.is_timeout(StoreBusyError("busy")) is False diff --git a/tests/unit/test_smoke_iam_roles.py b/tests/unit/test_smoke_iam_roles.py index 6cdf735..c4573c9 100644 --- a/tests/unit/test_smoke_iam_roles.py +++ b/tests/unit/test_smoke_iam_roles.py @@ -96,6 +96,16 @@ } +#: The real supplementary rows, kept before the autouse fixture below replaces them. +_REAL_SUPPLEMENTARY_CHECKS: Final = iam_roles.supplementary_checks + + +@pytest.fixture(autouse=True) +def _no_supplementary_rows(monkeypatch: pytest.MonkeyPatch) -> None: + """Matrix tests stub only the IAM client; the supplementary rows are tested on their own below.""" + monkeypatch.setattr(iam_roles, "supplementary_checks", lambda _ctx: iter(())) + + @pytest.fixture(autouse=True) def _fixture_matrix(monkeypatch: pytest.MonkeyPatch) -> None: monkeypatch.setattr( @@ -1336,7 +1346,12 @@ def test_expected_check_count_is_derived_from_the_real_files_not_hardcoded( ), (conditioned_rows, sweep_rows) assert tool_rows > 0 and sweep_rows > 0 assert expectation.minimum == ( - roles * triples + non_own_rows + scope_rows + conditioned_rows + roles * 4 + roles * triples + + non_own_rows + + scope_rows + + conditioned_rows + + roles * 4 + + iam_roles.SUPPLEMENTARY_ROW_COUNT ) assert str(roles) in expectation.basis and str(triples) in expectation.basis assert f"{scope_rows} index_scope_denied" in expectation.basis @@ -1366,8 +1381,13 @@ def test_the_floor_rejects_the_harness_s_own_single_synthesised_failure( assert str(expectation.minimum) in verdict.detail -def test_a_complete_run_satisfies_its_own_floor() -> None: +def test_a_complete_run_satisfies_its_own_floor(monkeypatch: pytest.MonkeyPatch) -> None: """A complete run over the fixture matrix satisfies its own floor.""" + supplementary = [ + CheckResult(resource="s", check=f"supplementary_{n}", status="pass", detail="") + for n in range(iam_roles.SUPPLEMENTARY_ROW_COUNT) + ] + monkeypatch.setattr(iam_roles, "supplementary_checks", lambda _ctx: iter(supplementary)) clients = _StubbedClientSet() for role_function in _SORTED_FUNCTIONS: clients.add_role_for(role_function) @@ -1625,7 +1645,7 @@ def test_the_correct_code_control_is_unchanged_by_the_blanking(self) -> None: assert {name: len(pairs) for name, pairs in locals_grants.items()} == { "dynamodb_grants": 1, "eval_trigger_eval_runs_grants": 6, - "tool_dynamodb_grants": 33, + "tool_dynamodb_grants": 34, } assert len(iam_roles._terraform_tool_grants()) == len(ALL_TOOLS) @@ -1955,6 +1975,7 @@ def test_the_real_composition_declares_exactly_the_status_and_sweep_index_querie ("revert_audit_record", "opportunities", "dynamodb:Query"): "gsi_account", ("revert_audit_record", "activities", "dynamodb:Query"): "gsi_account", ("revert_audit_record", "notes", "dynamodb:Query"): "gsi_opportunity", + ("approve_proposal", "opportunities", "dynamodb:Query"): "gsi_account", } assert _real_terraform_index_only_grants() == expected # These index grants are gone. @@ -4108,6 +4129,7 @@ def test_the_real_block_names_the_revert_child_indexes(self) -> None: ("revert_audit_record", "opportunities"): ("gsi_account",), ("revert_audit_record", "activities"): ("gsi_account", "gsi_opportunity"), ("revert_audit_record", "notes"): ("gsi_opportunity",), + ("approve_proposal", "opportunities"): ("gsi_account",), } def test_an_absent_block_is_no_scoping(self, tmp_path: Path) -> None: @@ -4528,3 +4550,295 @@ def test_an_empty_select_condition_is_no_condition(self) -> None: def test_an_unreadable_select_condition_raises(self, select: str) -> None: with pytest.raises(iam_roles.UnreadableTerraformGrantsError): self._grants(select) + + +# --------------------------------------------------------------------------- +# Supplementary rows: non-API roles refused the cursor key and the allowlist parameter, and +# approve_proposal's opportunities Query confined to gsi_account. +# --------------------------------------------------------------------------- + +_SUP_ACCOUNT: Final = "123456789012" +_SUP_KEY_ARN: Final = "arn:aws:kms:us-east-1:123456789012:key/0000aaaa-1111-2222-3333-4444bbbb5555" +_SUP_PARAMETER: Final = "/crm-agent-eval/api/allowed-client-ids" +_SUP_PARAMETER_ARN: Final = f"arn:aws:ssm:us-east-1:{_SUP_ACCOUNT}:parameter{_SUP_PARAMETER}" +_SUP_TABLE: Final = "crm-agent-evalopportunities" +_SUP_TABLE_ARN: Final = f"arn:aws:dynamodb:us-east-1:{_SUP_ACCOUNT}:table/{_SUP_TABLE}" +_SUP_INDEXES: Final = ("gsi_account", "gsi_tenant", "gsi_stage") + + +def _sup_role_arn(name: str) -> str: + return f"arn:aws:iam::{_SUP_ACCOUNT}:role/{name}" + + +_SUP_APPROVE_ARN: Final = _sup_role_arn(iam_roles._role_name("approve_proposal")) + +#: (role ARN, action, resource ARN) triples the healthy fake allows; everything else is implicitDeny. +_SUP_HEALTHY_ALLOWED: Final = frozenset( + {(_SUP_APPROVE_ARN, "dynamodb:Query", f"{_SUP_TABLE_ARN}/index/gsi_account")} +) + + +class _SupIam: + def __init__(self, allowed: frozenset[tuple[str, str, str]], roles: Sequence[str]) -> None: + self.allowed = allowed + self.roles = list(roles) + self.requests: list[dict[str, Any]] = [] + + def get_paginator(self, name: str) -> Any: + assert name == "list_roles" + roles = self.roles + + class _Paginator: + def paginate(self) -> Any: + half = len(roles) // 2 + for chunk in (roles[:half], roles[half:]): + yield {"Roles": [{"RoleName": r, "Arn": _sup_role_arn(r)} for r in chunk]} + + return _Paginator() + + def simulate_principal_policy(self, **request: Any) -> dict[str, Any]: + self.requests.append(request) + triple = (request["PolicySourceArn"], request["ActionNames"][0], request["ResourceArns"][0]) + decision = "allowed" if triple in self.allowed else "implicitDeny" + return {"EvaluationResults": [{"EvalDecision": decision, "MissingContextValues": []}]} + + +class _SupLambda: + def __init__(self, env: dict[str, str]) -> None: + self.env = env + + def get_function_configuration(self, FunctionName: str) -> dict[str, Any]: # noqa: N803 + assert FunctionName == iam_roles.CURSOR_ENV_FUNCTION + return {"Environment": {"Variables": dict(self.env)}} + + +class _SupDynamo: + def __init__(self, indexes: Sequence[str]) -> None: + self.indexes = list(indexes) + + def describe_table(self, TableName: str) -> dict[str, Any]: # noqa: N803 + assert TableName == _SUP_TABLE + return {"Table": {"GlobalSecondaryIndexes": [{"IndexName": n} for n in self.indexes]}} + + +class _SupSts: + def __init__(self, fail: bool = False) -> None: + self.fail = fail + + def get_caller_identity(self) -> dict[str, str]: + if self.fail: + raise RuntimeError("no credentials") + return {"Account": _SUP_ACCOUNT} + + +_SUP_ALL_ROLES: Final = ( + *iam_roles.NON_API_ROLE_NAMES.values(), + iam_roles._role_name("approve_proposal"), + "crm-agent-eval-unrelated-role", +) +_SUP_ENV: Final = { + iam_roles.CURSOR_KEY_ENV: _SUP_KEY_ARN, + iam_roles.ALLOWLIST_PARAMETER_ENV: _SUP_PARAMETER, +} + + +def _sup_run( + *, + allowed: frozenset[tuple[str, str, str]] = _SUP_HEALTHY_ALLOWED, + roles: Sequence[str] = _SUP_ALL_ROLES, + env: dict[str, str] | None = None, + indexes: Sequence[str] = _SUP_INDEXES, + sts_fails: bool = False, +) -> tuple[dict[str, Any], _SupIam]: + iam = _SupIam(allowed, roles) + ctx = context_for_test( + outputs={"dynamodb_table_names": {"opportunities": _SUP_TABLE}}, + clients={ + "iam": iam, + "lambda": _SupLambda(dict(_SUP_ENV) if env is None else env), + "dynamodb": _SupDynamo(indexes), + "sts": _SupSts(sts_fails), + }, + ) + results = list(_REAL_SUPPLEMENTARY_CHECKS(ctx)) + assert len(results) == iam_roles.SUPPLEMENTARY_ROW_COUNT, [r.check for r in results] + rows = {r.check: r for r in results} + assert len(rows) == len(results), "duplicate supplementary row names" + return rows, iam + + +def _failing(rows: dict[str, Any]) -> set[str]: + return {name for name, row in rows.items() if row.status != "pass"} + + +def test_supplementary_rows_all_pass_on_a_healthy_deployment() -> None: + rows, _ = _sup_run() + assert _failing(rows) == set(), {n: r.detail for n, r in rows.items() if r.status != "pass"} + assert set(rows) == { + *( + f"{check}:{label}" + for label in iam_roles.NON_API_ROLE_NAMES + for check in ( + "cursor_key_use_denied", + "allowlist_parameter_write_denied", + "allowlist_parameter_read_denied", + ) + ), + "approve_query_gsi_account_allowed", + "approve_query_base_table_denied", + "approve_query_other_indexes_denied", + "approve_scan_denied", + } + + +def _sup_named_role(label: str) -> str: + return _sup_role_arn(iam_roles.NON_API_ROLE_NAMES[label]) + + +@pytest.mark.parametrize( + ("extra_allowed", "expected_failure"), + [ + ( + (_sup_named_role("sweep_task"), "kms:Decrypt", _SUP_KEY_ARN), + "cursor_key_use_denied:sweep_task", + ), + ( + (_sup_named_role("pre_token_generation"), "kms:Encrypt", _SUP_KEY_ARN), + "cursor_key_use_denied:pre_token_generation", + ), + ( + (_sup_named_role("codebuild"), "ssm:PutParameter", _SUP_PARAMETER_ARN), + "allowlist_parameter_write_denied:codebuild", + ), + ( + (_sup_named_role("sweep_task"), "ssm:LabelParameterVersion", _SUP_PARAMETER_ARN), + "allowlist_parameter_write_denied:sweep_task", + ), + ( + (_sup_named_role("pre_token_generation"), "ssm:GetParameter", _SUP_PARAMETER_ARN), + "allowlist_parameter_read_denied:pre_token_generation", + ), + ((_SUP_APPROVE_ARN, "dynamodb:Query", _SUP_TABLE_ARN), "approve_query_base_table_denied"), + ( + (_SUP_APPROVE_ARN, "dynamodb:Query", f"{_SUP_TABLE_ARN}/index/gsi_stage"), + "approve_query_other_indexes_denied", + ), + ( + (_SUP_APPROVE_ARN, "dynamodb:Scan", f"{_SUP_TABLE_ARN}/index/gsi_account"), + "approve_scan_denied", + ), + ((_SUP_APPROVE_ARN, "dynamodb:Scan", _SUP_TABLE_ARN), "approve_scan_denied"), + ], +) +def test_each_over_grant_fails_exactly_its_own_row( + extra_allowed: tuple[str, str, str], expected_failure: str +) -> None: + rows, _ = _sup_run(allowed=_SUP_HEALTHY_ALLOWED | {extra_allowed}) + assert _failing(rows) == {expected_failure} + + +def test_a_refused_gsi_account_query_fails_only_the_allowed_row() -> None: + rows, _ = _sup_run(allowed=frozenset()) + assert _failing(rows) == {"approve_query_gsi_account_allowed"} + + +def test_the_cursor_simulation_sends_the_valid_encryption_context() -> None: + """A refusal caused by a missing context would prove nothing, so the valid one is sent.""" + _, iam = _sup_run() + kms = [r for r in iam.requests if r["ActionNames"][0].startswith("kms:")] + assert kms, "no cursor-key simulation was made" + for request in kms: + context = {e["ContextKeyName"]: e["ContextKeyValues"] for e in request["ContextEntries"]} + assert context["kms:EncryptionContext:purpose"] == ["crm-cursor"] + assert request["ResourceArns"] == [_SUP_KEY_ARN] + + +def test_the_parameter_arn_is_built_from_the_functions_env_value() -> None: + _, iam = _sup_run() + ssm = {r["ResourceArns"][0] for r in iam.requests if r["ActionNames"][0].startswith("ssm:")} + assert ssm == {_SUP_PARAMETER_ARN} + + +def test_an_unknown_simulation_decision_is_never_a_pass() -> None: + class _Broken(_SupIam): + def simulate_principal_policy(self, **request: Any) -> dict[str, Any]: + return {"EvaluationResults": []} + + iam = _Broken(_SUP_HEALTHY_ALLOWED, _SUP_ALL_ROLES) + ctx = context_for_test( + outputs={"dynamodb_table_names": {"opportunities": _SUP_TABLE}}, + clients={ + "iam": iam, + "lambda": _SupLambda(dict(_SUP_ENV)), + "dynamodb": _SupDynamo(_SUP_INDEXES), + "sts": _SupSts(), + }, + ) + results = list(_REAL_SUPPLEMENTARY_CHECKS(ctx)) + assert results and all(r.status == "fail" for r in results) + + +def test_a_role_missing_from_list_roles_fails_its_three_rows_only() -> None: + absent = iam_roles.NON_API_ROLE_NAMES["codebuild"] + rows, _ = _sup_run(roles=[r for r in _SUP_ALL_ROLES if r != absent]) + assert _failing(rows) == { + "cursor_key_use_denied:codebuild", + "allowlist_parameter_write_denied:codebuild", + "allowlist_parameter_read_denied:codebuild", + } + assert absent in rows["cursor_key_use_denied:codebuild"].detail + + +def test_a_missing_approve_role_fails_the_four_approve_rows() -> None: + absent = iam_roles._role_name("approve_proposal") + rows, _ = _sup_run(roles=[r for r in _SUP_ALL_ROLES if r != absent]) + assert _failing(rows) == { + "approve_query_gsi_account_allowed", + "approve_query_base_table_denied", + "approve_query_other_indexes_denied", + "approve_scan_denied", + } + + +def test_a_missing_cursor_key_env_fails_only_the_cursor_rows() -> None: + env = {iam_roles.ALLOWLIST_PARAMETER_ENV: _SUP_PARAMETER} + rows, _ = _sup_run(env=env) + assert _failing(rows) == { + f"cursor_key_use_denied:{label}" for label in iam_roles.NON_API_ROLE_NAMES + } + assert iam_roles.CURSOR_KEY_ENV in rows["cursor_key_use_denied:sweep_task"].detail + + +def test_a_missing_parameter_env_fails_only_the_parameter_rows() -> None: + rows, _ = _sup_run(env={iam_roles.CURSOR_KEY_ENV: _SUP_KEY_ARN}) + assert _failing(rows) == { + f"{check}:{label}" + for label in iam_roles.NON_API_ROLE_NAMES + for check in ("allowlist_parameter_write_denied", "allowlist_parameter_read_denied") + } + + +def test_a_table_without_gsi_account_fails_every_approve_row() -> None: + rows, _ = _sup_run(indexes=("gsi_tenant",)) + assert _failing(rows) == { + "approve_query_gsi_account_allowed", + "approve_query_base_table_denied", + "approve_query_other_indexes_denied", + "approve_scan_denied", + } + + +def test_an_identity_failure_fails_every_row() -> None: + rows, _ = _sup_run(sts_fails=True) + assert _failing(rows) == set(rows) + + +def test_checks_appends_the_supplementary_rows_after_the_matrix( + monkeypatch: pytest.MonkeyPatch, +) -> None: + marker = CheckResult(resource="m", check="matrix_row", status="pass", detail="") + extra = CheckResult(resource="s", check="supplementary_row", status="pass", detail="") + monkeypatch.setattr(iam_roles, "_role_matrix_checks", lambda _ctx: iter([marker])) + monkeypatch.setattr(iam_roles, "supplementary_checks", lambda _ctx: iter([extra])) + ctx = context_for_test(clients={}, outputs={}) + assert [r.check for r in iam_roles.checks(ctx)] == ["matrix_row", "supplementary_row"] diff --git a/tests/unit/test_smoke_lambda_actions.py b/tests/unit/test_smoke_lambda_actions.py index a57812f..e7a38f6 100644 --- a/tests/unit/test_smoke_lambda_actions.py +++ b/tests/unit/test_smoke_lambda_actions.py @@ -12,7 +12,7 @@ import boto3 import pytest from botocore.stub import ANY, Stubber -from scripts.smoke.harness import context_for_test +from scripts.smoke.harness import CheckResult, context_for_test from scripts.smoke.lambda_actions import ( _EMPTY_BOOK_DENIAL_TOOLS, _EXPLICIT_FILTER_TOOL, @@ -23,6 +23,17 @@ _PRIMARY_CONTACT_TOOL, _T3_PENDING_TOOLS, CONTACT_DEPARTED_MISSING_SCOPE, + CURSOR_ENV_CHECK, + CURSOR_KEY_ARN_CHECK, + CURSOR_KEY_RESOURCE, + CURSOR_KEY_ROTATION_CHECK, + CURSOR_KEY_SHAPE_CHECK, + CURSOR_KEY_TAG_CHECK, + CURSOR_OTHER_OPERATION_CHECK, + CURSOR_OTHER_REP_CHECK, + CURSOR_PAGE_TWO_CHECK, + CURSOR_TAMPERED_CHECK, + CURSOR_TOOLS, DEPARTED_CONTACT_CHECKS, DEPARTED_REACTIVATED_CHECK, DEPARTED_REFUSED_CHECK, @@ -30,7 +41,17 @@ EMPTY_BOOK_MISSING_SCOPE, EXPLICIT_FILTER_CHECK, FUNCTION_NAME_PREFIX, + KMS_ADMIN_DENIED_CHECK, + KMS_NO_CONTEXT_CHECK, + KMS_OTHER_ACTIONS_CHECK, + KMS_OTHER_PURPOSE_CHECK, + KMS_OUTSIDE_IDENTITY_CHECK, + KMS_OUTSIDE_KEY_POLICY_CHECK, + KMS_USE_ALLOWED_CHECK, + LONG_TEXT_CAP_CHECK, MALFORMED_PAGE_CONTEXT_CHECK, + NO_SECOND_PAGE_DEFER_REASON, + NON_CURSOR_PROBE_TOOL, SMOKE_PHONE, _check_explicit_filter_denied, _check_foreign_primary_contact_refused, @@ -39,10 +60,13 @@ _check_primary_contact_accepted, _departed_contact_checks, checks, + cursor_event, empty_book_listing_event, explicit_filter_event, function_name_for, + guarded_extra_checks, in_scope_event, + long_text_event, out_of_scope_event, page_context_tools, primary_contact_event, @@ -52,10 +76,12 @@ seeded_in_scope_account_id, seeded_other_account_contact_id, seeded_out_of_scope_account_id, + tampered_cursor, ) from scripts.smoke.tenant import SmokeTenant, TenantTeardownError -from crm.toolspec.definitions import ALL_TOOLS, ToolDefinition +from crm.cursor import CURSOR_KMS_KEY_ENV, CURSOR_PURPOSE +from crm.toolspec.definitions import ALL_TOOLS, LONG_TEXT_MAX_LENGTH, ToolDefinition _TEST_TENANT = "eval-smoke-testfixedrunid" #: Placeholder credential for a client whose calls never leave the process; not a secret. @@ -66,6 +92,20 @@ _TEST_OUTPUTS = {"dynamodb_table_names": {"eval_runs": "crm-agent-eval-testeval_runs"}} +@pytest.fixture(autouse=True) +def _no_extra_rows(monkeypatch: pytest.MonkeyPatch) -> None: + """Keep the per-tool orchestration tests to the per-tool rows. + + The cursor, cursor-key and long-text rows are tested through `guarded_extra_checks` directly, + and `test_the_tool_checks_end_with_the_extra_rows` asserts they are wired in. + """ + + def none(ctx: Any, *, tenant: str) -> Any: + return iter(()) + + monkeypatch.setattr("scripts.smoke.lambda_actions.guarded_extra_checks", none) + + def _fake_lifecycle( *, teardown_raises: Exception | None = None ) -> tuple[list[str], list[str], list[str], dict[str, Any]]: @@ -1386,3 +1426,558 @@ def invoke(self, **kwargs: Any) -> dict[str, Any]: results = {r.check: r for r in _departed_contact_checks(ctx, tenant=_TEST_TENANT)} assert results[DEPARTED_REFUSED_CHECK].status == "fail" assert "FunctionError" in results[DEPARTED_REFUSED_CHECK].detail + + +# --------------------------------------------------------------------------- +# Pagination cursors, the cursor key and the long-text cap +# --------------------------------------------------------------------------- + +_KEY_ARN = "arn:aws:kms:us-east-1:123456789012:key/11111111-2222-3333-4444-5555aaaa5555" +_OTHER_KEY_ARN = "arn:aws:kms:us-east-1:123456789012:key/99999999-2222-3333-4444-5555bbbb5555" +_UNRELATED_RESOURCE = "arn:aws:kms:us-east-1:123456789012:alias/unrelated" +#: A key policy as KMS stores it, every statement on `Resource "*"`, plus a non-key list element. +_KEY_POLICY = json.dumps( + { + "Version": "2012-10-17", + "Statement": [ + { + "Sid": "EnableIAMUserPermissions", + "Effect": "Allow", + "Action": "kms:*", + "Resource": "*", + }, + { + "Sid": "Mixed", + "Effect": "Deny", + "Action": "kms:*", + "Resource": ["*", _UNRELATED_RESOURCE], + }, + ], + } +) + + +def _role_arn(tool_name: str) -> str: + return f"arn:aws:iam::123456789012:role/crm-agent-eval-{tool_name}-role" + + +def _issued_cursor(tool_name: str) -> str: + return f"QUJDRA{tool_name.replace('_', '')}cursorQUJDRA" + + +def _tool_of(function_name: str) -> str: + return function_name.removeprefix(FUNCTION_NAME_PREFIX) + + +def _cursor_refusal_body() -> dict[str, Any]: + return { + "statusCode": 400, + "error": { + "code": "validation_failed", + "message": "The cursor is not valid.", + "next_step": "fix_arguments", + "source": "cursor", + }, + } + + +class _CursorLambda: + """A `lambda` double modelling the deployed cursor tools and every function's configuration. + + A cursor is accepted only by the tool that issued it, unaltered, for the issuing rep. Each + `accept_*` set names tools that wrongly accept that kind of bad cursor. + """ + + def __init__( + self, + *, + issuing: Sequence[str] = CURSOR_TOOLS, + page_two_error: Sequence[str] = (), + accept_tampered: Sequence[str] = (), + accept_other_rep: Sequence[str] = (), + accept_other_operation: Sequence[str] = (), + refusal_body: dict[str, Any] | None = None, + env_overrides: dict[str, str | None] | None = None, + long_text_body: dict[str, Any] | None = None, + ) -> None: + self.issuing = set(issuing) + self.page_two_error = set(page_two_error) + self.accept_tampered = set(accept_tampered) + self.accept_other_rep = set(accept_other_rep) + self.accept_other_operation = set(accept_other_operation) + self.refusal_body = refusal_body or _cursor_refusal_body() + self.env_overrides = env_overrides or {} + self.long_text_body = long_text_body or _validation_failed_body() + self.events: list[tuple[str, dict[str, Any]]] = [] + + def invoke(self, **kwargs: Any) -> dict[str, Any]: + tool = _tool_of(str(kwargs["FunctionName"])) + event = json.loads(kwargs["Payload"]) + self.events.append((tool, event)) + return _payload_response(self._answer(tool, event)) + + def _answer(self, tool: str, event: dict[str, Any]) -> dict[str, Any]: + if tool == "create_note": + return self.long_text_body + cursor = event.get("cursor") + if cursor is None: + body: dict[str, Any] = {"items": [{"id": "x"}]} + if tool in self.issuing: + body["next_cursor"] = _issued_cursor(tool) + return {"statusCode": 200, "body": body} + owner = next((name for name in CURSOR_TOOLS if _issued_cursor(name) == cursor), None) + rep = event["_identity"]["rep_id"] + if owner is None: + accepted = tool in self.accept_tampered + elif owner != tool: + accepted = tool in self.accept_other_operation + elif rep != "rep-ashford": + accepted = tool in self.accept_other_rep + elif tool in self.page_two_error: + return _internal_error_body() + else: + accepted = True + return {"statusCode": 200, "body": {"items": []}} if accepted else self.refusal_body + + def get_function_configuration(self, *, FunctionName: str) -> dict[str, Any]: # noqa: N803 + tool = _tool_of(FunctionName) + default = _KEY_ARN if tool in CURSOR_TOOLS else None + value = self.env_overrides.get(tool, default) + variables = {"LOG_LEVEL": "INFO"} + if value is not None: + variables[CURSOR_KMS_KEY_ENV] = value + return {"Role": _role_arn(tool), "Environment": {"Variables": variables}} + + +class _Kms: + def __init__( + self, + *, + rotation: bool = True, + metadata: dict[str, Any] | None = None, + tags: list[dict[str, str]] | None = None, + policy_error: bool = False, + ) -> None: + self.rotation = rotation + self.metadata = metadata or { + "KeySpec": "SYMMETRIC_DEFAULT", + "KeyUsage": "ENCRYPT_DECRYPT", + "MultiRegion": False, + } + self.tags = ( + tags + if tags is not None + else [{"TagKey": "data-classification", "TagValue": "internal"}] + ) + self.policy_error = policy_error + + def get_key_rotation_status(self, *, KeyId: str) -> dict[str, Any]: # noqa: N803 + assert KeyId == _KEY_ARN + return {"KeyRotationEnabled": self.rotation} + + def describe_key(self, *, KeyId: str) -> dict[str, Any]: # noqa: N803 + return {"KeyMetadata": self.metadata} + + def list_resource_tags(self, *, KeyId: str) -> dict[str, Any]: # noqa: N803 + return {"Tags": self.tags} + + def get_key_policy(self, *, KeyId: str, PolicyName: str) -> dict[str, Any]: # noqa: N803 + if self.policy_error: + raise RuntimeError("AccessDeniedException") + assert PolicyName == "default" + return {"Policy": _KEY_POLICY} + + +class _Iam: + """Simulates the intended policy: the five roles may Encrypt/Decrypt under the cursor purpose, + the key policy explicitly denies administration and every outside principal. + + `overrides[(role tool, action, purpose-or-None, with_policy)]` replaces one decision; + `missing_context` names roles whose allowed results report missing context values. + """ + + def __init__( + self, + *, + overrides: dict[tuple[str, str, str | None, bool], str] | None = None, + missing_context: Sequence[str] = (), + ) -> None: + self.overrides = overrides or {} + self.missing_context = set(missing_context) + self.requests: list[dict[str, Any]] = [] + + def simulate_principal_policy(self, **request: Any) -> dict[str, Any]: + self.requests.append(request) + role_tool = ( + str(request["PolicySourceArn"]).split("crm-agent-eval-", 1)[1].removesuffix("-role") + ) + purpose = next( + ( + entry["ContextKeyValues"][0] + for entry in request["ContextEntries"] + if entry["ContextKeyName"] == "kms:EncryptionContext:purpose" + ), + None, + ) + with_policy = "ResourcePolicy" in request + results = [] + for action in request["ActionNames"]: + decision = self._decide(role_tool, action, purpose, with_policy) + decision = self.overrides.get((role_tool, action, purpose, with_policy), decision) + result: dict[str, Any] = {"EvalActionName": action, "EvalDecision": decision} + if decision == "allowed" and role_tool in self.missing_context: + result["MissingContextValues"] = ["kms:EncryptionContext:tenant"] + results.append(result) + return {"EvaluationResults": results, "IsTruncated": False} + + @staticmethod + def _decide(role_tool: str, action: str, purpose: str | None, with_policy: bool) -> str: + if with_policy and ( + action in {"kms:PutKeyPolicy", "kms:ScheduleKeyDeletion", "kms:DisableKeyRotation"} + or role_tool not in CURSOR_TOOLS + ): + return "explicitDeny" + if ( + role_tool in CURSOR_TOOLS + and action in {"kms:Encrypt", "kms:Decrypt"} + and purpose == CURSOR_PURPOSE + ): + return "allowed" + return "implicitDeny" + + +def _extra_ctx( + lam: _CursorLambda | None = None, + kms: _Kms | None = None, + iam: _Iam | None = None, + outputs: dict[str, Any] | None = None, +) -> Any: + return context_for_test( + clients={"lambda": lam or _CursorLambda(), "kms": kms or _Kms(), "iam": iam or _Iam()}, + outputs=outputs, + tenant=_TEST_TENANT, + ) + + +def _rows(ctx: Any) -> list[Any]: + return list(guarded_extra_checks(ctx, tenant=_TEST_TENANT)) + + +def _failing(rows: Sequence[Any]) -> set[tuple[str, str]]: + return {(r.resource, r.check) for r in rows if r.status == "fail"} + + +def test_every_extra_row_passes_against_the_intended_deployment() -> None: + rows = _rows(_extra_ctx()) + assert _failing(rows) == set() + assert {r.status for r in rows} == {"pass"} + checks_by_resource: dict[str, set[str]] = {} + for row in rows: + checks_by_resource.setdefault(row.resource, set()).add(row.check) + for name in CURSOR_TOOLS: + assert { + CURSOR_PAGE_TWO_CHECK, + CURSOR_TAMPERED_CHECK, + CURSOR_OTHER_REP_CHECK, + CURSOR_OTHER_OPERATION_CHECK, + CURSOR_ENV_CHECK, + KMS_USE_ALLOWED_CHECK, + KMS_OTHER_PURPOSE_CHECK, + KMS_NO_CONTEXT_CHECK, + KMS_OTHER_ACTIONS_CHECK, + KMS_ADMIN_DENIED_CHECK, + } <= checks_by_resource[name] + assert { + CURSOR_KEY_ARN_CHECK, + CURSOR_KEY_ROTATION_CHECK, + CURSOR_KEY_SHAPE_CHECK, + CURSOR_KEY_TAG_CHECK, + } == checks_by_resource[CURSOR_KEY_RESOURCE] + assert { + CURSOR_ENV_CHECK, + KMS_OUTSIDE_IDENTITY_CHECK, + KMS_OUTSIDE_KEY_POLICY_CHECK, + } == checks_by_resource[NON_CURSOR_PROBE_TOOL] + assert LONG_TEXT_CAP_CHECK in checks_by_resource["create_note"] + every_tool = {tool.name for tool in ALL_TOOLS} + assert {r.resource for r in rows if r.check == CURSOR_ENV_CHECK} == every_tool, ( + "the env row must cover every action Lambda" + ) + + +@pytest.mark.parametrize( + ("lam", "expected"), + [ + ( + _CursorLambda(page_two_error=["search_accounts"]), + {("search_accounts", "cursor_page_two")}, + ), + ( + _CursorLambda(accept_tampered=["list_activities"]), + {("list_activities", "cursor_tampered_refused")}, + ), + ( + _CursorLambda(accept_other_rep=["search_opportunities"]), + {("search_opportunities", "cursor_other_rep_refused")}, + ), + ( + _CursorLambda(accept_other_operation=["list_proposals"]), + {("list_proposals", "cursor_other_operation_refused")}, + ), + ( + _CursorLambda(env_overrides={"list_audit_records": None}), + {("list_audit_records", "cursor_key_env")}, + ), + ( + _CursorLambda(env_overrides={"get_account": _KEY_ARN}), + {("get_account", "cursor_key_env")}, + ), + ( + _CursorLambda(long_text_body=_success_body()), + {("create_note", "long_text_cap_enforced")}, + ), + ], + ids=[ + "page-two-error", + "tampered-accepted", + "other-rep-accepted", + "other-operation-accepted", + "env-missing-on-cursor-tool", + "env-set-on-other-tool", + "over-cap-accepted", + ], +) +def test_a_broken_function_property_fails_exactly_its_row( + lam: _CursorLambda, expected: set[tuple[str, str]] +) -> None: + assert _failing(_rows(_extra_ctx(lam=lam))) == expected + + +def test_a_5xx_refusal_is_not_a_clean_cursor_refusal() -> None: + lam = _CursorLambda(refusal_body=_internal_error_body()) + failing = _failing(_rows(_extra_ctx(lam=lam))) + refusal_checks = { + CURSOR_TAMPERED_CHECK, + CURSOR_OTHER_REP_CHECK, + CURSOR_OTHER_OPERATION_CHECK, + } + assert failing == {(name, check) for name in CURSOR_TOOLS for check in refusal_checks} + + +def test_a_refusal_without_source_cursor_fails() -> None: + body = _cursor_refusal_body() + del body["error"]["source"] + failing = _failing(_rows(_extra_ctx(lam=_CursorLambda(refusal_body=body)))) + assert ("search_opportunities", CURSOR_TAMPERED_CHECK) in failing + + +@pytest.mark.parametrize( + ("kms", "expected"), + [ + (_Kms(rotation=False), {(CURSOR_KEY_RESOURCE, "cursor_key_rotation_enabled")}), + ( + _Kms( + metadata={ + "KeySpec": "SYMMETRIC_DEFAULT", + "KeyUsage": "ENCRYPT_DECRYPT", + "MultiRegion": True, + } + ), + {(CURSOR_KEY_RESOURCE, "cursor_key_shape")}, + ), + (_Kms(tags=[]), {(CURSOR_KEY_RESOURCE, "cursor_key_classified")}), + ( + _Kms(policy_error=True), + {(name, KMS_ADMIN_DENIED_CHECK) for name in CURSOR_TOOLS} + | {(NON_CURSOR_PROBE_TOOL, KMS_OUTSIDE_KEY_POLICY_CHECK)}, + ), + ], + ids=["rotation-off", "multi-region", "untagged", "key-policy-unreadable"], +) +def test_a_broken_key_property_fails_exactly_its_row( + kms: _Kms, expected: set[tuple[str, str]] +) -> None: + assert _failing(_rows(_extra_ctx(kms=kms))) == expected + + +@pytest.mark.parametrize( + ("iam", "expected"), + [ + ( + _Iam( + overrides={ + ("search_accounts", "kms:Decrypt", CURSOR_PURPOSE, False): "implicitDeny" + } + ), + {("search_accounts", KMS_USE_ALLOWED_CHECK)}, + ), + (_Iam(missing_context=["list_activities"]), {("list_activities", KMS_USE_ALLOWED_CHECK)}), + ( + _Iam(overrides={("list_proposals", "kms:Encrypt", "other", False): "allowed"}), + {("list_proposals", KMS_OTHER_PURPOSE_CHECK)}, + ), + ( + _Iam(overrides={("list_audit_records", "kms:Encrypt", None, False): "allowed"}), + {("list_audit_records", KMS_NO_CONTEXT_CHECK)}, + ), + ( + _Iam( + overrides={ + ( + "search_opportunities", + "kms:GenerateDataKey", + CURSOR_PURPOSE, + False, + ): "allowed" + } + ), + {("search_opportunities", KMS_OTHER_ACTIONS_CHECK)}, + ), + ( + _Iam( + overrides={("search_accounts", "kms:PutKeyPolicy", CURSOR_PURPOSE, True): "allowed"} + ), + {("search_accounts", KMS_ADMIN_DENIED_CHECK)}, + ), + ( + _Iam(overrides={("get_account", "kms:Encrypt", CURSOR_PURPOSE, False): "allowed"}), + {("get_account", KMS_OUTSIDE_IDENTITY_CHECK)}, + ), + ( + _Iam(overrides={("get_account", "kms:Decrypt", CURSOR_PURPOSE, True): "implicitDeny"}), + {("get_account", KMS_OUTSIDE_KEY_POLICY_CHECK)}, + ), + ], + ids=[ + "use-not-allowed", + "missing-context", + "other-purpose-allowed", + "no-context-allowed", + "generate-data-key-allowed", + "admin-not-explicitly-denied", + "outside-role-allowed", + "outside-role-only-implicitly-denied", + ], +) +def test_a_broken_simulation_fails_exactly_its_row( + iam: _Iam, expected: set[tuple[str, str]] +) -> None: + assert _failing(_rows(_extra_ctx(iam=iam))) == expected + + +def test_the_simulations_use_the_deployed_roles_and_the_live_key_policy() -> None: + iam = _Iam() + _rows(_extra_ctx(iam=iam)) + sources = {request["PolicySourceArn"] for request in iam.requests} + assert sources == {_role_arn(name) for name in (*CURSOR_TOOLS, NON_CURSOR_PROBE_TOOL)} + assert all(request["ResourceArns"] == [_KEY_ARN] for request in iam.requests) + with_policy = [request for request in iam.requests if "ResourcePolicy" in request] + assert with_policy + for request in with_policy: + sent = [s["Resource"] for s in json.loads(request["ResourcePolicy"])["Statement"]] + assert sent == [_KEY_ARN, [_KEY_ARN, _UNRELATED_RESOURCE]], sent + for request in with_policy: + principal = next( + e["ContextKeyValues"] + for e in request["ContextEntries"] + if e["ContextKeyName"] == "aws:PrincipalArn" + ) + assert principal == [request["PolicySourceArn"]] + + +def test_two_cursor_keys_fail_only_the_consistency_row_and_skip_the_dependents() -> None: + lam = _CursorLambda(env_overrides={"search_accounts": _OTHER_KEY_ARN}) + rows = _rows(_extra_ctx(lam=lam)) + assert _failing(rows) == {(CURSOR_KEY_RESOURCE, CURSOR_KEY_ARN_CHECK)} + skipped = {(r.resource, r.check) for r in rows if r.status == "skip"} + assert (CURSOR_KEY_RESOURCE, CURSOR_KEY_ROTATION_CHECK) in skipped + assert (NON_CURSOR_PROBE_TOOL, KMS_OUTSIDE_KEY_POLICY_CHECK) in skipped + + +def test_a_tool_with_no_second_page_defers_its_own_rows_and_still_checks_foreign_cursors() -> None: + lam = _CursorLambda(issuing=["search_opportunities", "search_accounts", "list_activities"]) + rows = _rows(_extra_ctx(lam=lam)) + assert _failing(rows) == set() + deferred = {(r.resource, r.check) for r in rows if r.status == "defer"} + assert deferred == { + (name, check) + for name in ("list_audit_records", "list_proposals") + for check in (CURSOR_PAGE_TWO_CHECK, CURSOR_TAMPERED_CHECK, CURSOR_OTHER_REP_CHECK) + } + assert all(r.defer_reason == NO_SECOND_PAGE_DEFER_REASON for r in rows if r.status == "defer") + other_operation = { + r.resource: r.status for r in rows if r.check == CURSOR_OTHER_OPERATION_CHECK + } + assert other_operation == dict.fromkeys(CURSOR_TOOLS, "pass") + + +def test_no_cursor_issued_anywhere_fails_every_other_operation_row() -> None: + rows = _rows(_extra_ctx(lam=_CursorLambda(issuing=[]))) + assert _failing(rows) == {(name, CURSOR_OTHER_OPERATION_CHECK) for name in CURSOR_TOOLS} + + +def test_the_replays_send_the_real_cursor_altered_only_as_each_row_says() -> None: + lam = _CursorLambda() + _rows(_extra_ctx(lam=lam)) + resumed = [(tool, event) for tool, event in lam.events if "cursor" in event] + own = _issued_cursor("search_opportunities") + sent = [event for tool, event in resumed if tool == "search_opportunities"] + cursors = [event["cursor"] for event in sent] + reps = [event["_identity"]["rep_id"] for event in sent] + assert cursors[0] == own and reps[0] == "rep-ashford" + assert cursors[1] == tampered_cursor(own) and cursors[1] != own and len(cursors[1]) == len(own) + assert cursors[2] == own and reps[2] != "rep-ashford" + assert cursors[3] != own and cursors[3] in {_issued_cursor(n) for n in CURSOR_TOOLS} + page_one = [ + event for tool, event in lam.events if "cursor" not in event and tool != "create_note" + ] + assert all(event["limit"] == 1 for event in page_one if "limit" in event) + + +def test_the_page_one_calls_force_a_second_page_where_the_tool_takes_a_limit() -> None: + for name in CURSOR_TOOLS: + event = cursor_event(name, tenant=_TEST_TENANT) + tool = next(t for t in ALL_TOOLS if t.name == name) + assert ("limit" in event) == ("limit" in tool.input_schema["properties"]) + assert "cursor" not in event + assert event["_identity"]["tenant"] == _TEST_TENANT + assert cursor_event("list_activities", tenant=_TEST_TENANT)["opportunity_id"] + + +def test_tampering_changes_one_character_within_the_url_safe_alphabet() -> None: + for cursor in ("AAAA", "ABCD", "x-_y"): + tampered = tampered_cursor(cursor) + assert len(tampered) == len(cursor) + assert sum(a != b for a, b in zip(cursor, tampered, strict=True)) == 1 + with pytest.raises(ValueError): + tampered_cursor("") + + +def test_the_long_text_body_is_exactly_one_over_the_cap() -> None: + event = long_text_event(tenant=_TEST_TENANT) + assert len(event["body"]) == LONG_TEXT_MAX_LENGTH + 1 + assert event["_identity"]["tenant"] == _TEST_TENANT + + +def test_the_long_text_cap_row_fails_on_a_5xx() -> None: + lam = _CursorLambda(long_text_body=_internal_error_body()) + assert _failing(_rows(_extra_ctx(lam=lam))) == {("create_note", LONG_TEXT_CAP_CHECK)} + + +def test_the_tool_checks_end_with_the_extra_rows(monkeypatch: pytest.MonkeyPatch) -> None: + """`_run_all_tool_checks` yields `guarded_extra_checks` last, under the same tenant.""" + seen: list[str] = [] + + def recorder(ctx: Any, *, tenant: str) -> Any: + seen.append(tenant) + yield CheckResult(resource="sentinel", check="extra", status="pass") + + monkeypatch.setattr("scripts.smoke.lambda_actions.guarded_extra_checks", recorder) + client = _lambda_client() + stubber = Stubber(client) + _stub_all_pass(stubber, ALL_TOOLS) + stubber.activate() + results = list(checks(context_for_test(clients={"lambda": client}, tenant=_TEST_TENANT))) + stubber.deactivate() + assert seen == [_TEST_TENANT] + assert (results[-1].resource, results[-1].check) == ("sentinel", "extra") diff --git a/tests/unit/test_smoke_mcp_client_compat.py b/tests/unit/test_smoke_mcp_client_compat.py index 703c698..4bd0bfd 100644 --- a/tests/unit/test_smoke_mcp_client_compat.py +++ b/tests/unit/test_smoke_mcp_client_compat.py @@ -364,7 +364,6 @@ def test_the_sdk_performs_the_full_handshake_and_one_read_call_on_gateway1_only( "host": _G1_HOST, "name": f"crm-actions___{module.READ_TOOL}", "arguments": {"account_id": _ACCOUNT}, - "_meta": {}, } ] @@ -805,8 +804,8 @@ def test_the_module_is_registered_in_layer_5() -> None: def test_the_sdk_is_a_pinned_dev_dependency() -> None: pyproject = (REPO_ROOT / "pyproject.toml").read_text(encoding="utf-8") lock = (REPO_ROOT / "requirements.txt").read_text(encoding="utf-8") - assert '"mcp==2.1.1"' in pyproject - assert re.search(r"^mcp==2\.1\.1$", lock, re.MULTILINE) + assert '"mcp==2.3.0"' in pyproject + assert re.search(r"^mcp==2\.3\.0$", lock, re.MULTILINE) def test_the_cli_fails_loudly_on_missing_outputs(tmp_path: Path) -> None: diff --git a/tests/unit/test_smoke_store_principal_deny.py b/tests/unit/test_smoke_store_principal_deny.py index f92e025..a2ae9ed 100644 --- a/tests/unit/test_smoke_store_principal_deny.py +++ b/tests/unit/test_smoke_store_principal_deny.py @@ -42,6 +42,36 @@ def _key_arn(suffix: str) -> str: _DYNAMODB_KEY_ARN = _key_arn("00a6") +_CURSOR_KEY_ARN = _key_arn("00c7") +_CURSOR_ROLE = f"arn:aws:iam::{_ACCOUNT}:role/crm-agent-eval-search_opportunities-role" +#: A key policy as KMS stores it: every statement names `Resource "*"`, plus one list resource that +#: is not the key and must reach the simulation unchanged. +_UNRELATED_RESOURCE = f"arn:aws:kms:us-east-1:{_ACCOUNT}:alias/unrelated" +_CURSOR_POLICY = json.dumps( + { + "Version": "2012-10-17", + "Statement": [ + { + "Sid": "EnableIAMUserPermissions", + "Effect": "Allow", + "Action": "kms:*", + "Resource": "*", + }, + { + "Sid": "DenyOutsidePurpose", + "Effect": "Deny", + "Action": "kms:Encrypt", + "Resource": ["*"], + }, + { + "Sid": "Mixed", + "Effect": "Deny", + "Action": "kms:Decrypt", + "Resource": ["*", _UNRELATED_RESOURCE], + }, + ], + } +) _CRM_TABLE = "crm-agent-eval-accounts" _VPC_ID = "vpc-0abc" _RUNTIME_LOG_GROUP = "/aws/bedrock-agentcore/runtimes/crm_agent_eval-AbCdEf-DEFAULT" @@ -478,6 +508,14 @@ class FakeAccount: } ) operator_errors: dict[tuple[str, str], Err] = field(default_factory=dict) + cursor_env: dict[str, str] = field( + default_factory=lambda: {"CRM_CURSOR_KMS_KEY_ARN": _CURSOR_KEY_ARN} + ) + cursor_policy: str | None = _CURSOR_POLICY + cursor_encrypt_outcome: Err | None = field( + default_factory=lambda: _explicit_deny("kms:Encrypt", _CURSOR_KEY_ARN) + ) + cursor_simulated: dict[str, dict[str, str]] = field(default_factory=dict) create_role_error: Err | None = None delete_role_error: Err | None = None calls: list[tuple[str, str, str, dict[str, Any]]] = field(default_factory=list) @@ -647,8 +685,20 @@ def _policy(self, p: dict[str, Any], missing: Err) -> Any: text = self.policies[store] return missing if text is None else {"Policy": text} + def operator_lambda_get_function_configuration(self, p: dict[str, Any]) -> Any: + assert p == {"FunctionName": "crm-agent-eval-search_opportunities"} + return { + "FunctionName": p["FunctionName"], + "Role": _CURSOR_ROLE, + "Environment": {"Variables": dict(self.cursor_env)}, + } + def operator_kms_get_key_policy(self, p: dict[str, Any]) -> Any: assert p["PolicyName"] == "default" + if p["KeyId"] == _CURSOR_KEY_ARN: + if self.cursor_policy is None: + return Err("NotFoundException", "no", 400) + return {"Policy": self.cursor_policy, "PolicyName": "default"} return {**self._policy(p, Err("NotFoundException", "no", 400)), "PolicyName": "default"} def operator_s3_get_bucket_policy(self, p: dict[str, Any]) -> Any: @@ -726,6 +776,8 @@ def operator_sts_assume_role(self, p: dict[str, Any]) -> Any: } def operator_iam_simulate_principal_policy(self, p: dict[str, Any]) -> Any: + if p["ResourceArns"] == [_CURSOR_KEY_ARN]: + return self._simulate_cursor(p) store = next(s for s, b in _BUCKETS.items() if p["ResourceArns"] == [f"arn:aws:s3:::{b}"]) principal = p["PolicySourceArn"] assert p["ContextEntries"][0] == { @@ -747,6 +799,41 @@ def operator_iam_simulate_principal_policy(self, p: dict[str, Any]) -> Any: "IsTruncated": False, } + def _simulate_cursor(self, p: dict[str, Any]) -> Any: + principal = p["PolicySourceArn"] + sent = json.loads(p["ResourcePolicy"]) + resources = [s["Resource"] for s in sent["Statement"]] + assert resources == [ + _CURSOR_KEY_ARN, + [_CURSOR_KEY_ARN], + [_CURSOR_KEY_ARN, _UNRELATED_RESOURCE], + ] + assert "*" not in json.dumps(resources) + context = {e["ContextKeyName"]: e["ContextKeyValues"] for e in p["ContextEntries"]} + assert context["aws:PrincipalArn"] == [principal] + assert context["kms:EncryptionContext:purpose"] == ["crm-cursor"] + assert context["kms:EncryptionContextKeys"] == ["purpose", "tenant", "rep_id", "operation"] + decisions = self.cursor_simulated.get(principal, {}) + + def default(action: str) -> str: + if principal == _PROBE_ROLE_ARN: + return "explicitDeny" + if principal == _CURSOR_ROLE and action not in ("kms:Encrypt", "kms:Decrypt"): + return "explicitDeny" + return "allowed" + + return { + "EvaluationResults": [ + { + "EvalActionName": action, + "EvalResourceName": _CURSOR_KEY_ARN, + "EvalDecision": decisions.get(action, default(action)), + } + for action in p["ActionNames"] + ], + "IsTruncated": False, + } + def operator_iam_delete_role_policy(self, _p: dict[str, Any]) -> Any: return {} @@ -795,6 +882,12 @@ def probe_kms_decrypt(self, p: dict[str, Any]) -> Any: p, smoke.PROBE_DECRYPT, {"Plaintext": b"PLAINTEXT-KEY-MATERIAL", "KeyId": p["KeyId"]} ) + def probe_kms_encrypt(self, p: dict[str, Any]) -> Any: + assert p["KeyId"] == _CURSOR_KEY_ARN + assert p["EncryptionContext"]["purpose"] == "crm-cursor" + assert set(p["EncryptionContext"]) == {"purpose", "tenant", "rep_id", "operation"} + return self.cursor_encrypt_outcome or {"CiphertextBlob": b"c", "KeyId": p["KeyId"]} + def probe_kms_revoke_grant(self, p: dict[str, Any]) -> Any: return self._probe(p, smoke.PROBE_REVOKE_GRANT, {}) @@ -1047,6 +1140,7 @@ def _expected_checks() -> set[str]: checks |= {f"probe_denied:{s}:{c}" for s in smoke.PROBED_STORES for c in smoke.probe_calls(s)} checks |= {f"log_ingestion_current:{w}" for w in smoke.INGESTION_LOGS} checks |= {f"admin_simulated_denied:{s}" for s in smoke.BUCKET_STORES} + checks |= set(smoke.CURSOR_KEY_CHECKS) checks |= { "state_operator_list_matches_stack", "ecr_layer_fetch", @@ -1094,7 +1188,7 @@ def test_compliant_account_passes_every_row_and_meets_the_coverage_floor(tmp_pat run = _run(tmp_path) assert _not_passing(run) == {} assert {r.check for r in run.rows} == _expected_checks() - assert len(run.rows) == smoke.expected_check_count(context_for_test()).minimum == 66 + assert len(run.rows) == smoke.expected_check_count(context_for_test()).minimum == 71 def test_pre_group_g_account_fails_every_probe_and_shape_row(tmp_path: Path) -> None: @@ -1113,7 +1207,7 @@ def test_pre_group_g_account_fails_every_probe_and_shape_row(tmp_path: Path) -> for c in by if ( c.startswith(("probe_denied:", "admin_simulated_denied:")) - and not c.startswith("probe_denied:dynamodb_key:") + and not c.startswith(("probe_denied:dynamodb_key:", "probe_denied:cursor_key:")) ) or c.endswith("_policy_shape") or c == "state_operator_list_matches_stack" @@ -1363,6 +1457,7 @@ def test_every_probe_call_is_non_mutating_by_construction(tmp_path: Path) -> Non ("kms", "GenerateDataKey"), ("kms", "Decrypt"), ("kms", "RevokeGrant"), + ("kms", "Encrypt"), ("s3", "GetObject"), ("s3", "ListObjectsV2"), ("s3", "PutObject"), @@ -1374,6 +1469,8 @@ def test_every_probe_call_is_non_mutating_by_construction(tmp_path: Path) -> Non ("ecr", "GetDownloadUrlForLayer"), } for service, operation, params in probe: + if operation == "Encrypt": + assert params["Plaintext"] == b"probe" if operation == "PutObject": assert params["IfMatch"] == '"probe-nonexistent-etag"' assert params["Key"] == f"probe-{_RUN_ID}/absent" @@ -1465,6 +1562,7 @@ def test_probe_role_trusts_only_the_operator_and_allows_exactly_the_probed_resou for a in ("dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:PutResourcePolicy") } expected |= {("logs:FilterLogEvents", _LOG_GROUP_ARN)} + expected |= {("kms:Encrypt", _CURSOR_KEY_ARN)} assert granted == expected assert all(st["Effect"] == "Allow" for st in policy["Statement"]) @@ -1488,11 +1586,15 @@ def broken_factory(*_: Any) -> Any: by = run.by_check() assert by["probe_role_setup"].status == "fail" assert by["probe_role_deleted"].status == "pass" - probe_rows = [c for c in by if c.startswith(("probe_denied:", "admin_simulated_denied:"))] - assert len(probe_rows) == 37 + probe_rows = [ + c + for c in by + if c.startswith(("probe_denied:", "admin_simulated_denied:", "cursor_key_simulated:")) + ] + assert len(probe_rows) == 42 assert {by[c].status for c in probe_rows} == {"fail"} assert by["logs_probe_denied"].status == "fail" - assert len(run.rows) == 67 + assert len(run.rows) == 72 def test_a_create_role_failure_is_reported_and_teardown_tolerates_no_such_entity( @@ -1542,7 +1644,9 @@ def test_admin_simulation_uses_the_live_document_and_fails_on_any_non_explicit_d assert "simulation pair of the live document" in row.detail assert set(_not_passing(run)) == {"admin_simulated_denied:cloudtrail_bucket"} simulations = [ - p for _, o, p in run.account.calls_by("operator") if o == "SimulatePrincipalPolicy" + p + for _, o, p in run.account.calls_by("operator") + if o == "SimulatePrincipalPolicy" and p["ResourceArns"] != [_CURSOR_KEY_ARN] ] assert len(simulations) == 10 assert sorted({p["PolicySourceArn"] for p in simulations}) == sorted( @@ -1684,7 +1788,7 @@ def test_absent_backend_config_defers_only_the_state_store_rows(tmp_path: Path) if any(c.endswith(f"{s}_policy_shape") or f":{s}" in c for s in smoke.STATE_STORES) } | {"state_operator_list_matches_stack"} assert set(not_passing) == state_checks - assert len(run.rows) == 66 + assert len(run.rows) == 71 def test_absent_operator_output_defers_every_shape_and_logs_key_event_row(tmp_path: Path) -> None: @@ -1708,7 +1812,7 @@ def test_absent_bucket_output_defers_that_bucket_and_its_key(tmp_path: Path) -> not_passing = _not_passing(run) assert set(not_passing.values()) == {DEFER} assert set(not_passing) == {c for c in _expected_checks() if "eval_artifacts" in c} - assert len(run.rows) == 66 + assert len(run.rows) == 71 def test_absent_runtime_output_defers_the_ecr_row(tmp_path: Path) -> None: @@ -1756,7 +1860,7 @@ def test_backend_config_missing_a_field_fails_the_state_rows(tmp_path: Path) -> by = run.by_check() assert by["tfstate_key_policy_shape"].status == "fail" assert "dynamodb_table" in by["tfstate_key_policy_shape"].detail - assert len(run.rows) == 66 + assert len(run.rows) == 71 # --------------------------------------------------------------------------- @@ -2129,3 +2233,104 @@ def test_absent_runtime_log_group_output_defers_only_its_ingestion_row(tmp_path: outputs = {k: v for k, v in _OUTPUTS.items() if k != "agentcore_runtime_log_group_name"} run = _run(tmp_path, outputs=outputs) assert _not_passing(run) == {"log_ingestion_current:runtime_log": DEFER} + + +# --------------------------------------------------------------------------- +# The pagination-cursor CMK: a real denied Encrypt and four live-policy simulations. +# --------------------------------------------------------------------------- + + +def _cursor_failing(run: Run) -> set[str]: + by = run.by_check() + return {check for check in smoke.CURSOR_KEY_CHECKS if by[check].status != "pass"} + + +def test_the_cursor_key_rows_pass_on_a_compliant_account(tmp_path: Path) -> None: + run = _run(tmp_path) + assert _cursor_failing(run) == set() + encrypts = [p for s, o, p in run.account.calls_by("probe") if o == "Encrypt"] + assert len(encrypts) == 1 and encrypts[0]["KeyId"] == _CURSOR_KEY_ARN + + +@pytest.mark.parametrize( + "outcome", + [ + None, + _implicit_deny("kms:Encrypt", _CURSOR_KEY_ARN), + Err("NotFoundException", "Key does not exist", 400), + ], + ids=["encrypt-succeeded", "implicit-deny", "reached-the-key"], +) +def test_a_cursor_encrypt_not_refused_by_the_key_policy_reds_exactly_its_row( + tmp_path: Path, outcome: Err | None +) -> None: + run = _run(tmp_path, FakeAccount(cursor_encrypt_outcome=outcome)) + assert _cursor_failing(run) == {smoke.CHECK_CURSOR_PROBE} + assert run.by_check()[smoke.CHECK_CURSOR_PROBE].status == "fail" + + +@pytest.mark.parametrize( + ("principal", "decisions", "reddened"), + [ + (_PROBE_ROLE_ARN, {"kms:Encrypt": "allowed"}, smoke.CHECK_CURSOR_SIM_PROBE), + (_PROBE_ROLE_ARN, {"kms:Decrypt": "implicitDeny"}, smoke.CHECK_CURSOR_SIM_PROBE), + (_CURSOR_ROLE, {"kms:Decrypt": "explicitDeny"}, smoke.CHECK_CURSOR_SIM_ROLE), + (_OPERATOR_ARN, {"kms:Encrypt": "explicitDeny"}, smoke.CHECK_CURSOR_SIM_OPERATOR), + (_CURSOR_ROLE, {"kms:PutKeyPolicy": "allowed"}, smoke.CHECK_CURSOR_SIM_ADMIN), + (_CURSOR_ROLE, {"kms:DisableKeyRotation": "implicitDeny"}, smoke.CHECK_CURSOR_SIM_ADMIN), + ], + ids=[ + "probe-allowed", + "probe-implicit", + "role-denied", + "operator-denied", + "role-may-change-policy", + "role-rotation-implicit", + ], +) +def test_each_cursor_simulation_reds_exactly_its_row( + tmp_path: Path, principal: str, decisions: dict[str, str], reddened: str +) -> None: + run = _run(tmp_path, FakeAccount(cursor_simulated={principal: decisions})) + assert _cursor_failing(run) == {reddened} + assert "not a call" in run.by_check()[reddened].detail + + +def test_an_unreadable_cursor_key_policy_fails_every_simulation_but_still_probes( + tmp_path: Path, +) -> None: + run = _run(tmp_path, FakeAccount(cursor_policy=None)) + assert _cursor_failing(run) == set(smoke.CURSOR_KEY_CHECKS) - {smoke.CHECK_CURSOR_PROBE} + + +def test_a_function_without_the_cursor_key_variable_fails_every_cursor_row( + tmp_path: Path, +) -> None: + run = _run(tmp_path, FakeAccount(cursor_env={})) + assert _cursor_failing(run) == set(smoke.CURSOR_KEY_CHECKS) + by = run.by_check() + assert all(by[c].status == "fail" for c in smoke.CURSOR_KEY_CHECKS) + assert "CRM_CURSOR_KMS_KEY_ARN" in by[smoke.CHECK_CURSOR_PROBE].detail + assert not [o for _s, o, _p in run.account.calls_by("probe") if o == "Encrypt"] + policy = next( + json.loads(p["PolicyDocument"]) + for _s, o, p in run.account.calls_by("operator") + if o == "PutRolePolicy" + ) + assert "ProbeCursorKmsEncrypt" not in {st["Sid"] for st in policy["Statement"]} + + +def test_key_policy_for_simulation_rewrites_only_star_resources() -> None: + from scripts.smoke.harness import key_policy_for_simulation + + rewritten = json.loads(key_policy_for_simulation(_CURSOR_POLICY, _CURSOR_KEY_ARN)) + assert [s["Resource"] for s in rewritten["Statement"]] == [ + _CURSOR_KEY_ARN, + [_CURSOR_KEY_ARN], + [_CURSOR_KEY_ARN, _UNRELATED_RESOURCE], + ] + untouched = json.dumps( + {"Statement": {"Effect": "Deny", "Action": "kms:*", "NotResource": "*", "Resource": "x"}} + ) + single = json.loads(key_policy_for_simulation(untouched, _CURSOR_KEY_ARN))["Statement"] + assert (single["Resource"], single["NotResource"]) == ("x", "*") diff --git a/tests/unit/test_store_transport_errors.py b/tests/unit/test_store_transport_errors.py new file mode 100644 index 0000000..26a3d31 --- /dev/null +++ b/tests/unit/test_store_transport_errors.py @@ -0,0 +1,258 @@ +# SPDX-License-Identifier: MIT +"""Client-side SDK failures on every Store write path, and BatchGetItem no-progress, against moto. + +A transport fault (unreachable endpoint, connect or read timeout) becomes a retryable +:class:`crm.errors.ServiceBusy`; any other SDK-side failure becomes an internal ``CrmError``. The +exception text never reaches the user-facing message. +""" + +from __future__ import annotations + +from collections.abc import Callable, Iterator +from typing import Any + +import boto3 +import pytest +from botocore.exceptions import ( + BotoCoreError, + ConnectTimeoutError, + EndpointConnectionError, + ParamValidationError, + ReadTimeoutError, +) +from moto import mock_aws + +from crm.envelope import IDENTITY_KEY, identity_event +from crm.errors import CrmError, ServiceBusy +from crm.handlers import update_account +from crm.store.keys import derive +from crm.store.provisioning import create_all_tables +from crm.store.store import Store + +pytestmark = pytest.mark.filterwarnings("ignore::DeprecationWarning") + +_ENDPOINT = "https://dynamodb.us-east-1.amazonaws.com" +_SECRET_TEXT = "internal-endpoint-detail" +_TENANT = "demo" +_ACCOUNT = "acct-1" + +_TRANSPORT_FAULTS: dict[str, Callable[[], BotoCoreError]] = { + "endpoint_connection": lambda: EndpointConnectionError(endpoint_url=_ENDPOINT), + "connect_timeout": lambda: ConnectTimeoutError(endpoint_url=_ENDPOINT), + "read_timeout": lambda: ReadTimeoutError(endpoint_url=_ENDPOINT), +} + + +class _FaultyClient: + """Delegates to a real client, raising ``fault()`` from the named operations.""" + + def __init__(self, inner: Any, failing: set[str], fault: Callable[[], BotoCoreError]) -> None: + self._inner = inner + self._failing = failing + self._fault = fault + + def __getattr__(self, name: str) -> Any: + if name in self._failing: + + def _raise(**_kwargs: Any) -> Any: + raise self._fault() + + return _raise + return getattr(self._inner, name) + + +@pytest.fixture +def client() -> Iterator[Any]: + with mock_aws(): + real = boto3.client("dynamodb", region_name="us-east-1") + create_all_tables(real) + Store(client=real).put_item( + "accounts", + derive( + "accounts", + {"account_id": _ACCOUNT, "tenant": _TENANT, "owner_rep_id": "rep-1", "name": "A"}, + ), + ) + yield real + + +def _faulty(client: Any, operations: set[str], fault: Callable[[], BotoCoreError]) -> Store: + return Store(client=_FaultyClient(client, operations, fault)) + + +def _account(**extra: object) -> dict[str, object]: + return { + "account_id": _ACCOUNT, + "tenant": _TENANT, + "owner_rep_id": "rep-1", + "name": "A", + **extra, + } + + +_WRITE_CALLS: dict[str, tuple[set[str], Callable[[Store], object]]] = { + "put_item": ({"put_item"}, lambda s: s.put_item("accounts", _account())), + "put_if_absent": ({"put_item"}, lambda s: s.put_if_absent("accounts", _account())), + "put_idempotent": ( + {"put_item"}, + lambda s: s.put_idempotent("accounts", _account(name="B"), transaction_key="tx-1"), + ), + "delete_item": ({"delete_item"}, lambda s: s.delete_item("accounts", {"account_id": _ACCOUNT})), + "update_item": ( + {"update_item"}, + lambda s: s.update_item( + "accounts", {"account_id": _ACCOUNT}, set_values={"industry": "Retail"}, condition=None + ), + ), + "transact_write": ( + {"transact_write_items"}, + lambda s: s.transact_write( + [{"Put": {"TableName": "accounts", "Item": {"account_id": {"S": "acct-9"}}}}] + ), + ), + "batch_put_items": ( + {"batch_write_item"}, + lambda s: s.batch_put_items("accounts", [_account(account_id="acct-2")]), + ), + "delete_tenant": ({"batch_write_item"}, lambda s: s.delete_tenant(_TENANT)), +} + + +@pytest.mark.parametrize("fault_name", sorted(_TRANSPORT_FAULTS)) +@pytest.mark.parametrize("call_name", sorted(_WRITE_CALLS)) +def test_a_transport_fault_on_a_write_path_is_service_busy( + client: Any, call_name: str, fault_name: str +) -> None: + operations, call = _WRITE_CALLS[call_name] + store = _faulty(client, operations, _TRANSPORT_FAULTS[fault_name]) + + with pytest.raises(ServiceBusy) as raised: + call(store) + + assert raised.value.next_step == "retry_later" + assert _ENDPOINT not in str(raised.value) + assert raised.value.detail is not None and call_name.split("_")[0] in raised.value.detail + + +@pytest.mark.parametrize("call_name", sorted(_WRITE_CALLS)) +def test_a_non_transport_sdk_failure_on_a_write_path_is_internal( + client: Any, call_name: str +) -> None: + operations, call = _WRITE_CALLS[call_name] + store = _faulty(client, operations, lambda: ParamValidationError(report=_SECRET_TEXT)) + + with pytest.raises(CrmError) as raised: + call(store) + + assert not isinstance(raised.value, ServiceBusy) + assert raised.value.code == "internal_error" + assert _SECRET_TEXT not in str(raised.value) + + +def test_an_update_handler_returns_a_retryable_error_on_a_connection_fault(client: Any) -> None: + store = _faulty( + client, + {"put_item", "update_item", "transact_write_items"}, + _TRANSPORT_FAULTS["endpoint_connection"], + ) + event = identity_event( + IDENTITY_KEY, + { + "rep_id": "rep-1", + "book": [_ACCOUNT], + "full_visibility": False, + "principal_type": "user", + "session_id": "sess-1", + "source": "gateway", + "tenant": _TENANT, + }, + {"account_id": _ACCOUNT, "fields": {"industry": "Retail"}, "transaction_key": "tx-h"}, + ) + + result = update_account.handler(event, store=store) + + assert result["statusCode"] == ServiceBusy.http_status, result + assert result["error"]["next_step"] == "retry_later", result + assert _ENDPOINT not in str(result) + + +# --- BatchGetItem no-progress --------------------------------------------------------------- + + +class _UnprocessedBatchGet: + """Returns ``unprocessed_per_call[i]`` of the requested keys as unprocessed on call ``i``.""" + + def __init__(self, inner: Any, unprocessed_per_call: list[int | None]) -> None: + self._inner = inner + self._plan = list(unprocessed_per_call) + self.calls = 0 + + def __getattr__(self, name: str) -> Any: + return getattr(self._inner, name) + + def batch_get_item(self, **kwargs: Any) -> dict[str, Any]: + self.calls += 1 + ((physical, request),) = kwargs["RequestItems"].items() + keys = request["Keys"] + hold = self._plan.pop(0) if self._plan else 0 + hold = len(keys) if hold is None else hold + served = ( + self._inner.batch_get_item(RequestItems={physical: {"Keys": keys[hold:]}}) + if (hold < len(keys)) + else {"Responses": {physical: []}} + ) + unprocessed = {physical: {"Keys": keys[:hold]}} if hold else {} + return {"Responses": served.get("Responses", {}), "UnprocessedKeys": unprocessed} + + +@pytest.fixture +def sleeps(monkeypatch: pytest.MonkeyPatch) -> list[float]: + recorded: list[float] = [] + monkeypatch.setattr("crm.store.store.time.sleep", recorded.append) + return recorded + + +def _seed_accounts(client: Any, count: int) -> list[dict[str, str]]: + store = Store(client=client) + ids = [f"acct-b{index}" for index in range(count)] + store.batch_put_items("accounts", [_account(account_id=i) for i in ids]) + return [{"account_id": i} for i in ids] + + +def test_batch_get_with_no_progress_is_service_busy_after_backoff( + client: Any, sleeps: list[float] +) -> None: + keys = _seed_accounts(client, 3) + fake = _UnprocessedBatchGet(client, [None] * 50) + + with pytest.raises(ServiceBusy) as raised: + Store(client=fake).batch_get_items("accounts", keys) + + assert "batch_get_items" not in str(raised.value) + assert raised.value.detail is not None and "batch_get_items:accounts" in raised.value.detail + assert fake.calls > 1 + assert sleeps and sleeps == sorted(sleeps) and sleeps[-1] > sleeps[0] + + +def test_batch_get_that_stalls_then_progresses_returns_every_item( + client: Any, sleeps: list[float] +) -> None: + keys = _seed_accounts(client, 4) + fake = _UnprocessedBatchGet(client, [None, None, 2, 0]) + + items = Store(client=fake).batch_get_items("accounts", keys) + + assert sorted(str(item["account_id"]) for item in items) == sorted( + k["account_id"] for k in keys + ) + assert len(sleeps) == 2 + + +def test_batch_get_making_partial_progress_never_sleeps(client: Any, sleeps: list[float]) -> None: + keys = _seed_accounts(client, 4) + fake = _UnprocessedBatchGet(client, [3, 2, 1, 0]) + + items = Store(client=fake).batch_get_items("accounts", keys) + + assert len(items) == 4 + assert sleeps == [] diff --git a/tests/unit/test_tool_actor.py b/tests/unit/test_tool_actor.py index 97040bb..5fedee4 100644 --- a/tests/unit/test_tool_actor.py +++ b/tests/unit/test_tool_actor.py @@ -19,7 +19,14 @@ from agents.tier_attribution import InvocationAttribution from agents.tool_actor import TOOL_TIER, ToolActorResult, formulate_and_invoke from agents.turn_driver import session_turn_tuning -from crm.envelope import AGENT_IDENTITY_KEY, CLAIM_REP_ID, CLAIM_TENANT, Identity +from crm.envelope import ( + AGENT_IDENTITY_KEY, + AGENT_PRINCIPAL_TYPE_KEY, + CLAIM_REP_ID, + CLAIM_TENANT, + Identity, + decode_identity, +) from crm.errors import ValidationFailed from crm.toolspec.definitions import BY_NAME from crm.toolspec.validation import validate_arguments @@ -257,6 +264,26 @@ def test_production_dispatch_strips_identity_keys_and_appends_the_trusted_block( assert trusted["claims"][CLAIM_TENANT] == "demo" assert event["account_id"] == "acc-1" # the non-identity arg survives as a sibling + def test_a_service_identity_keeps_its_principal_type_across_the_agent_hop(self) -> None: + identity = Identity( + rep_id="svc-1", book=frozenset({"acc-1"}), principal_type="service", tenant="demo" + ) + + event = agent_identity_event(identity, {"account_id": "acc-1"}) + + assert event[AGENT_IDENTITY_KEY][AGENT_PRINCIPAL_TYPE_KEY] == "service" + decoded = decode_identity(event) + assert decoded.principal_type == "service" + assert decoded.source == "agent" + + def test_a_user_identity_round_trips_unchanged_across_the_agent_hop(self) -> None: + identity = Identity(rep_id="rep-1", book=frozenset({"acc-1", "acc-2"}), tenant="demo") + + decoded = decode_identity(agent_identity_event(identity, {})) + + assert decoded.principal_type == "user" + assert (decoded.rep_id, decoded.book, decoded.tenant) == ("rep-1", identity.book, "demo") + class TestSB4OutOfScopeDenied: def test_out_of_scope_account_id_returns_verbatim_and_classifies_denied(self) -> None: diff --git a/tests/unit/test_update_conditional.py b/tests/unit/test_update_conditional.py new file mode 100644 index 0000000..0ca1f7e --- /dev/null +++ b/tests/unit/test_update_conditional.py @@ -0,0 +1,382 @@ +# SPDX-License-Identifier: MIT +"""Every ``update_*`` handler writes only if the record is unchanged since its consistent read. + +Runs each handler's real entry point against a `moto`-mocked DynamoDB, with a concurrent write +injected between the handler's read and its transaction. A lost race is a 409 ``conflict`` with +``reason="fields_changed"``; the concurrent write's values persist and no audit record is written. +""" + +from __future__ import annotations + +from collections.abc import Callable, Iterator +from dataclasses import dataclass +from typing import Any + +import boto3 +import pytest +from botocore.exceptions import ClientError +from moto import mock_aws + +from crm.envelope import IDENTITY_KEY, identity_event +from crm.errors import Conflict, wrap_aws_error +from crm.handlers import ( + log_activity, + update_account, + update_activity, + update_contact, + update_opportunity, +) +from crm.handlers.wire import ( + put_operation, + raise_if_record_changed, + unchanged_since_read, + unchanged_since_read_values, +) +from crm.store.provisioning import create_all_tables +from crm.store.store import Store + +pytestmark = pytest.mark.filterwarnings("ignore::DeprecationWarning") + +_TENANT = "demo" +_ACCOUNT = "acct-1" +_READ_UPDATED_AT = "2024-02-01T00:00:00+00:00" + + +@dataclass(frozen=True) +class _Case: + table: str + key_attr: str + record_id: str + handler: Callable[..., dict[str, Any]] + field: str + + +_CASES = [ + _Case("accounts", "account_id", _ACCOUNT, update_account.handler, "name"), + _Case("contacts", "contact_id", "cont-1", update_contact.handler, "name"), + _Case("opportunities", "opportunity_id", "opp-1", update_opportunity.handler, "description"), + _Case("activities", "activity_id", "act-1", update_activity.handler, "subject"), +] + + +@pytest.fixture +def client() -> Iterator[Any]: + with mock_aws(): + yield boto3.client("dynamodb", region_name="us-east-1") + + +@pytest.fixture +def store(client: Any) -> Store: + create_all_tables(client) + return Store(client=client) + + +def _seed(store: Store, *, updated_at: str | None) -> None: + stamp = {} if updated_at is None else {"updated_at": updated_at} + store.put_item( + "accounts", + { + "account_id": _ACCOUNT, + "tenant": _TENANT, + "owner_rep_id": "rep-1", + "name": "Acme", + **stamp, + }, + ) + store.put_item( + "contacts", + { + "contact_id": "cont-1", + "tenant": _TENANT, + "account_id": _ACCOUNT, + "name": "Jane Doe", + "status": "active", + "created_at": "2024-01-01T00:00:00+00:00", + **stamp, + }, + ) + store.put_item( + "opportunities", + { + "opportunity_id": "opp-1", + "tenant": _TENANT, + "account_id": _ACCOUNT, + "owner_rep_id": "rep-1", + "name": "Big Deal", + "stage": "Discovery", + "value": 1000, + "primary_contact_id": None, + "last_touch": None, + "created_at": "2024-01-01T00:00:00+00:00", + **stamp, + }, + ) + store.put_item( + "activities", + { + "activity_id": "act-1", + "tenant": _TENANT, + "opportunity_id": "opp-1", + "account_id": _ACCOUNT, + "kind": "call", + "subject": "Intro", + "occurred_at": "2024-01-01T00:00:00+00:00", + "created_at": "2024-01-01T00:00:00+00:00", + **stamp, + }, + ) + + +def _event(case: _Case, value: str, transaction_key: str = "tx-race") -> dict[str, Any]: + identity = { + "rep_id": "rep-1", + "book": [_ACCOUNT], + "full_visibility": False, + "principal_type": "user", + "session_id": "sess-1", + "source": "gateway", + "tenant": _TENANT, + } + args = { + case.key_attr: case.record_id, + "fields": {case.field: value}, + "transaction_key": transaction_key, + } + return identity_event(IDENTITY_KEY, identity, args) + + +def _audit_rows(client: Any, record_id: str) -> list[dict[str, Any]]: + items = client.scan(TableName="audit_records")["Items"] + return [item for item in items if item.get("target_id", {}).get("S") == record_id] + + +def _interpose( + store: Store, monkeypatch: pytest.MonkeyPatch, case: _Case, write: Callable[[], None] +) -> list[bool]: + """Run ``write`` right after the handler reads its target; return each read's ``consistent``.""" + real = store.get_item + consistent_flags: list[bool] = [] + + def _get_item(table: str, key: Any, *, consistent: bool = False) -> Any: + item = real(table, key, consistent=consistent) + if table == case.table and key.get(case.key_attr) == case.record_id: + consistent_flags.append(consistent) + write() + return item + + monkeypatch.setattr(store, "get_item", _get_item) + return consistent_flags + + +def _approve_style_update(client: Any, case: _Case) -> Callable[[], None]: + def _write() -> None: + client.update_item( + TableName=case.table, + Key={case.key_attr: {"S": case.record_id}}, + UpdateExpression="SET approved_marker = :m, updated_at = :t", + ExpressionAttributeValues={ + ":m": {"S": "approved"}, + ":t": {"S": "2024-03-01T00:00:00+00:00"}, + }, + ) + + return _write + + +@pytest.mark.parametrize("updated_at", [_READ_UPDATED_AT, None], ids=["stamped", "unstamped"]) +@pytest.mark.parametrize("case", _CASES, ids=[case.table for case in _CASES]) +def test_concurrent_write_between_read_and_put_is_a_fields_changed_conflict( + store: Store, + client: Any, + monkeypatch: pytest.MonkeyPatch, + case: _Case, + updated_at: str | None, +) -> None: + _seed(store, updated_at=updated_at) + consistent_flags = _interpose(store, monkeypatch, case, _approve_style_update(client, case)) + + result = case.handler(_event(case, "from-the-loser"), store=store) + + assert result["statusCode"] == 409 + assert result["error"]["code"] == "conflict" + assert result["error"]["reason"] == "fields_changed" + assert consistent_flags == [True] + persisted = Store(client=client).get_item(case.table, {case.key_attr: case.record_id}) + assert persisted is not None + assert persisted["approved_marker"] == "approved" + assert persisted["updated_at"] == "2024-03-01T00:00:00+00:00" + assert persisted.get(case.field) != "from-the-loser" + assert _audit_rows(client, case.record_id) == [] + + +@pytest.mark.parametrize("case", _CASES, ids=[case.table for case in _CASES]) +def test_record_deleted_between_read_and_put_is_not_resurrected( + store: Store, client: Any, monkeypatch: pytest.MonkeyPatch, case: _Case +) -> None: + _seed(store, updated_at=_READ_UPDATED_AT) + + def _delete() -> None: + client.delete_item(TableName=case.table, Key={case.key_attr: {"S": case.record_id}}) + + _interpose(store, monkeypatch, case, _delete) + + result = case.handler(_event(case, "from-the-loser"), store=store) + + assert result["statusCode"] == 409 + assert result["error"]["reason"] == "fields_changed" + assert Store(client=client).get_item(case.table, {case.key_attr: case.record_id}) is None + assert _audit_rows(client, case.record_id) == [] + + +@pytest.mark.parametrize("updated_at", [_READ_UPDATED_AT, None], ids=["stamped", "unstamped"]) +@pytest.mark.parametrize("case", _CASES, ids=[case.table for case in _CASES]) +def test_uncontended_update_commits_with_one_audit_record( + store: Store, client: Any, monkeypatch: pytest.MonkeyPatch, case: _Case, updated_at: str | None +) -> None: + _seed(store, updated_at=updated_at) + consistent_flags = _interpose(store, monkeypatch, case, lambda: None) + + result = case.handler(_event(case, "new-value"), store=store) + + assert result["statusCode"] == 200 + assert consistent_flags == [True] + persisted = Store(client=client).get_item(case.table, {case.key_attr: case.record_id}) + assert persisted is not None + assert persisted[case.field] == "new-value" + assert persisted["updated_at"] != updated_at + assert len(_audit_rows(client, case.record_id)) == 1 + + +def test_put_operation_carries_condition_values_and_names() -> None: + operation = put_operation( + "accounts", + {"account_id": "a"}, + condition="attribute_exists(account_id) AND #u = :u", + values={":u": {"S": "x"}}, + names={"#u": "updated_at"}, + ) + assert operation == { + "Put": { + "TableName": "accounts", + "Item": {"account_id": {"S": "a"}}, + "ConditionExpression": "attribute_exists(account_id) AND #u = :u", + "ExpressionAttributeValues": {":u": {"S": "x"}}, + "ExpressionAttributeNames": {"#u": "updated_at"}, + } + } + + +def test_put_operation_without_condition_is_unconditional() -> None: + assert put_operation("accounts", {"account_id": "a"}) == { + "Put": {"TableName": "accounts", "Item": {"account_id": {"S": "a"}}} + } + + +def test_unchanged_since_read_pins_a_string_updated_at() -> None: + item = {"updated_at": _READ_UPDATED_AT} + assert unchanged_since_read(item) == "updated_at = :read_updated_at" + assert unchanged_since_read_values(item) == {":read_updated_at": {"S": _READ_UPDATED_AT}} + + +@pytest.mark.parametrize("item", [{}, {"updated_at": None}], ids=["absent", "null"]) +def test_unchanged_since_read_requires_absent_or_null_when_none_was_read( + item: dict[str, object], +) -> None: + assert "attribute_not_exists(updated_at)" in unchanged_since_read(item) + assert unchanged_since_read_values(item) == {":null_type": {"S": "NULL"}} + + +def _wrapped(response: dict[str, Any]) -> Conflict: + """The taxonomy error ``Store.transact_write`` raises for ``response``, cause attached.""" + client_error = ClientError(response, "TransactWriteItems") + try: + raise wrap_aws_error(client_error, operation="transact_write") from client_error + except Conflict as exc: + return exc + + +def _cancelled(*codes: str) -> Conflict: + return _wrapped( + { + "Error": {"Code": "TransactionCanceledException", "Message": "x"}, + "CancellationReasons": [{"Code": code} for code in codes], + } + ) + + +def test_record_condition_failure_becomes_fields_changed() -> None: + error = _cancelled("ConditionalCheckFailed", "None") + with pytest.raises(Conflict) as raised: + raise_if_record_changed(error, table="accounts", record_id=_ACCOUNT) + assert raised.value.reason == "fields_changed" + assert raised.value.__cause__ is error + + +@pytest.mark.parametrize( + "error", + [ + _wrapped({"Error": {"Code": "IdempotentParameterMismatchException", "Message": "x"}}), + _cancelled("None", "TransactionConflict"), + _cancelled("TransactionConflict", "None"), + _cancelled("None", "ConditionalCheckFailed"), + Conflict("no AWS cause"), + ], + ids=["idempotency-mismatch", "audit-conflict", "record-conflict", "audit-condition", "bare"], +) +def test_other_conflicts_are_left_for_the_caller_to_reraise(error: Conflict) -> None: + raise_if_record_changed(error, table="accounts", record_id=_ACCOUNT) + assert error.reason is None + + +@pytest.mark.parametrize("updated_at", [_READ_UPDATED_AT, None], ids=["stamped", "unstamped"]) +def test_log_activity_losing_the_race_on_its_opportunity_is_a_fields_changed_conflict( + store: Store, client: Any, monkeypatch: pytest.MonkeyPatch, updated_at: str | None +) -> None: + _seed(store, updated_at=updated_at) + opportunity = next(case for case in _CASES if case.table == "opportunities") + _interpose(store, monkeypatch, opportunity, _approve_style_update(client, opportunity)) + identity = { + "rep_id": "rep-1", + "book": [_ACCOUNT], + "full_visibility": False, + "principal_type": "user", + "session_id": "sess-1", + "source": "gateway", + "tenant": _TENANT, + } + event = identity_event( + IDENTITY_KEY, + identity, + { + "opportunity_id": "opp-1", + "kind": "call", + "subject": "Checked in", + "occurred_at": "2024-05-01T00:00:00+00:00", + "transaction_key": "tx-log-race", + }, + ) + + result = log_activity.handler(event, store=store) + + assert result["statusCode"] == 409 + assert result["error"]["reason"] == "fields_changed" + persisted = Store(client=client).get_item("opportunities", {"opportunity_id": "opp-1"}) + assert persisted is not None + assert persisted["approved_marker"] == "approved" + assert persisted.get("last_touch") is None + activities = client.scan(TableName="activities")["Items"] + assert [item["activity_id"]["S"] for item in activities] == ["act-1"] + assert _audit_rows(client, "opp-1") == [] + + +def test_operation_index_selects_which_operation_s_condition_counts() -> None: + second = _cancelled("None", "ConditionalCheckFailed") + with pytest.raises(Conflict) as raised: + raise_if_record_changed(second, table="opportunities", record_id="opp-1", operation_index=1) + assert raised.value.reason == "fields_changed" + raise_if_record_changed(second, table="opportunities", record_id="opp-1") + + first = _cancelled("ConditionalCheckFailed", "None") + raise_if_record_changed(first, table="opportunities", record_id="opp-1", operation_index=1) + with pytest.raises(Conflict): + raise_if_record_changed(first, table="opportunities", record_id="opp-1")