Skip to content

feat(infra): the deployed public-contract store, and the prod deploy role's grant (#1245) - #1246

Merged
athvin merged 3 commits into
mainfrom
issue/1245-contract-store
Nov 26, 2026
Merged

athvin merged 3 commits into
mainfrom
issue/1245-contract-store

Conversation

@athvin

@athvin athvin commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

Closes #1245

🚧 Claimed by an agent session — 2026-11-26T00:46:49Z, session Claude Code:d1e3b2dc-3174-4091-9c30-c08fc4820306 on Mac.
The claim is this open draft PR: closing it releases the claim.

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

What

infra/terraform/envs/prod/api-contract.tf:

  • bucket er-prod-api-contract-797781631727: versioned, SSE-S3, all public access blocked, prevent_destroy, and a 365-day noncurrent expiry;
  • bucket policy: TLS only, and s3:DeleteObject* denied to everyone on releases/*, so a published release record cannot be deleted;
  • er-ci-deploy-prod gains an api-contract inline policy: GetObject and PutObject on deployed/* and releases/* only, plus ListBucket conditioned to those prefixes. The ListBucket is what makes a missing baseline a 404, which the gate treats as first publication, rather than a 403, which it must treat as unreadable and refuse.

SSE-S3, not KMS: the public document is public by construction (no operator route, no credential), and it is committed and served at /api/openapi. KMS would only add the cross-stack grants #658 named as the expensive part.

Why

#1245, part of #658: the API launch gate needs a durable record of what production is serving. This lands ahead of the deploy step that reads and writes it, the #929 → #556 ordering precedent, because a PR carrying both would race the infra apply against the next deploy. The owner authorized this IAM/storage change on 2026-11-25.

Proof

  • terraform fmt -check and terraform validate (envs/prod): clean.
  • make tf-static-credentials-check: clean.
  • The PR's terraform plan (prod) comment is the change of record; it must show additions only. That is checked before merge, below.

Risk & rollback

Additive: one bucket with its configuration, and one inline policy on an existing role. Nothing reads it until the follow-up deploy change. Rollback: revert, though prevent_destroy will refuse to delete the bucket, which is the intent; empty it by hand only if it is truly unwanted.

Post-merge ledger

Closed by: agent · session Claude Code:d1e3b2dc-3174-4091-9c30-c08fc4820306 on Mac · 2026-11-26T01:05:01Z

Specific to this change

Context — plan, discoveries, measurements, files

Plan

Discoveries

Measurements

Files

bmoore813 and others added 2 commits November 25, 2026 16:46
…role's grant (#1245)

er-prod-api-contract: versioned, SSE-S3 (the public contract is public
data, so no KMS grants), public access blocked, TLS-only, and release
objects undeletable by bucket policy. er-ci-deploy-prod gets Get/Put on
deployed/ and releases/ only, with ListBucket scoped to them so a missing
baseline is a 404 the gate can call first publication. Part of #658, landed
ahead of the deploy step that uses it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@athvin
athvin marked this pull request as ready for review November 26, 2026 00:48
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

terraform plan

58bd0ed · 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 7 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 — 7 to add, 0 to change
module.ses.data.aws_region.current: Reading...
data.aws_iam_policy_document.efs_csi_trust: Reading...
module.ses.data.aws_region.current: Read complete after 0s [id=us-east-2]
data.aws_iam_policy_document.efs_csi_trust: Read complete after 0s [id=819195744]
module.eks.data.aws_iam_policy_document.cluster_trust: Reading...
data.aws_iam_policy_document.pod_trust: Reading...
module.eks.data.aws_iam_policy_document.cluster_trust: Read complete after 0s [id=1029077455]
data.aws_iam_policy_document.pod_trust: Read complete after 0s [id=819195744]
module.eks.data.aws_iam_policy_document.node_trust: Reading...
module.network.data.aws_availability_zones.available: Reading...
data.aws_rds_engine_version.aurora_pg: Reading...
data.aws_caller_identity.current: Reading...
module.network.data.aws_region.current: Reading...
module.eks.data.aws_iam_policy_document.node_trust: Read complete after 0s [id=2851119427]
data.aws_iam_openid_connect_provider.github: Reading...
data.aws_iam_policy_document.eso_trust: Reading...
module.network.data.aws_region.current: Read complete after 0s [id=us-east-2]
data.aws_iam_policy_document.eso_trust: Read complete after 0s [id=819195744]
data.aws_iam_policy_document.fluent_bit: Reading...
data.aws_iam_policy_document.fluent_bit: Read complete after 0s [id=2978074842]
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=81696635]
data.aws_iam_policy_document.openobserve: Reading...
data.aws_iam_policy_document.openobserve: Read complete after 0s [id=2652188337]
data.aws_caller_identity.current: Read complete after 0s [id=797781631727]
data.aws_iam_policy_document.otel_collector: Reading...
data.aws_iam_policy_document.otel_collector: Read complete after 0s [id=1193716550]
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...
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 1s [id=17.9]
module.network.data.aws_availability_zones.available: Read complete after 1s [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=2891227359]
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_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
 <= read (data resources)

Terraform will perform the following actions:

  # data.aws_iam_policy_document.api_contract_bucket will be read during apply
  # (config refers to values not yet known)
 <= data "aws_iam_policy_document" "api_contract_bucket" {
      + id            = (known after apply)
      + json          = (known after apply)
      + minified_json = (known after apply)

      + statement {
          + actions   = [
              + "s3:*",
            ]
          + effect    = "Deny"
          + resources = [
              + (known after apply),
              + (known after apply),
            ]
          + sid       = "DenyInsecureTransport"

          + condition {
              + test     = "Bool"
              + values   = [
                  + "false",
                ]
              + variable = "aws:SecureTransport"
            }

          + principals {
              + identifiers = [
                  + "*",
                ]
              + type        = "*"
            }
        }
      + statement {
          + actions   = [
              + "s3:DeleteObject",
              + "s3:DeleteObjectVersion",
            ]
          + effect    = "Deny"
          + resources = [
              + (known after apply),
            ]
          + sid       = "DenyReleaseDeletion"

          + principals {
              + identifiers = [
                  + "*",
                ]
              + type        = "*"
            }
        }
    }

  # data.aws_iam_policy_document.ci_deploy_prod_api_contract will be read during apply
  # (config refers to values not yet known)
 <= data "aws_iam_policy_document" "ci_deploy_prod_api_contract" {
      + id            = (known after apply)
      + json          = (known after apply)
      + minified_json = (known after apply)

      + statement {
          + actions   = [
              + "s3:GetObject",
              + "s3:PutObject",
            ]
          + effect    = "Allow"
          + resources = [
              + (known after apply),
              + (known after apply),
            ]
        }
      + statement {
          + actions   = [
              + "s3:ListBucket",
            ]
          + effect    = "Allow"
          + resources = [
              + (known after apply),
            ]

          + condition {
              + test     = "StringLike"
              + values   = [
                  + "deployed/*",
                  + "releases/*",
                ]
              + variable = "s3:prefix"
            }
        }
    }

  # aws_iam_role_policy.ci_deploy_prod_api_contract will be created
  + resource "aws_iam_role_policy" "ci_deploy_prod_api_contract" {
      + id          = (known after apply)
      + name        = "api-contract"
      + name_prefix = (known after apply)
      + policy      = (known after apply)
      + role        = "er-ci-deploy-prod"
    }

  # aws_s3_bucket.api_contract will be created
  + resource "aws_s3_bucket" "api_contract" {
      + acceleration_status         = (known after apply)
      + acl                         = (known after apply)
      + arn                         = (known after apply)
      + bucket                      = "er-prod-api-contract-797781631727"
      + bucket_domain_name          = (known after apply)
      + bucket_namespace            = (known after apply)
      + bucket_prefix               = (known after apply)
      + bucket_region               = (known after apply)
      + bucket_regional_domain_name = (known after apply)
      + force_destroy               = false
      + hosted_zone_id              = (known after apply)
      + id                          = (known after apply)
      + object_lock_enabled         = (known after apply)
      + policy                      = (known after apply)
      + region                      = "us-east-2"
      + request_payer               = (known after apply)
      + tags_all                    = {
          + "Environment" = "prod"
          + "ManagedBy"   = "terraform"
          + "Project"     = "entity-resolution"
        }
      + website_domain              = (known after apply)
      + website_endpoint            = (known after apply)

      + cors_rule (known after apply)

      + grant (known after apply)

      + lifecycle_rule (known after apply)

      + logging (known after apply)

      + object_lock_configuration (known after apply)

      + replication_configuration (known after apply)

      + server_side_encryption_configuration (known after apply)

      + versioning (known after apply)

      + website (known after apply)
    }

  # aws_s3_bucket_lifecycle_configuration.api_contract will be created
  + resource "aws_s3_bucket_lifecycle_configuration" "api_contract" {
      + bucket                                 = (known after apply)
      + expected_bucket_owner                  = (known after apply)
      + id                                     = (known after apply)
      + region                                 = "us-east-2"
      + transition_default_minimum_object_size = "all_storage_classes_128K"

      + rule {
          + id     = "noncurrent-expiry"
          + status = "Enabled"
            # (1 unchanged attribute hidden)

          + abort_incomplete_multipart_upload {
              + days_after_initiation = 7
            }

          + filter {
                # (1 unchanged attribute hidden)
            }

          + noncurrent_version_expiration {
              + noncurrent_days = 365
            }
        }
    }

  # aws_s3_bucket_policy.api_contract will be created
  + resource "aws_s3_bucket_policy" "api_contract" {
      + bucket = (known after apply)
      + id     = (known after apply)
      + policy = (known after apply)
      + region = "us-east-2"
    }

  # aws_s3_bucket_public_access_block.api_contract will be created
  + resource "aws_s3_bucket_public_access_block" "api_contract" {
      + block_public_acls       = true
      + block_public_policy     = true
      + bucket                  = (known after apply)
      + id                      = (known after apply)
      + ignore_public_acls      = true
      + region                  = "us-east-2"
      + restrict_public_buckets = true
    }

  # aws_s3_bucket_server_side_encryption_configuration.api_contract will be created
  + resource "aws_s3_bucket_server_side_encryption_configuration" "api_contract" {
      + bucket = (known after apply)
      + id     = (known after apply)
      + region = "us-east-2"

      + rule {
          + blocked_encryption_types = (known after apply)
          + bucket_key_enabled       = (known after apply)

          + apply_server_side_encryption_by_default {
              + kms_master_key_id = (known after apply)
              + sse_algorithm     = "AES256"
            }
        }
    }

  # aws_s3_bucket_versioning.api_contract will be created
  + resource "aws_s3_bucket_versioning" "api_contract" {
      + bucket = (known after apply)
      + id     = (known after apply)
      + region = "us-east-2"

      + versioning_configuration {
          + mfa_delete = (known after apply)
          + status     = "Enabled"
        }
    }

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

Changes to Outputs:
  + api_contract_bucket        = "er-prod-api-contract-797781631727"

@athvin
athvin merged commit 0e72bbc into main Nov 26, 2026
40 checks passed
@athvin
athvin temporarily deployed to marketing-preview November 26, 2026 00:58 — with GitHub Actions Inactive

This branch was previously deployed

1 inactive deployment
marketing-preview — 677a7f30 Deployed Nov 26, 2026 by athvin via remove closed PR previews #60
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.

#658a — The deployed-contract store: an S3 bucket and the prod deploy role's grant

2 participants