Skip to content

feat(infra): isolate runner lake access by tenant (#550) - #1027

Merged
athvin merged 7 commits into
mainfrom
issue/550-tenant-runner-identity
Nov 9, 2026
Merged

athvin merged 7 commits into
mainfrom
issue/550-tenant-runner-identity

Conversation

@athvin

@athvin athvin commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Closes #550

Claimed by agent — 2026-11-09T05:48:57.592565+00:00, session Codex:01a1be1b-0c92-7703-a4c2-25cb2c999baa on Mac. This open draft PR is the claim; closing it releases the ticket.

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

What

Give each enrolled org a distinct runner ServiceAccount and prefix-scoped Pod Identity role, driven by one Terraform/Helm registry. The executor selects it from the claimed task org; the shared fallback loses lake object access.

Why

The shared runner role currently permits access across the lake bucket. Tenant A must receive AccessDenied when explicitly handed tenant B’s prefix.

Proof

Full local make check passed after incorporating the CI-tool changes. Full Rust CI 42594625315 passed every product gate. Later frontend-only rebases and one empty dispatch-recovery commit left the six topic patches unchanged; final head d24cf752 satisfied all 15 required contexts with no failed detect or pending run, including Rust 42596948629 and infra 42596948627.

Real Postgres/DuckLake tests, six Terraform policy tests, 49 helper tests, Helm/schema checks and adversarial probe tests pass. Dev/prod each plan +6/~1/-0; core/state-backend unchanged. Merged as c892d9ea at 09:59:07 UTC; application and live acceptance are being verified in the ledger below.

Risk & rollback

Unenrolled orgs retain local/EFS execution with no S3 object permissions. Enrollment must match provisioning’s data prefix. CI owns IAM application and the bounded fixture probe. Both fixed synthetic marker keys remain per environment; overwritten versions follow the bucket lifecycle. No live AWS success is claimed yet. Revert the merge to restore the prior shared identity behavior.

Post-merge ledger

Closed by: Codex · session 01a1be1a-66a7-72f3-8e78-32c20c5e0da9 on Mac-87.lan · 2026-11-10T18:58:47.558166+00:00 — final dev/prod live-boundary follow-up resolved through #1079.

Specific to this change

  • Independent fallback IAM policy readback — production-readiness audit 2026-11-09 used er-readonly to read both er-prod-runner-lake and er-dev-runner-lake. Each shared fallback role now grants only s3:GetBucketLocation on its own lake bucket; neither grants object access. The earlier local read blockage is resolved.

  • Terraform applied the reviewed tenant associations/prefix policies and fallback narrowing in both environments — main infra run 42610044722 at descendant 3c09bbc2, all core/dev/prod apply jobs successful. The exact merge rerun 42597514286 remains stuck in GitHub rerun scheduling; the later applied main includes Per-tenant runner ServiceAccounts #550.

  • Registry enrollment and two tenant ServiceAccounts without runner RBAC verified in both environments by runner-isolation run 42611149254; both dispatchers successfully rolled out before the probe.

  • Live S3 boundary — runner isolation 42880252276 passed dev and prod on 2354ff96 at 2026-11-10T18:57Z after fix(infra): repair development OpenAPI schema serialization (#1058) #1079 repaired the development metrics-server schema. Both fixture tenants in each environment passed own-prefix put/get/list and all cross-prefix put/get/list/delete plus bucket-root-list denials. Jobs and ConfigMaps were cleaned up. Strict validation and all acceptance assertions were unchanged.

Context — plan, discoveries, measurements, files

Plan

  • Audit the runner template, executor tenant identity, provisioning prefixes, Pod Identity associations and existing S3 grants. Preserve the no-Kubernetes-RBAC runner boundary and Terraform-only AWS ownership.
  • Define one reviewed tenant-runner registry consumed by Terraform and deployment/chart configuration. Bind each enrolled org to a distinct ServiceAccount and prefix-scoped Pod Identity role, with trust pinned to its cluster/namespace/account triple. Remove broad S3 object access from the shared fallback runner identity; unenrolled orgs must never inherit another tenant's AWS access.
  • Select the runner identity from the authoritative task org, not caller-supplied job parameters. Keep local/kind execution usable without AWS and prove tenant selection and malformed configuration behavior in the existing executor/manifest harnesses.
  • Test generated IAM policy boundaries (own-prefix positive controls, cross-prefix/root/wildcard denial), chart account/config consistency and the existing deployment helpers. Run Terraform fmt/credential-free validation, Helm checks, make check and the real Postgres/DuckLake tier where executor behavior changes.
  • Add and locally validate the bounded main-only acceptance workflow: both own-prefix controls finish before cross-prefix checks, using the deployed tenant ServiceAccounts. Terraform/CI own resource mutations.
  • Update routed design/runbook references and complete fresh-context instrumentation, tier and reuse reviews plus independent probe verification.
  • Obtain all required exact-head CI greens, land through land-pr, verify dev/prod application and actual AccessDenied results, and close the post-merge ledger — completed with the final live acceptance run 42880252276 after fix(infra): repair development OpenAPI schema serialization (#1058) #1079.

Selection: #521/#518 depend on the public API/configuration work still in Todo; #516 retains peer-owned #803; #514 depends on #511/shared contracts and its remaining children are Todo. #550 is the first eligible unclaimed P1 item. PR #1019 is merged, deployed and verified; its ledger is closed.

Files expected: infra/terraform shared runner-identity module and dev/prod wiring; shared tenant-runner configuration; er-platform ServiceAccounts/task template/dispatcher config; er-server executor and existing tests; scripts/ci deployment/probe helpers and workflow; infra-platform/AWS operations/engine references as needed.

Discoveries

The original live-probe cleanup could produce a false positive: a faster pod removed its own marker before its partner’s GetObject. AWS returns AccessDenied for a missing object without ListBucket permission (GetObject API). The final probe completes both prepare Jobs before either verify Job and retains both fixed markers. An independent verifier reproduced old 7b450db passing despite a foreign GetObject grant, then confirmed both fixed probes reject it; correct-policy probes pass, and markers survive success/failure. The verification used a temporary simulated S3 store, not live AWS. Fresh reuse review found no candidates. Eight Job manifests validate, the probe fault suite passes, and make skills-check passes. These probe changes are carried unchanged in final head 1aa15727; live AWS acceptance remains pending.

The issue’s statement that Rust cannot open an S3 lake is also stale: #792 added ObjectStoreConfig and the credential-chain attach path, confirmed in dedupe-core and the er-cli/tests/s3_lake.rs regression. S3-backed orgs must be enrolled with their actual data prefix before using the restricted roles. Local/EFS orgs need no enrollment. The live probe proves the AWS boundary using synthetic fixture orgs; it does not claim to migrate customer lakes.

The issue's interim-service-user description is stale: that user has been retired, but the shared er-dev-runner-pod / er-prod-runner-pod roles still grant the entire lake bucket. Before this change, the chart hardcoded er-runner and the typed manifest substitution had no tenant identity field. Provisioning already derives an org prefix and dataset sub-prefixes. The scope here is org/tenant S3 isolation; dataset isolation remains a separate lake boundary.

AWS documentation confirms Pod Identity session tags include cluster ARN, namespace and ServiceAccount; account names alone are not globally unique. Source: https://docs.aws.amazon.com/eks/latest/best-practices/identity-and-access-management.html . No new IAM credential provider or IRSA path is needed.

Measurements

Merged final head d24cf752 as c892d9ea5c89b342aadc64f4f27b8f55b7265513 at 09:59:07 UTC. All 15 required contexts satisfied, no failed detect, no unfinished workflow and no active merge bus; final base c47822d3 was included. Post-merge watch/apply/deployment/live acceptance now run through the open ledger. The earlier download/dispatch incidents below are historical, not current blockers.

Final base refresh includes peer sign-in fix c47822d3. The six topic patches remain byte-for-byte equivalent. GitHub recorded force-push head dc378582 but created zero Actions runs/check suites for more than three minutes; workflows remained active and the PR was mergeable. An empty commit d24cf75225fd4bda48849b5ae1a29d22f4996e30 retriggers synchronization without changing the tree. Await exact-head checks before merge. Previous refreshed head e2c3ffe3 passed Rust 42595846055 and infra 42595846162; its base difference is only the independent sign-in frontend files.

Fresh head f9b9f8c6: infra 42594625351 succeeds on its initial run. Both dev/prod plans remain +6/~1/-0, core/state-backend unchanged; chart and helper gates pass. Actionlint passes in Rust 42594625315, whose remaining test groups are still running with no failures. The prior download blockers have recovered; no renewed failed-job rerun has been needed.

Resumed at the user’s “keep going” instruction on 2026-11-09 at 09:27 UTC. The earlier retry stop is historical: work is authorized to continue with a fresh bounded retry cycle. main now includes the cached, checksum-verified tool installer with bounded curl retries (#1031), an observability deployment fix, and marketing/docs work. The branch rebases cleanly onto 8c9111b0b07afc018ae2c56d6137456ca2a07719 as f9b9f8c63420d59db7b1b9c520e56360dab3c04f; range-diff confirms all six topic patches unchanged. Full make check passed on the combined tree (/tmp/tenant-runner-make-check-ci-base.log); f9b9f8c6 is pushed and fresh CI is pending. Local provider checksum/signature and actionlint GETs now return HTTP 200; fresh CI still must prove runner recovery.

Prior blocked head: 1aa157277220b200d65b6579427168a378c4d483, based on ef9ab24f32005d746fb3a52acdc07722dceb7f69. The rebase incorporates only the upstream offline-kubectl hook fix; range-diff confirms all six topic patches unchanged. The working tree is clean.

Evidence Result
Rust 42581312136, attempt 3 Every product gate passes, including the workspace-test shard and all DuckLake/Postgres groups. Only workflow pins (S9) fails, before linting, downloading actionlint with HTTP 504. Both ordinary failed-job retries consumed.
Infra 42581312002, attempt 3 Helm lint/render/schema/selectors, tenant enrollment and probe fault tests pass. Credential-free Terraform validation fails downloading the Cloudflare provider signature with HTTP 504. Both user-authorized extra failed-job retries consumed.
Earlier infra 42579589823, attempts 1–3 Same provider-download failure; consumed the two ordinary infrastructure retries before the hook-only rebase. The new head’s initial run is not counted as a failed-job retry.
Frontend 42581312060; devcontainer 42581311958 Success on the final head.
Local make check Passed again after the final rebase; /tmp/tenant-runner-make-check-hook-base.log.
Local make check-e2e Real Postgres/DuckLake tier passed before the hook-only rebase; /tmp/tenant-runner-e2e-rebased.log. No product source changed in that rebase.
Earlier reviewed Terraform plan, 42573551067 Dev/prod each +6/~1/-0; state-backend/core unchanged. No destroy or replacement. Final module configuration is unchanged from this plan.
Focused local gates Every Terraform stack validates; six module tests, 49 helper tests, eight final Job manifests, probe fault/live-input tests, actionlint and skills-check pass.

The download failures are external to the assertions, not evidence that the skipped checks passed. Local downloads returned HTTP 200 while CI runners still received 504, so local recovery is insufficient. Existing #849 tracks download resilience. Those earlier allowances were exhausted before the user resumed work; see the current status above. No merge, apply, deployment or live S3 acceptance has occurred.

Fresh-context instrumentation, tier and reuse reviews passed on 5e74b3cd/cd4ddd50; subsequent live-enrollment and probe-ordering deltas received fresh reuse reviews. A separate adversarial verifier reproduced the old probe’s missing-marker false positive and confirmed the final two-phase probe rejects broad foreign GetObject permissions. No SQL review dimension was routed because no SQL/entity declaration changed.

The submitted-manifest regression pg_run_all_dag::lake_maintain_runs_end_to_end_through_the_executor passes against real Postgres with spoofed org/ServiceAccount parameters. Identity-selection, wildcard-IAM and missing-enrollment regressions were each observed failing before restoring green. Evidence: /tmp/tenant-runner-identity-red.log, /tmp/tenant-runner-iam-red.log, /tmp/tenant-runner-chart-red.log.

Read-only IAM baselines confirm the current shared roles still grant bucket-wide object/list and KMS access. /tmp/tenant-runner-live-expected.json records expected tenant identities. The local guard rejected kubectl reads; the main-only workflow therefore checks actual rolled-out ServiceAccounts, dispatcher enrollment and absence of runner RBAC before its S3 probes. Fixed synthetic markers are deliberately retained; Jobs and ConfigMaps are cleaned up.

Files

infra/terraform/modules/tenant-runner, dev/prod identity wiring, the shared Helm registry/accounts/dispatcher config, the executor and its existing harnesses, the main-only isolation workflow/checkers, and routed infrastructure/security references.

Pending apply recovery

The reviewed #1046 infrastructure plan on head 9295aa3df41920831a0a36113e41c8f8e57772ae includes these still-unapplied tenant roles, Pod Identity associations and fallback-policy narrowing: dev 11 additions/1 change/0 destroys (including its five new observability resources), prod 6 additions/1 change/0 destroys. Infra run 42603861421 succeeded. After #1046 lands and its main apply succeeds, run the existing runner-isolation acceptance workflow; neither the plan nor the earlier successful app deployment establishes live IAM isolation. The original infra rerun 42597514286 remains an Actions queue failure, not successful application.

@athvin
athvin force-pushed the issue/550-tenant-runner-identity branch from 14b9c21 to 786318e Compare November 9, 2026 06:31
@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

terraform plan

c892d9e · run log and full plans

env add change destroy
state-backend (plan only) 0 0 0
core 0 0 0
dev 6 1 0
prod 6 1 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.

dev — 6 to add, 1 to change
data.aws_iam_policy_document.eso: Reading...
data.aws_caller_identity.current: Reading...
module.network.data.aws_availability_zones.available: Reading...
data.aws_rds_engine_version.aurora_pg: Reading...
data.aws_iam_policy_document.eso_trust: Reading...
data.aws_iam_policy_document.eso: Read complete after 0s [id=1725605485]
data.aws_iam_policy_document.eso_trust: Read complete after 0s [id=819195744]
module.eks.data.aws_iam_policy_document.node_trust: Reading...
data.aws_iam_policy_document.er_api_pod_trust: Reading...
module.network.data.aws_region.current: Reading...
module.eks.data.aws_iam_policy_document.cluster_trust: Reading...
data.aws_iam_policy_document.obs_pod_trust: Reading...
module.eks.data.aws_iam_policy_document.cluster_trust: Read complete after 0s [id=1029077455]
module.network.data.aws_region.current: Read complete after 0s [id=us-east-2]
module.eks.data.aws_iam_policy_document.node_trust: Read complete after 0s [id=2851119427]
data.aws_iam_policy_document.er_api_pod_trust: Read complete after 0s [id=819195744]
data.aws_iam_policy_document.obs_pod_trust: Read complete after 0s [id=819195744]
data.aws_iam_policy_document.efs_csi_trust: Reading...
data.aws_iam_openid_connect_provider.github: Reading...
data.aws_caller_identity.current: Read complete after 0s [id=797781631727]
data.aws_iam_policy_document.efs_csi_trust: Read complete after 0s [id=819195744]
data.aws_region.current: Reading...
data.aws_region.current: Read complete after 0s [id=us-east-2]
data.aws_iam_policy_document.otel_collector: Reading...
data.aws_iam_policy_document.fluent_bit: Reading...
data.aws_iam_policy_document.fluent_bit: Read complete after 0s [id=4006586444]
data.aws_iam_policy_document.otel_collector: Read complete after 0s [id=3111493560]
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=2205495074]
data.aws_iam_policy_document.bedrock_invoke: Reading...
data.aws_iam_policy_document.bedrock_invoke: Read complete after 0s [id=3601248236]
data.aws_iam_policy_document.lake_access: Reading...
data.aws_iam_policy_document.lake_access: Read complete after 0s [id=2921565705]
data.aws_iam_openid_connect_provider.github: Read complete after 0s [id=arn:aws:iam::797781631727:oidc-provider/token.actions.githubusercontent.com]
data.aws_iam_policy_document.ci_deploy_dev_trust: Reading...
data.aws_iam_policy_document.ci_deploy_dev_trust: Read complete after 0s [id=4060172364]
data.aws_rds_engine_version.aurora_pg: Read complete after 0s [id=17.9]
module.network.data.aws_availability_zones.available: Read complete after 0s [id=us-east-2]
data.aws_iam_policy_document.ci_deploy_dev: Reading...
data.aws_iam_policy_document.ci_deploy_dev: Read complete after 0s [id=1754478413]

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

Terraform will perform the following actions:

  # aws_iam_role_policy.er_runner_lake will be updated in-place
  ~ resource "aws_iam_role_policy" "er_runner_lake" {
        id          = "er-dev-runner-pod:er-dev-runner-lake"
        name        = "er-dev-runner-lake"
      ~ policy      = jsonencode(
          ~ {
              ~ Statement = [
                  ~ {
                      ~ Action   = [
                          - "s3:PutObject",
                          - "s3:ListMultipartUploadParts",
                          - "s3:GetObject",
                          - "s3:DeleteObject",
                          - "s3:AbortMultipartUpload",
                        ] -> "s3:GetBucketLocation"
                      ~ Resource = "arn:aws:s3:::er-dev-lake-797781631727/*" -> "arn:aws:s3:::er-dev-lake-797781631727"
                      ~ Sid      = "LakeObjects" -> "BucketLocationOnly"
                        # (1 unchanged attribute hidden)
                    },
                  - {
                      - Action   = [
                          - "s3:ListBucketMultipartUploads",
                          - "s3:ListBucket",
                          - "s3:GetBucketLocation",
                        ]
                      - Effect   = "Allow"
                      - Resource = "arn:aws:s3:::er-dev-lake-797781631727"
                      - Sid      = "LakeList"
                    },
                  - {
                      - Action   = [
                          - "kms:GenerateDataKey*",
                          - "kms:Decrypt",
                        ]
                      - Effect   = "Allow"
                      - Resource = "arn:aws:kms:us-east-2:797781631727:key/0c226b8f-de72-4f5f-b50b-0cf1391bc325"
                      - Sid      = "LakeKey"
                    },
                ]
                # (1 unchanged attribute hidden)
            }
        )
        # (2 unchanged attributes hidden)
    }

  # module.tenant_runners.aws_eks_pod_identity_association.tenant["ci/isolation-probe-a"] will be created
  + resource "aws_eks_pod_identity_association" "tenant" {
      + association_arn      = (known after apply)
      + association_id       = (known after apply)
      + cluster_name         = "er-dev"
      + disable_session_tags = false
      + external_id          = (known after apply)
      + id                   = (known after apply)
      + namespace            = "ci"
      + region               = "us-east-2"
      + role_arn             = (known after apply)
      + service_account      = "er-runner-93ccc8f077814e800e7a"
      + tags_all             = {
          + "Environment" = "dev"
          + "ManagedBy"   = "terraform"
          + "Project"     = "entity-resolution"
        }
    }

  # module.tenant_runners.aws_eks_pod_identity_association.tenant["ci/isolation-probe-b"] will be created
  + resource "aws_eks_pod_identity_association" "tenant" {
      + association_arn      = (known after apply)
      + association_id       = (known after apply)
      + cluster_name         = "er-dev"
      + disable_session_tags = false
      + external_id          = (known after apply)
      + id                   = (known after apply)
      + namespace            = "ci"
      + region               = "us-east-2"
      + role_arn             = (known after apply)
      + service_account      = "er-runner-c6090ab88ffa4d30bb25"
      + tags_all             = {
          + "Environment" = "dev"
          + "ManagedBy"   = "terraform"
          + "Project"     = "entity-resolution"
        }
    }

  # module.tenant_runners.aws_iam_role.tenant["ci/isolation-probe-a"] will be created
  + resource "aws_iam_role" "tenant" {
      + arn                   = (known after apply)
      + assume_role_policy    = jsonencode(
            {
              + Statement = [
                  + {
                      + Action    = [
                          + "sts:AssumeRole",
                          + "sts:TagSession",
                        ]
                      + Condition = {
                          + StringEquals = {
                              + "aws:RequestTag/eks-cluster-arn"            = "arn:aws:eks:us-east-2:797781631727:cluster/er-dev"
                              + "aws:RequestTag/kubernetes-namespace"       = "ci"
                              + "aws:RequestTag/kubernetes-service-account" = "er-runner-93ccc8f077814e800e7a"
                            }
                        }
                      + 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-dev-runner-cdd932a93c2249b8a621"
      + name_prefix           = (known after apply)
      + path                  = "/"
      + tags_all              = {
          + "Environment" = "dev"
          + "ManagedBy"   = "terraform"
          + "Project"     = "entity-resolution"
        }
      + unique_id             = (known after apply)

      + inline_policy (known after apply)
    }

  # module.tenant_runners.aws_iam_role.tenant["ci/isolation-probe-b"] will be created
  + resource "aws_iam_role" "tenant" {
      + arn                   = (known after apply)
      + assume_role_policy    = jsonencode(
            {
              + Statement = [
                  + {
                      + Action    = [
                          + "sts:AssumeRole",
                          + "sts:TagSession",
                        ]
                      + Condition = {
                          + StringEquals = {
                              + "aws:RequestTag/eks-cluster-arn"            = "arn:aws:eks:us-east-2:797781631727:cluster/er-dev"
                              + "aws:RequestTag/kubernetes-namespace"       = "ci"
                              + "aws:RequestTag/kubernetes-service-account" = "er-runner-c6090ab88ffa4d30bb25"
                            }
                        }
                      + 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-dev-runner-20ada9dc46d46007ab8d"
      + name_prefix           = (known after apply)
      + path                  = "/"
      + tags_all              = {
          + "Environment" = "dev"
          + "ManagedBy"   = "terraform"
          + "Project"     = "entity-resolution"
        }
      + unique_id             = (known after apply)

      + inline_policy (known after apply)
    }

  # module.tenant_runners.aws_iam_role_policy.lake["ci/isolation-probe-a"] will be created
  + resource "aws_iam_role_policy" "lake" {
      + id          = (known after apply)
      + name        = "tenant-lake"
      + name_prefix = (known after apply)
      + policy      = jsonencode(
            {
              + Statement = [
                  + {
                      + Action   = [
                          + "s3:GetObject",
                          + "s3:PutObject",
                          + "s3:DeleteObject",
                          + "s3:AbortMultipartUpload",
                          + "s3:ListMultipartUploadParts",
                        ]
                      + Effect   = "Allow"
                      + Resource = [
                          + "arn:aws:s3:::er-dev-lake-797781631727/_isolation/probe-a/*",
                        ]
                      + Sid      = "TenantObjects"
                    },
                  + {
                      + Action    = [
                          + "s3:ListBucket",
                        ]
                      + Condition = {
                          + StringLike = {
                              + "s3:prefix" = [
                                  + "_isolation/probe-a/*",
                                ]
                            }
                        }
                      + Effect    = "Allow"
                      + Resource  = [
                          + "arn:aws:s3:::er-dev-lake-797781631727",
                        ]
                      + Sid       = "TenantList"
                    },
                  + {
                      + Action   = [
                          + "s3:GetBucketLocation",
                        ]
                      + Effect   = "Allow"
                      + Resource = [
                          + "arn:aws:s3:::er-dev-lake-797781631727",
                        ]
                      + Sid      = "BucketLocation"
                    },
                  + {
                      + Action    = [
                          + "kms:Decrypt",
                          + "kms:GenerateDataKey",
                        ]
                      + Condition = {
                          + StringEquals = {
                              + "kms:EncryptionContext:aws:s3:arn" = "arn:aws:s3:::er-dev-lake-797781631727"
                              + "kms:ViaService"                   = "s3.us-east-2.amazonaws.com"
                            }
                        }
                      + Effect    = "Allow"
                      + Resource  = [
                          + "arn:aws:kms:us-east-2:797781631727:key/0c226b8f-de72-4f5f-b50b-0cf1391bc325",
                        ]
                      + Sid       = "LakeKeyViaS3"
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
      + role        = (known after apply)
    }

  # module.tenant_runners.aws_iam_role_policy.lake["ci/isolation-probe-b"] will be created
  + resource "aws_iam_role_policy" "lake" {
      + id          = (known after apply)
      + name        = "tenant-lake"
      + name_prefix = (known after apply)
      + policy      = jsonencode(
            {
              + Statement = [
                  + {
                      + Action   = [
                          + "s3:GetObject",
                          + "s3:PutObject",
                          + "s3:DeleteObject",
                          + "s3:AbortMultipartUpload",
                          + "s3:ListMultipartUploadParts",
                        ]
                      + Effect   = "Allow"
                      + Resource = [
                          + "arn:aws:s3:::er-dev-lake-797781631727/_isolation/probe-b/*",
                        ]
                      + Sid      = "TenantObjects"
                    },
                  + {
                      + Action    = [
                          + "s3:ListBucket",
                        ]
                      + Condition = {
                          + StringLike = {
                              + "s3:prefix" = [
                                  + "_isolation/probe-b/*",
                                ]
                            }
                        }
                      + Effect    = "Allow"
                      + Resource  = [
                          + "arn:aws:s3:::er-dev-lake-797781631727",
                        ]
                      + Sid       = "TenantList"
                    },
                  + {
                      + Action   = [
                          + "s3:GetBucketLocation",
                        ]
                      + Effect   = "Allow"
                      + Resource = [
                          + "arn:aws:s3:::er-dev-lake-797781631727",
                        ]
                      + Sid      = "BucketLocation"
                    },
                  + {
                      + Action    = [
                          + "kms:Decrypt",
                          + "kms:GenerateDataKey",
                        ]
                      + Condition = {
                          + StringEquals = {
                              + "kms:EncryptionContext:aws:s3:arn" = "arn:aws:s3:::er-dev-lake-797781631727"
                              + "kms:ViaService"                   = "s3.us-east-2.amazonaws.com"
                            }
                        }
                      + Effect    = "Allow"
                      + Resource  = [
                          + "arn:aws:kms:us-east-2:797781631727:key/0c226b8f-de72-4f5f-b50b-0cf1391bc325",
                        ]
                      + Sid       = "LakeKeyViaS3"
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
      + role        = (known after apply)
    }

Plan: 6 to add, 1 to change, 0 to destroy.
prod — 6 to add, 1 to change
data.aws_iam_policy_document.efs_csi_trust: Reading...
data.aws_rds_engine_version.aurora_pg: Reading...
data.aws_iam_policy_document.efs_csi_trust: Read complete after 0s [id=819195744]
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.ses.data.aws_region.current: Reading...
data.aws_iam_openid_connect_provider.github: Reading...
data.aws_iam_policy_document.eso_trust: Reading...
module.ses.data.aws_region.current: Read complete after 0s [id=us-east-2]
module.eks.data.aws_iam_policy_document.node_trust: Reading...
data.aws_iam_policy_document.eso_trust: Read complete after 0s [id=819195744]
data.aws_iam_policy_document.pod_trust: Reading...
module.network.data.aws_region.current: Reading...
module.eks.data.aws_iam_policy_document.node_trust: Read complete after 0s [id=2851119427]
module.network.data.aws_availability_zones.available: Reading...
data.aws_caller_identity.current: Reading...
data.aws_iam_policy_document.pod_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.otel_collector: Reading...
data.aws_iam_policy_document.otel_collector: Read complete after 0s [id=1193716550]
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.fluent_bit: Reading...
data.aws_iam_policy_document.fluent_bit: Read complete after 0s [id=2978074842]
data.aws_iam_policy_document.lake_access: Reading...
data.aws_iam_policy_document.lake_access: Read complete after 0s [id=1033619361]
module.ses.data.aws_iam_policy_document.send: Reading...
data.aws_caller_identity.current: Read complete after 0s [id=797781631727]
module.ses.data.aws_iam_policy_document.send: Read complete after 0s [id=3767633194]
data.aws_iam_policy_document.eso: Reading...
data.aws_iam_policy_document.eso: Read complete after 0s [id=2178872705]
data.aws_rds_engine_version.aurora_pg: Read complete after 0s [id=17.9]
module.network.data.aws_availability_zones.available: Read complete after 0s [id=us-east-2]
data.aws_iam_policy_document.ci_deploy_prod: Reading...
data.aws_iam_policy_document.ci_deploy_prod: Read complete after 0s [id=3634844169]
data.aws_iam_openid_connect_provider.github: Read complete after 0s [id=arn:aws:iam::797781631727:oidc-provider/token.actions.githubusercontent.com]
data.aws_iam_policy_document.ci_deploy_prod_trust: Reading...
data.aws_iam_policy_document.ci_deploy_prod_trust: Read complete after 0s [id=4060172364]

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

Terraform will perform the following actions:

  # aws_iam_role_policy.er_runner_lake will be updated in-place
  ~ resource "aws_iam_role_policy" "er_runner_lake" {
        id          = "er-prod-runner-pod:er-prod-runner-lake"
        name        = "er-prod-runner-lake"
      ~ policy      = jsonencode(
          ~ {
              ~ Statement = [
                  ~ {
                      ~ Action   = [
                          - "s3:PutObject",
                          - "s3:ListMultipartUploadParts",
                          - "s3:GetObject",
                          - "s3:DeleteObject",
                          - "s3:AbortMultipartUpload",
                        ] -> "s3:GetBucketLocation"
                      ~ Resource = "arn:aws:s3:::er-prod-lake-797781631727/*" -> "arn:aws:s3:::er-prod-lake-797781631727"
                      ~ Sid      = "LakeObjects" -> "BucketLocationOnly"
                        # (1 unchanged attribute hidden)
                    },
                  - {
                      - 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"
                    },
                ]
                # (1 unchanged attribute hidden)
            }
        )
        # (2 unchanged attributes hidden)
    }

  # module.tenant_runners.aws_eks_pod_identity_association.tenant["app/isolation-probe-a"] will be created
  + resource "aws_eks_pod_identity_association" "tenant" {
      + 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-93ccc8f077814e800e7a"
      + tags_all             = {
          + "Environment" = "prod"
          + "ManagedBy"   = "terraform"
          + "Project"     = "entity-resolution"
        }
    }

  # module.tenant_runners.aws_eks_pod_identity_association.tenant["app/isolation-probe-b"] will be created
  + resource "aws_eks_pod_identity_association" "tenant" {
      + 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-c6090ab88ffa4d30bb25"
      + tags_all             = {
          + "Environment" = "prod"
          + "ManagedBy"   = "terraform"
          + "Project"     = "entity-resolution"
        }
    }

  # module.tenant_runners.aws_iam_role.tenant["app/isolation-probe-a"] will be created
  + resource "aws_iam_role" "tenant" {
      + arn                   = (known after apply)
      + assume_role_policy    = jsonencode(
            {
              + Statement = [
                  + {
                      + Action    = [
                          + "sts:AssumeRole",
                          + "sts:TagSession",
                        ]
                      + Condition = {
                          + StringEquals = {
                              + "aws:RequestTag/eks-cluster-arn"            = "arn:aws:eks:us-east-2:797781631727:cluster/er-prod"
                              + "aws:RequestTag/kubernetes-namespace"       = "app"
                              + "aws:RequestTag/kubernetes-service-account" = "er-runner-93ccc8f077814e800e7a"
                            }
                        }
                      + 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-79b3a4bd146119bda02f"
      + 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)
    }

  # module.tenant_runners.aws_iam_role.tenant["app/isolation-probe-b"] will be created
  + resource "aws_iam_role" "tenant" {
      + arn                   = (known after apply)
      + assume_role_policy    = jsonencode(
            {
              + Statement = [
                  + {
                      + Action    = [
                          + "sts:AssumeRole",
                          + "sts:TagSession",
                        ]
                      + Condition = {
                          + StringEquals = {
                              + "aws:RequestTag/eks-cluster-arn"            = "arn:aws:eks:us-east-2:797781631727:cluster/er-prod"
                              + "aws:RequestTag/kubernetes-namespace"       = "app"
                              + "aws:RequestTag/kubernetes-service-account" = "er-runner-c6090ab88ffa4d30bb25"
                            }
                        }
                      + 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-9ba07546e1359bb14800"
      + 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)
    }

  # module.tenant_runners.aws_iam_role_policy.lake["app/isolation-probe-a"] will be created
  + resource "aws_iam_role_policy" "lake" {
      + id          = (known after apply)
      + name        = "tenant-lake"
      + name_prefix = (known after apply)
      + policy      = jsonencode(
            {
              + Statement = [
                  + {
                      + Action   = [
                          + "s3:GetObject",
                          + "s3:PutObject",
                          + "s3:DeleteObject",
                          + "s3:AbortMultipartUpload",
                          + "s3:ListMultipartUploadParts",
                        ]
                      + Effect   = "Allow"
                      + Resource = [
                          + "arn:aws:s3:::er-prod-lake-797781631727/_isolation/probe-a/*",
                        ]
                      + Sid      = "TenantObjects"
                    },
                  + {
                      + Action    = [
                          + "s3:ListBucket",
                        ]
                      + Condition = {
                          + StringLike = {
                              + "s3:prefix" = [
                                  + "_isolation/probe-a/*",
                                ]
                            }
                        }
                      + Effect    = "Allow"
                      + Resource  = [
                          + "arn:aws:s3:::er-prod-lake-797781631727",
                        ]
                      + Sid       = "TenantList"
                    },
                  + {
                      + Action   = [
                          + "s3:GetBucketLocation",
                        ]
                      + Effect   = "Allow"
                      + Resource = [
                          + "arn:aws:s3:::er-prod-lake-797781631727",
                        ]
                      + Sid      = "BucketLocation"
                    },
                  + {
                      + Action    = [
                          + "kms:Decrypt",
                          + "kms:GenerateDataKey",
                        ]
                      + Condition = {
                          + StringEquals = {
                              + "kms:EncryptionContext:aws:s3:arn" = "arn:aws:s3:::er-prod-lake-797781631727"
                              + "kms:ViaService"                   = "s3.us-east-2.amazonaws.com"
                            }
                        }
                      + Effect    = "Allow"
                      + Resource  = [
                          + "arn:aws:kms:us-east-2:797781631727:key/aac8b63d-fd14-4c13-896e-ceaa41dcf0ce",
                        ]
                      + Sid       = "LakeKeyViaS3"
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
      + role        = (known after apply)
    }

  # module.tenant_runners.aws_iam_role_policy.lake["app/isolation-probe-b"] will be created
  + resource "aws_iam_role_policy" "lake" {
      + id          = (known after apply)
      + name        = "tenant-lake"
      + name_prefix = (known after apply)
      + policy      = jsonencode(
            {
              + Statement = [
                  + {
                      + Action   = [
                          + "s3:GetObject",
                          + "s3:PutObject",
                          + "s3:DeleteObject",
                          + "s3:AbortMultipartUpload",
                          + "s3:ListMultipartUploadParts",
                        ]
                      + Effect   = "Allow"
                      + Resource = [
                          + "arn:aws:s3:::er-prod-lake-797781631727/_isolation/probe-b/*",
                        ]
                      + Sid      = "TenantObjects"
                    },
                  + {
                      + Action    = [
                          + "s3:ListBucket",
                        ]
                      + Condition = {
                          + StringLike = {
                              + "s3:prefix" = [
                                  + "_isolation/probe-b/*",
                                ]
                            }
                        }
                      + Effect    = "Allow"
                      + Resource  = [
                          + "arn:aws:s3:::er-prod-lake-797781631727",
                        ]
                      + Sid       = "TenantList"
                    },
                  + {
                      + Action   = [
                          + "s3:GetBucketLocation",
                        ]
                      + Effect   = "Allow"
                      + Resource = [
                          + "arn:aws:s3:::er-prod-lake-797781631727",
                        ]
                      + Sid      = "BucketLocation"
                    },
                  + {
                      + Action    = [
                          + "kms:Decrypt",
                          + "kms:GenerateDataKey",
                        ]
                      + Condition = {
                          + StringEquals = {
                              + "kms:EncryptionContext:aws:s3:arn" = "arn:aws:s3:::er-prod-lake-797781631727"
                              + "kms:ViaService"                   = "s3.us-east-2.amazonaws.com"
                            }
                        }
                      + Effect    = "Allow"
                      + Resource  = [
                          + "arn:aws:kms:us-east-2:797781631727:key/aac8b63d-fd14-4c13-896e-ceaa41dcf0ce",
                        ]
                      + Sid       = "LakeKeyViaS3"
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
      + role        = (known after apply)
    }

Plan: 6 to add, 1 to change, 0 to destroy.

@athvin
athvin marked this pull request as ready for review November 9, 2026 06:52
@athvin
athvin force-pushed the issue/550-tenant-runner-identity branch 4 times, most recently from f9b9f8c to e2c3ffe Compare November 9, 2026 09:45
@athvin
athvin force-pushed the issue/550-tenant-runner-identity branch from e2c3ffe to dc37858 Compare November 9, 2026 09:50
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.

Per-tenant runner ServiceAccounts

2 participants