Skip to content

feat(infra): prod Pod Identity, ESO and the §9 secrets envs/prod never had - #895

Merged
athvin merged 1 commit into
mainfrom
worktree-prod-substrate
Nov 8, 2026
Merged

athvin merged 1 commit into
mainfrom
worktree-prod-substrate

Conversation

@athvin

@athvin athvin commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

Closes #894

Post-merge is part of this pull request. The ledger below records whether
the follow-up work actually happened. /land-pr closes it.

What

The ESO stack, the two Pod Identity roles and the two §9 Secrets Manager entries that envs/prod/ never had. Plus the lake_access policy document lake.tf has referred to since October without defining.

Why

#553–#556 all assume a prod substrate that does not exist. Without this, the er-platform release fails at its first pre-install hook (its two ExternalSecrets resolve against no store) and a pod that did start could not reach the lake — Pod Identity has no node-credential fallback here by design.

Proof

bash scripts/ci/tf-validate-all.sh — all five stacks, including envs/prod, Success! The configuration is valid. bash scripts/ci/tf-static-credentials-check.sh — clean — 1 access key(s), all allowed. terraform fmt -recursive clean. No Rust or frontend files in the diff, so make check's compile tiers are not the gate this change answers to; CI's detect skips them for the same reason.

Not applied. The plan tier will show the real resource count on this PR.

Risk & rollback

Risk: additive to a stack carrying no traffic — the app namespace it names does not exist yet, so the two associations bind to nothing until the deploy path lands. Rollback: git revert <merge-sha>, then an apply; the two Secrets Manager entries survive revert behind their recovery windows and must be deleted by hand if that is wanted.

Post-merge ledger

