Skip to content

feat(infra): delete the static S3 lake key, which had no consumer (#549) - #791

Merged
athvin merged 3 commits into
mainfrom
issue/549-s3-credential-chain
Nov 7, 2026
Merged

athvin merged 3 commits into
mainfrom
issue/549-s3-credential-chain

Conversation

@athvin

@athvin athvin commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

Closes #549

🚧 Claimed by an agent session — 2026-11-07T19:30:38Z.
The claim is this open draft PR: closing it releases the ticket.

What the tree says, against what the ticket says

The ticket asks for "DuckDB credential_chain plus the boto3 default chain".
Neither half is reachable as written, and the reason changes the scope:

  • There is no boto3. The Python tree was deleted. The ticket inherited that
    phrasing from plan-to-aws.md, written when the implementation was Python.
  • There is no DuckDB object-store path to migrate. dedupe_core::session
    has no httpfs/aws load, no CREATE SECRET and no ER_S3_* reader —
    .claude/skills/ducklake-lakehouse/SKILL.md pins this as a fact, and
    references/attach-and-tenancy.md records building one as still-not-on-main
    in-flight work. So credential_chain is not a switch to flip; it is a feature
    that does not exist yet.

What that leaves is smaller and cleaner than the ticket implies: the static
key has no consumer at all.
Verified each path:

Claimed consumer Reality
Rust engine reads ER_S3_* no reader anywhere in rust/crates/
er-server reads ERSERVER_SECRET_S3_* / secret:// no reader — that indirection was Python's secrets.py, deleted
Helm injects it chart has no ER_S3_*
scripts/dev_env.sh consumes er/dev/shared/s3 it reads only shared/postgres; the s3 entry is read by nothing
It is the only lake grant no — pod_identity.tf:106 already attaches the identical policy document to the er-dev-runner-pod role, and says in-line that this is where credential-chain access "already lives"
s3_ingest needs the key already on the default chain (s3_ingest.rs:230 says so explicitly)

So the ticket's own narrowed acceptance check — aws_iam_access_key blocks drop
from 2 to 1, and the surviving one is builder
— is the whole achievable
deliverable, and it is a deletion rather than a migration.

Plan

  • 1. infra/terraform/envs/dev/lake.tf — delete aws_iam_user.s3,
    aws_iam_user_policy.s3, aws_iam_access_key.s3,
    aws_secretsmanager_secret.s3 and its ..._version. Keep the policy
    document (the runner role uses it) renamed s3_user → lake_access,
    since there is no user left for it to describe. Rewrite the header comment
    that currently calls the key a live Phase-1 credential.
  • 2. infra/terraform/envs/dev/pod_identity.tf — repoint to the renamed
    document and correct the comment: the service user has retired, so
    "when that user retires" is no longer a future tense.
  • 3. scripts/dev_env.sh — drop the dead ER_S3_* / secret:// tenant
    env, the ERSERVER_SECRET_S3_* pair, the ER_DEV_S3_KEY warning and the
    header docs for both, all of which describe a Python resolver that is gone.
  • 4. Stale prose that asserts the key is the live mechanism — the failure
    mode my notes call skills rot at borrowed identifiers:
    .claude/skills/infra-platform/references/infrastructure.md (§467 cites
    two deleted src/er/lake/*.py files as current),
    .claude/skills/aws-account-operations/references/bedrock-and-sdks.md
    (table row names "the static ER_S3_* key" as the lake's credential), and
    .claude/skills/er-engine-ops/references/configuration.md (documents
    ER_S3_* as env the CLI reads). builder.tf's "should still be removed"
    line goes too — Retire the S3 service access key in favour of the credential chain #549 records the builder key as permanent.
  • 5. A guard so the count cannot drift back: scripts/ci/tf-static-credentials-check.sh
    asserting exactly one aws_iam_access_key under infra/terraform/ and
    that it is builder, with its own self-test first (a detector that breaks
    by noticing nothing reads like a clean tree). Wired into make check and
    rust.yml's ungated workflow pins (S9) job beside the sibling checks.

Out of scope, and it needs its own ticket: the actual object-store
credential path (optional-field config → CREATE OR REPLACE SECRET where an
absent key selects the chain, plus the filter keeping credential-shaped values
out of org rows). That is the in-flight feature attach-and-tenancy.md
describes, it is not what #549's acceptance check measures, and it is the thing
that would make an s3:// lake open from Rust. Filed as #792, with both of
that document's in-flight bullets as its acceptance criteria.

Gates

make check (touches scripts/, a workflow and skill references, so
scripts-home-check, workflow-shell-check and skills-check all bear on it),
plus terraform validate/fmt via the infra tier, and the new guard observed
failing before it is trusted.

Merge note: this plans a non-zero destroy, so tf-destroy-guard.sh refuses
it without the token — merge with
gh pr merge 791 --squash --subject '<subject> ALLOW-DESTROY'.

What changed while implementing

Three things the plan did not predict, all worth reading before the diff:

  1. Two of the stale sites named in Retire the S3 service access key in favour of the credential chain #549 were already fixed. builder.tf now
    says "REMOVAL — NOT SCHEDULED. Kept indefinitely by owner decision", and
    docs/parity-roadmap.md is gone with the whole docs/ directory. So step 4
    went looking elsewhere and found worse: bedrock-and-sdks.md was still
    giving the builder key "a scheduled deletion before the production gate",
    which is the opposite of the recorded decision, and
    infrastructure-decisions.md cited three ER_S3_REGION sites of which none
    still sets it.
  2. The gate found two real bugs in itself on first run — it flagged its own
    REJECT fixtures, and the self-test was pointing rule 2 at a directory the
    terraform fixture was not in, so that case had been asserting nothing. Both
    fixed; the commit message records them rather than hiding a clean first run.
  3. main was already red on make check before this branch existed.
    a241585b ("enable skill") edited claim-ticket's frontmatter without
    regenerating CLAUDE.md's generated skill table, so this branch originally
    carried that one regenerated line in order to go green. It no longer does:
    6d04e4b3 has since landed the identical regen, the rebase onto it dropped
    mine, and the commit message was amended to stop describing a change it no
    longer contains. This PR now touches neither CLAUDE.md nor agent-skills.md.

Independent corroboration of the acceptance check, from a generator that does
not know about this ticket: footprint.md's AWS resource inventory is
regenerated by skills-check from the Terraform tree, and now reads
1 aws_iam_access_key, 1 aws_iam_user, 1 aws_iam_user_policy and
4 aws_secretsmanager_secret — each down one.

Verification

make check run to completion against this branch, then every non-compiling
gate re-run after the rebase onto 6d04e4b3:

Phase Result
fmt, clippy -D warnings, doc -D warnings pass
entities-check 17 lint rules over 49 entities, 139 generated files current, every statement plans
skills-check ok (10/10 self-test)
scripts-home-check ok — 85 scripts, none astray
workflow-shell-check ok — 6 inline blocks, all within budget
tf-static-credentials-check 9/9 self-test; 1 access key(s), all allowed
test 92 test result: ok, zero FAILED
terraform fmt -check -recursive clean

The gate was observed failing before being trusted — it rejected its own
fixtures and exposed a self-test case that was asserting nothing. Both fixed in
the same commit.

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

terraform plan

993df31 · run log and full plans

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

Warning

This plan DESTROYS resources in: dev. Merging applies it unattended.
The apply refuses to run unless the merge commit message carries
ALLOW-DESTROY. Retitling is not enough on a single-commit PR — GitHub
uses the commit message there, not the title. Merge with
gh pr merge <n> --squash --subject '<subject> ALLOW-DESTROY'.

dev — 0 to add, 0 to change, 5 to DESTROY
data.aws_iam_policy_document.eso_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]
data.aws_iam_policy_document.eso_trust: Read complete after 0s [id=819195744]
data.aws_iam_policy_document.efs_csi_trust: Reading...
data.aws_rds_engine_version.aurora_pg: Reading...
module.network.data.aws_region.current: Reading...
data.aws_iam_openid_connect_provider.github: Reading...
data.aws_iam_policy_document.efs_csi_trust: Read complete after 0s [id=819195744]
data.aws_iam_policy_document.obs_pod_trust: Reading...
module.network.data.aws_region.current: Read complete after 0s [id=us-east-2]
data.aws_iam_policy_document.obs_pod_trust: Read complete after 0s [id=819195744]
data.aws_iam_policy_document.er_api_pod_trust: Reading...
data.aws_caller_identity.current: Reading...
module.eks.data.aws_iam_policy_document.node_trust: Reading...
module.network.data.aws_availability_zones.available: Reading...
data.aws_iam_policy_document.er_api_pod_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.eso: Reading...
module.eks.data.aws_iam_policy_document.node_trust: Read complete after 0s [id=2851119427]
data.aws_iam_policy_document.fluent_bit: Reading...
data.aws_iam_policy_document.eso: Read complete after 0s [id=1725605485]
data.aws_iam_policy_document.fluent_bit: Read complete after 0s [id=4006586444]
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.otel_collector: Reading...
data.aws_iam_policy_document.otel_collector: Read complete after 0s [id=3111493560]
data.aws_iam_policy_document.lake_access: Reading...
data.aws_iam_policy_document.lake_access: Read complete after 0s [id=3442692123]
data.aws_caller_identity.current: Read complete after 0s [id=797781631727]
data.aws_iam_policy_document.bedrock_invoke: Reading...
data.aws_iam_policy_document.bedrock_invoke: Read complete after 0s [id=3601248236]
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]
data.aws_iam_policy_document.ci_deploy_dev: Reading...
data.aws_iam_policy_document.ci_deploy_dev: Read complete after 0s [id=1754478413]
data.aws_iam_openid_connect_provider.github: Read complete after 1s [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]

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

Terraform will perform the following actions:

  # aws_iam_access_key.s3 will be destroyed
  # (because aws_iam_access_key.s3 is not in configuration)
  - resource "aws_iam_access_key" "s3" {
      - create_date          = "2026-10-10T21:17:07Z" -> null
      - id                   = "AKIA3TP35ULXQQYDISZZ" -> null
      - secret               = (sensitive value) -> null
      - ses_smtp_password_v4 = (sensitive value) -> null
      - status               = "Active" -> null
      - user                 = "er-dev-s3" -> null
    }

  # aws_iam_user.s3 will be destroyed
  # (because aws_iam_user.s3 is not in configuration)
  - resource "aws_iam_user" "s3" {
      - arn                  = "arn:aws:iam::797781631727:user/er-dev-s3" -> null
      - force_destroy        = false -> null
      - id                   = "er-dev-s3" -> null
      - name                 = "er-dev-s3" -> null
      - path                 = "/" -> null
      - tags                 = {} -> null
      - tags_all             = {
          - "Environment" = "dev"
          - "ManagedBy"   = "terraform"
          - "Project"     = "entity-resolution"
        } -> null
      - unique_id            = "AIDA3TP35ULXUPLD4NN54" -> null
        # (1 unchanged attribute hidden)
    }

  # aws_iam_user_policy.s3 will be destroyed
  # (because aws_iam_user_policy.s3 is not in configuration)
  - resource "aws_iam_user_policy" "s3" {
      - id          = "er-dev-s3:er-dev-lake" -> null
      - name        = "er-dev-lake" -> null
      - policy      = jsonencode(
            {
              - Statement = [
                  - {
                      - Action   = [
                          - "s3:PutObject",
                          - "s3:ListMultipartUploadParts",
                          - "s3:GetObject",
                          - "s3:DeleteObject",
                          - "s3:AbortMultipartUpload",
                        ]
                      - Effect   = "Allow"
                      - Resource = "arn:aws:s3:::er-dev-lake-797781631727/*"
                      - Sid      = "LakeObjects"
                    },
                  - {
                      - 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"
                    },
                ]
              - Version   = "2012-10-17"
            }
        ) -> null
      - user        = "er-dev-s3" -> null
        # (1 unchanged attribute hidden)
    }

  # aws_secretsmanager_secret.s3 will be destroyed
  # (because aws_secretsmanager_secret.s3 is not in configuration)
  - resource "aws_secretsmanager_secret" "s3" {
      - arn                            = "arn:aws:secretsmanager:us-east-2:797781631727:secret:er/dev/shared/s3-Y47I6B" -> null
      - description                    = "The 9.2 interim lake credential; consumed by scripts/dev_env.sh. Phase 4 retires it." -> null
      - force_overwrite_replica_secret = false -> null
      - id                             = "arn:aws:secretsmanager:us-east-2:797781631727:secret:er/dev/shared/s3-Y47I6B" -> null
      - name                           = "er/dev/shared/s3" -> null
      - recovery_window_in_days        = 30 -> null
      - region                         = "us-east-2" -> null
      - tags                           = {} -> null
      - tags_all                       = {
          - "Environment" = "dev"
          - "ManagedBy"   = "terraform"
          - "Project"     = "entity-resolution"
        } -> null
        # (4 unchanged attributes hidden)
    }

  # aws_secretsmanager_secret_version.s3 will be destroyed
  # (because aws_secretsmanager_secret_version.s3 is not in configuration)
  - resource "aws_secretsmanager_secret_version" "s3" {
      - arn              = "arn:aws:secretsmanager:us-east-2:797781631727:secret:er/dev/shared/s3-Y47I6B" -> null
      - id               = "arn:aws:secretsmanager:us-east-2:797781631727:secret:er/dev/shared/s3-Y47I6B|terraform-v7xxtO3mes7ucCqcdvguiO5Ipp" -> null
      - region           = "us-east-2" -> null
      - secret_arn       = "arn:aws:secretsmanager:us-east-2:797781631727:secret:er/dev/shared/s3-Y47I6B" -> null
      - secret_id        = "arn:aws:secretsmanager:us-east-2:797781631727:secret:er/dev/shared/s3-Y47I6B" -> null
      - secret_string    = (sensitive value) -> null
      - secret_string_wo = (write-only attribute) -> null
      - version_id       = "terraform-v7xxtO3mes7ucCqcdvguiO5Ipp" -> null
      - version_stages   = [
          - "AWSCURRENT",
        ] -> null
        # (1 unchanged attribute hidden)
    }

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

bmoore813 and others added 3 commits November 7, 2026 15:10
#549 asked to move DuckDB and boto3 onto the credential chain. Neither half
exists: the Python tree that held boto3 was deleted, and the Rust engine has no
object-store path to migrate — no httpfs/aws load, no CREATE SECRET, no ER_S3_*
reader (the ducklake-lakehouse skill pins this, and attach-and-tenancy.md
records building one as still-not-on-main).

So the key was not a credential in use. It was minted in lake.tf, written to
er/dev/shared/s3, and read by nothing: no Rust reader, no chart injection,
dev_env.sh reads only shared/postgres, and the `secret://` indirection meant to
resolve it belonged to Python's deleted secrets.py. Meanwhile the identical
grants already sit on the er-dev-runner-pod Pod Identity role, which
pod_identity.tf said in-line was where credential-chain access "already lives",
and the one real S3 client (s3_ingest::Watcher) has always used the default
chain.

Retiring it is therefore a deletion, which is #549's own narrowed acceptance
check: aws_iam_access_key blocks drop from 2 to 1, and the survivor is builder.
The policy document survives the user it described, renamed lake_access.

Also removes the dead ER_S3_*/secret:// tenant env and ERSERVER_SECRET_S3_* pair
from dev_env.sh, and corrects four references that still presented the key as
the live mechanism — including two that cited deleted src/er/lake/*.py files as
current, and one that gave the builder key a scheduled deletion it does not have.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
#549's acceptance check was a count — `aws_iam_access_key` blocks under
infra/terraform/ drop from 2 to 1, survivor `builder`. A count in a closed
issue protects nothing, so this is that check as a gate, plus a bar on
re-plumbing the ER_S3_* pair the previous commit removed (the engine has no
reader for it, so re-adding it could only recreate a credential nothing uses).

The gate carries a FLOOR, which is the part worth reviewing: against the real
tree, finding ZERO access-key blocks exits 2 rather than reporting success,
because builder.tf is known to declare one. A detector breaks by noticing
nothing, and that failure reads exactly like a clean tree — the shape that let
the S9 pin gate enforce nothing until #467. Its self-test asserts both
directions of both rules, proves the floor fires, and fails if it asserted
fewer than nine cases.

Both findings the self-test produced on first run were real: the gate flagged
its own REJECT fixtures (now exempted by exact path, not a *-test.sh glob), and
the harness was pointing rule 2 at a directory the terraform fixture was not in,
so that case had been asserting nothing.

Wired into `make check` and rust.yml's ungated `workflow pins (S9)` job, beside
its siblings — a new access key arrives on an infra-only PR, which is precisely
what a Rust path filter skips.

footprint.md's AWS inventory is regenerated here and is load-bearing as
corroboration: it now independently reads 1 aws_iam_access_key, 1 aws_iam_user,
1 aws_iam_user_policy and 4 aws_secretsmanager_secret — each down one — from a
generator that knows nothing about this ticket.

An earlier revision of this commit also carried a CLAUDE.md skill-table regen,
because a241585 ("enable skill") had edited claim-ticket's frontmatter without
regenerating it and `main` was failing `make skills-check` independently of this
branch. 6d04e4b has since landed that same regen, so the rebase dropped it and
this commit no longer touches CLAUDE.md.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@athvin
athvin force-pushed the issue/549-s3-credential-chain branch from 2e6041b to b5c3dcf Compare November 7, 2026 20:11
@athvin
athvin marked this pull request as ready for review November 7, 2026 20:12
@athvin athvin changed the title feat(infra): reach S3 through the credential chain instead of a static service key (#549) feat(infra): delete the static S3 lake key, which had no consumer (#549) Nov 7, 2026
@athvin
athvin merged commit 0c96a97 into main Nov 7, 2026
45 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.

Retire the S3 service access key in favour of the credential chain

2 participants