Closed by: agent · session a7f03c6d-206a-4ae3-a5c3-1c2f74052399 on Mac · 2026-11-08T20:05:00Z

  • main is green with this change on it — merge SHA 9583e470, which is origin/main's head. rust run 42516455716 concluded success with 23 jobs and zero failures; frontend, infra and devcontainer on the same SHA also success. The run sat pending with zero jobs for ~6 minutes first — the merge-burst concurrency signature (four commits in four minutes; the rust runs on 8f4059de and 350cd213 were both cancelled) — so it was watched to a conclusion rather than read while pending.
  • images — n/a — no image inputs changed. The diff is four Terraform files under envs/prod/ plus one generated reference; no images run exists on 9583e470.
  • deploy — n/a — nothing to deploy, and the red run on this SHA is not this change. A deploy run is attributed to 9583e470 and it failed, but DEPLOY_SHA inside it is 350cd21379f73526b9af7a1e383ffde95a424368 (feat(tags): reserved system tags, per-tag permission, tags in export (#805) #875, feat(tags)), and CLUSTER is er-dev. Root cause is feat(tags): reserved system tags, per-tag permission, tags in export (#805) #875's schema change, reported there with the pod log: the reconciler returns verdict: breaking and refuses public.tags: column kind is absent. Nothing in this diff reaches dev's control-plane schema.
  • the push-only surface no pull request can pre-test — infra (the only one this change can affect) is green and apply (prod) ran; deploy is knowingly red for feat(tags): reserved system tags, per-tag permission, tags in export (#805) #875's reason, not this change, per the box above; drift and kind's nightly leg have not fired since the merge and are untouched by a prod-only IAM/secrets diff.
  • the board card reached Done through the automation — Prod substrate: Pod Identity, ESO and the §9 secrets envs/prod never had #894 reads CLOSED / COMPLETED at 2026-11-08T19:43:25Z, two seconds after the merge, and its card reads Done. Not touched by hand.
  • follow-ups are open for everything deferred here — Prod app NodePool, and a per-environment cluster-objects target #906 (prod app NodePool + the per-environment cluster-objects layout, and applying the NetworkPolicy controller to er-prod), ANTHROPIC_API_KEY is empty in er/prod/app/erweb #907 (ANTHROPIC_API_KEY empty in er/prod/app/erweb). The sslmode=verify-full gap is Prod environment — network, EKS, Aurora #553's, where it was already recorded along with the 14-vs-35-day PITR finding.
  • what was learned is written down — the workflow_run attribution trap is recorded in memory (workflow-run-headsha-misattributes-deploy): for a workflow_run-triggered deploy, gh run list's headSha is the head of main when the run fired, not the commit being deployed, so a later merge appears to own an earlier one's broken deploy. It cost a full attribution pass here and would mislead any session landing a PR behind a broken deploy.

Specific to this change

  • apply (prod) actually ran and created the 15 resources — run 42516455727, job apply (prod) success. Verified against AWS rather than the log: er-prod-external-secrets, er-prod-api-pod and er-prod-runner-pod all return ARNs from iam get-role, and eks list-pod-identity-associations --cluster-name er-prod lists app/er-api, app/er-runner and external-secrets/external-secrets.
  • the two Secrets Manager entries exist with the expected key sets — jq keys on each, values never printed:
    er/prod/app/erserver → ERSERVER_DSN, ERSERVER_OPERATOR_TOKEN, ERSERVER_TENANT_ENV_JSON
    er/prod/app/erweb → ANTHROPIC_API_KEY, ERWEB_CREDENTIAL_KEY, ERWEB_DATABASE_URL, ERWEB_SESSION_SECRET
    Both match what scripts/dev_env.sh writes for dev, which is the chart's dataFrom.extract contract.
  • ANTHROPIC_API_KEY is filled in — deferred — #907. Terraform writes it empty on purpose and ignore_changes keeps it that way; the features degrade rather than crash, so this does not gate the bring-up.
  • a follow-up ticket exists for the prod app NodePool — deferred — #906. Confirmed live that it is needed and not merely theoretical: modules/eks/main.tf:109 sets node_pools = ["system"], so Auto Mode's general-purpose pool is not enabled and er-prod has no NodePool at all.
Context — plan, discoveries, measurements, files

Plan

  1. lake.tf — define lake_access, mirroring dev's document (same actions; the environments differ in bucket and CMK, not in what is allowed).
  2. secrets.tf — ESO role scoped to er/prod/*, its association, and the two §9 entries.
  3. pod_identity.tf — the two roles, the lake policy on the runner, associations for the one fixed namespace.
  4. versions.tf — random ~> 3.6 for random_bytes.
  5. Confirm envs/prod is already in all three CI tiers. It is — no hand-written list needed joining.

Discoveries

  • envs/prod/lake.tf's comment described a role that did not exist. "prod reaches S3 via EKS Pod Identity (an IAM role), wired with the app deploy" has been in the tree since 2026-10-15, and neither the role nor the lake_access document it attaches was ever written. Prod lake + scoped CloudTrail #554's body repeats the claim as fact.
  • The eks module enables only Auto Mode's system node pool (node_pools = ["system"]), not general-purpose. So prod has no pool that app pods can land on, and the custom app pool is required rather than an optimisation. Split out, because make cluster-objects is hardcoded to ER_DEV_CONTEXT and the non-recursive apply that keeps measure/ out of the cluster makes the per-environment nodepool layout its own decision.
  • rds.tf already writes ERSERVER_DSN with sslmode=require. Prod environment — network, EKS, Aurora #553's probe wants verify-full, which needs the RDS CA bundle in the images first. The DSNs here match what is already there rather than introducing a second convention; Prod environment — network, EKS, Aurora #553 moves both.
  • Dev's ESO role allows er/*, not er/dev/*. Copying it would have let the prod operator read developer namespaces and vice versa. Prod's is narrowed; dev's is left alone (the leak direction that matters is a dev cluster reading prod, not the reverse, and changing dev's is not this PR's business).

Measurements

$ bash scripts/ci/tf-validate-all.sh | tail -1
Success! The configuration is valid.

$ bash scripts/ci/tf-static-credentials-check.sh
tf-static-credentials: aws_iam_access_key "builder" — allowed
tf-static-credentials: clean — 1 access key(s), all allowed; no static ER_S3_* assignment

Files

  • infra/terraform/envs/prod/secrets.tf (new) — ESO role + association, er/prod/app/{erserver,erweb}
  • infra/terraform/envs/prod/pod_identity.tf (new) — er-prod-api-pod, er-prod-runner-pod, associations
  • infra/terraform/envs/prod/lake.tf — the lake_access document
  • infra/terraform/envs/prod/versions.tf — random ~> 3.6

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

terraform plan

99b2b91 · run log and full plans

env add change destroy
state-backend (plan only) 0 0 0
core 0 0 0
dev 0 0 0
prod 15 0 0

Planned with -refresh=false, so this is the config-versus-state diff and
not out-of-band drift. That is a security choice, not a speed one: a refreshing
plan reads secret values, and the plan role is assumable from any PR branch —
which can edit the workflow it runs under. Drift is caught at apply time, which
refreshes fully.

prod — 15 to add, 0 to change
module.network.data.aws_availability_zones.available: Reading...
module.network.data.aws_region.current: Reading...
data.aws_caller_identity.current: Reading...
data.aws_iam_policy_document.eso_trust: Reading...
data.aws_iam_policy_document.eso_trust: Read complete after 0s [id=819195744]
module.network.data.aws_region.current: Read complete after 0s [id=us-east-2]
data.aws_iam_policy_document.pod_trust: Reading...
data.aws_rds_engine_version.aurora_pg: Reading...
data.aws_iam_policy_document.pod_trust: Read complete after 0s [id=819195744]
data.aws_iam_policy_document.efs_csi_trust: Reading...
module.eks.data.aws_iam_policy_document.node_trust: Reading...
module.eks.data.aws_iam_policy_document.cluster_trust: Reading...
module.eks.data.aws_iam_policy_document.cluster_trust: Read complete after 0s [id=1029077455]
module.eks.data.aws_iam_policy_document.node_trust: Read complete after 0s [id=2851119427]
data.aws_iam_policy_document.efs_csi_trust: Read complete after 0s [id=819195744]
module.lake.data.aws_iam_policy_document.lake_tls_only: Reading...
module.lake.data.aws_iam_policy_document.lake_tls_only: Read complete after 0s [id=3960055703]
data.aws_iam_policy_document.lake_access: Reading...
data.aws_iam_policy_document.lake_access: Read complete after 0s [id=3734071059]
data.aws_caller_identity.current: Read complete after 0s [id=797781631727]
data.aws_iam_policy_document.eso: Reading...
data.aws_iam_policy_document.eso: Read complete after 0s [id=2178872705]
module.network.data.aws_availability_zones.available: Read complete after 1s [id=us-east-2]
data.aws_rds_engine_version.aurora_pg: Read complete after 1s [id=17.9]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # aws_eks_pod_identity_association.er_api will be created
  + resource "aws_eks_pod_identity_association" "er_api" {
      + association_arn      = (known after apply)
      + association_id       = (known after apply)
      + cluster_name         = "er-prod"
      + disable_session_tags = false
      + external_id          = (known after apply)
      + id                   = (known after apply)
      + namespace            = "app"
      + region               = "us-east-2"
      + role_arn             = (known after apply)
      + service_account      = "er-api"
      + tags_all             = {
          + "Environment" = "prod"
          + "ManagedBy"   = "terraform"
          + "Project"     = "entity-resolution"
        }
    }

  # aws_eks_pod_identity_association.er_runner will be created
  + resource "aws_eks_pod_identity_association" "er_runner" {
      + association_arn      = (known after apply)
      + association_id       = (known after apply)
      + cluster_name         = "er-prod"
      + disable_session_tags = false
      + external_id          = (known after apply)
      + id                   = (known after apply)
      + namespace            = "app"
      + region               = "us-east-2"
      + role_arn             = (known after apply)
      + service_account      = "er-runner"
      + tags_all             = {
          + "Environment" = "prod"
          + "ManagedBy"   = "terraform"
          + "Project"     = "entity-resolution"
        }
    }

  # aws_eks_pod_identity_association.eso will be created
  + resource "aws_eks_pod_identity_association" "eso" {
      + association_arn      = (known after apply)
      + association_id       = (known after apply)
      + cluster_name         = "er-prod"
      + disable_session_tags = false
      + external_id          = (known after apply)
      + id                   = (known after apply)
      + namespace            = "external-secrets"
      + region               = "us-east-2"
      + role_arn             = (known after apply)
      + service_account      = "external-secrets"
      + tags_all             = {
          + "Environment" = "prod"
          + "ManagedBy"   = "terraform"
          + "Project"     = "entity-resolution"
        }
    }

  # aws_iam_role.er_api_pod will be created
  + resource "aws_iam_role" "er_api_pod" {
      + arn                   = (known after apply)
      + assume_role_policy    = jsonencode(
            {
              + Statement = [
                  + {
                      + Action    = [
                          + "sts:TagSession",
                          + "sts:AssumeRole",
                        ]
                      + Effect    = "Allow"
                      + Principal = {
                          + Service = "pods.eks.amazonaws.com"
                        }
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
      + create_date           = (known after apply)
      + force_detach_policies = false
      + id                    = (known after apply)
      + managed_policy_arns   = (known after apply)
      + max_session_duration  = 3600
      + name                  = "er-prod-api-pod"
      + name_prefix           = (known after apply)
      + path                  = "/"
      + tags                  = {
          + "Name" = "er-prod-api-pod"
        }
      + tags_all              = {
          + "Environment" = "prod"
          + "ManagedBy"   = "terraform"
          + "Name"        = "er-prod-api-pod"
          + "Project"     = "entity-resolution"
        }
      + unique_id             = (known after apply)

      + inline_policy (known after apply)
    }

  # aws_iam_role.er_runner_pod will be created
  + resource "aws_iam_role" "er_runner_pod" {
      + arn                   = (known after apply)
      + assume_role_policy    = jsonencode(
            {
              + Statement = [
                  + {
                      + Action    = [
                          + "sts:TagSession",
                          + "sts:AssumeRole",
                        ]
                      + Effect    = "Allow"
                      + Principal = {
                          + Service = "pods.eks.amazonaws.com"
                        }
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
      + create_date           = (known after apply)
      + force_detach_policies = false
      + id                    = (known after apply)
      + managed_policy_arns   = (known after apply)
      + max_session_duration  = 3600
      + name                  = "er-prod-runner-pod"
      + name_prefix           = (known after apply)
      + path                  = "/"
      + tags                  = {
          + "Name" = "er-prod-runner-pod"
        }
      + tags_all              = {
          + "Environment" = "prod"
          + "ManagedBy"   = "terraform"
          + "Name"        = "er-prod-runner-pod"
          + "Project"     = "entity-resolution"
        }
      + unique_id             = (known after apply)

      + inline_policy (known after apply)
    }

  # aws_iam_role.eso will be created
  + resource "aws_iam_role" "eso" {
      + arn                   = (known after apply)
      + assume_role_policy    = jsonencode(
            {
              + Statement = [
                  + {
                      + Action    = [
                          + "sts:TagSession",
                          + "sts:AssumeRole",
                        ]
                      + Effect    = "Allow"
                      + Principal = {
                          + Service = "pods.eks.amazonaws.com"
                        }
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
      + create_date           = (known after apply)
      + force_detach_policies = false
      + id                    = (known after apply)
      + managed_policy_arns   = (known after apply)
      + max_session_duration  = 3600
      + name                  = "er-prod-external-secrets"
      + name_prefix           = (known after apply)
      + path                  = "/"
      + tags_all              = {
          + "Environment" = "prod"
          + "ManagedBy"   = "terraform"
          + "Project"     = "entity-resolution"
        }
      + unique_id             = (known after apply)

      + inline_policy (known after apply)
    }

  # aws_iam_role_policy.er_runner_lake will be created
  + resource "aws_iam_role_policy" "er_runner_lake" {
      + id          = (known after apply)
      + name        = "er-prod-runner-lake"
      + name_prefix = (known after apply)
      + policy      = jsonencode(
            {
              + Statement = [
                  + {
                      + Action   = [
                          + "s3:PutObject",
                          + "s3:ListMultipartUploadParts",
                          + "s3:GetObject",
                          + "s3:DeleteObject",
                          + "s3:AbortMultipartUpload",
                        ]
                      + Effect   = "Allow"
                      + Resource = "arn:aws:s3:::er-prod-lake-797781631727/*"
                      + Sid      = "LakeObjects"
                    },
                  + {
                      + Action   = [
                          + "s3:ListBucketMultipartUploads",
                          + "s3:ListBucket",
                          + "s3:GetBucketLocation",
                        ]
                      + Effect   = "Allow"
                      + Resource = "arn:aws:s3:::er-prod-lake-797781631727"
                      + Sid      = "LakeList"
                    },
                  + {
                      + Action   = [
                          + "kms:GenerateDataKey*",
                          + "kms:Decrypt",
                        ]
                      + Effect   = "Allow"
                      + Resource = "arn:aws:kms:us-east-2:797781631727:key/aac8b63d-fd14-4c13-896e-ceaa41dcf0ce"
                      + Sid      = "LakeKey"
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
      + role        = (known after apply)
    }

  # aws_iam_role_policy.eso will be created
  + resource "aws_iam_role_policy" "eso" {
      + id          = (known after apply)
      + name        = "read-prod-secrets"
      + name_prefix = (known after apply)
      + policy      = jsonencode(
            {
              + Statement = [
                  + {
                      + Action   = [
                          + "secretsmanager:ListSecretVersionIds",
                          + "secretsmanager:GetSecretValue",
                          + "secretsmanager:DescribeSecret",
                        ]
                      + Effect   = "Allow"
                      + Resource = "arn:aws:secretsmanager:us-east-2:797781631727:secret:er/prod/*"
                      + Sid      = "ReadProdSecrets"
                    },
                  + {
                      + Action   = [
                          + "secretsmanager:ListSecrets",
                          + "secretsmanager:BatchGetSecretValue",
                        ]
                      + Effect   = "Allow"
                      + Resource = "*"
                      + Sid      = "ListForDiscovery"
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
      + role        = (known after apply)
    }

  # aws_secretsmanager_secret.erserver will be created
  + resource "aws_secretsmanager_secret" "erserver" {
      + arn                            = (known after apply)
      + description                    = "Prod control-plane env (er-server): DSN, operator token, tenant env template."
      + force_overwrite_replica_secret = false
      + id                             = (known after apply)
      + name                           = "er/prod/app/erserver"
      + name_prefix                    = (known after apply)
      + policy                         = (known after apply)
      + recovery_window_in_days        = 30
      + region                         = "us-east-2"
      + tags_all                       = {
          + "Environment" = "prod"
          + "ManagedBy"   = "terraform"
          + "Project"     = "entity-resolution"
        }
    }

  # aws_secretsmanager_secret.erweb will be created
  + resource "aws_secretsmanager_secret" "erweb" {
      + arn                            = (known after apply)
      + description                    = "Prod BFF env (er-web): database URL, session secret, credential-sealing key."
      + force_overwrite_replica_secret = false
      + id                             = (known after apply)
      + name                           = "er/prod/app/erweb"
      + name_prefix                    = (known after apply)
      + policy                         = (known after apply)
      + recovery_window_in_days        = 30
      + region                         = "us-east-2"
      + tags_all                       = {
          + "Environment" = "prod"
          + "ManagedBy"   = "terraform"
          + "Project"     = "entity-resolution"
        }
    }

  # aws_secretsmanager_secret_version.erserver will be created
  + resource "aws_secretsmanager_secret_version" "erserver" {
      + arn                  = (known after apply)
      + has_secret_string_wo = (known after apply)
      + id                   = (known after apply)
      + region               = "us-east-2"
      + secret_arn           = (known after apply)
      + secret_id            = (known after apply)
      + secret_string        = (sensitive value)
      + secret_string_wo     = (write-only attribute)
      + version_id           = (known after apply)
      + version_stages       = (known after apply)
    }

  # aws_secretsmanager_secret_version.erweb will be created
  + resource "aws_secretsmanager_secret_version" "erweb" {
      + arn                  = (known after apply)
      + has_secret_string_wo = (known after apply)
      + id                   = (known after apply)
      + region               = "us-east-2"
      + secret_arn           = (known after apply)
      + secret_id            = (known after apply)
      + secret_string        = (sensitive value)
      + secret_string_wo     = (write-only attribute)
      + version_id           = (known after apply)
      + version_stages       = (known after apply)
    }

  # random_bytes.operator_token will be created
  + resource "random_bytes" "operator_token" {
      + base64 = (sensitive value)
      + hex    = (sensitive value)
      + length = 32
    }

  # random_bytes.web_credential_key will be created
  + resource "random_bytes" "web_credential_key" {
      + base64 = (sensitive value)
      + hex    = (sensitive value)
      + length = 32
    }

  # random_bytes.web_session_secret will be created
  + resource "random_bytes" "web_session_secret" {
      + base64 = (sensitive value)
      + hex    = (sensitive value)
      + length = 32
    }

Plan: 15 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + app_namespace          = "app"
  + er_api_pod_role_arn    = (known after apply)
  + er_runner_pod_role_arn = (known after apply)
  + eso_role_arn           = (known after apply)

…r had (#894)

`envs/prod/` declared the network, EKS, Aurora, EFS and the lake, and none of
the identity or secret plumbing a pod needs to start. #553-#556 all assume this
substrate exists.

- `secrets.tf`: the ESO role and its Pod Identity association, plus the two
  §9 Secrets Manager entries. Scoped to `er/prod/*` where dev's role allows
  `er/*` — dev's breadth is harmless in the direction that matters, but it is
  the wrong default to copy into the environment holding the real credentials.
  The entries are Terraform's here because prod has no `dev_env.sh`; the key
  lists are the chart's contract, since `externalsecrets.yaml` uses
  `dataFrom.extract` and a renamed key fails as a missing env var at pod start
  rather than at apply.
- `pod_identity.tf`: `er-prod-api-pod` and `er-prod-runner-pod` with
  associations for the one fixed prod namespace. `er-api` carries no policy
  yet and that is the correct state — its two dev capabilities are SES send
  and Bedrock invoke, and prod has neither. The association is the part that
  must exist before a pod starts.
- `lake.tf`: the `lake_access` document. The file's own comment has promised a
  role "wired with the app deploy" since October; that role is now written and
  this is what it attaches.

The namespace is `app`, not `prod`: the chart turns it into the `developer`
value which lands in the secret path, so `prod` would read back as
`er/prod/prod/erserver` — the objection `ci-deploy.tf` already raised against
naming dev's CI namespace `dev`.

`random_bytes` rather than `random_password` for the two values whose encoding
is load-bearing. `ERWEB_CREDENTIAL_KEY` must be 32 raw bytes base64-encoded —
base64-encoding a 32-character password decodes to 32 bytes and so passes
`frontend/src/lib/env.ts`'s check while carrying ~6 bits per byte instead of 8.

The `erweb` entry is `ignore_changes = [secret_string]` and has a 30-day
recovery window: its credential key unseals `erweb.org_credentials`, so an
apply that re-rendered the value would orphan every sealed org credential.

envs/prod is already in all three CI tiers (`tf-validate-all.sh`, and the plan
and apply matrices), so no hand-written list needed joining.

`footprint.md`'s generated block moves with it — +3 IAM roles, +2 role
policies, +3 Pod Identity associations, +2 secrets and versions, and the
`~> 3.6` random pin. The drift check compares against `git show HEAD:<f>`
(skills-check.sh:2765), so a regenerated-but-uncommitted block still fails it.

Closes #894

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@athvin
athvin force-pushed the worktree-prod-substrate branch from 1c690ab to 625ed4a Compare November 8, 2026 19:40
@athvin
athvin merged commit 9583e47 into main Nov 8, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prod substrate: Pod Identity, ESO and the §9 secrets envs/prod never had

2 participants