Skip to content

fix(infra): re-baseline the cost budgets above the measured floor - #1098

Merged
athvin merged 1 commit into
mainfrom
cost-rebaseline
Nov 17, 2026
Merged

athvin merged 1 commit into
mainfrom
cost-rebaseline

Conversation

@athvin

@athvin athvin commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Closes #1095

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

What

Re-baselines the two cost budgets from $300/$600 to $800 watch /
$1000 alarm, and renames them from amount-bearing (er-monthly-300) to
role-bearing (er-monthly-watch, er-monthly-alarm).

Why

Measured steady state is $23.08/day → ~$702/month, so the old upper tier
fired on ordinary operation and stopped carrying information. The rename is so
the amount lives only in limit_amount; the old names went stale the moment the
floor moved.

Proof

terraform fmt -check -recursive clean, terraform validate Success in
envs/core, and make tf-static-credentials-check passed (9/9 self-tests, then
clean — 1 access key(s), all allowed). Terraform-only diff, so the Rust and
frontend gates have nothing to compile; infra.yml's plan job on this PR is the
real gate.

Risk & rollback

Renaming the resources is a destroy+create of two aws_budgets_budget
resources
, which hold no data — the plan should show 2 destroys and 2 creates
and nothing else. Rollback is git revert <merge-sha>.

Post-merge ledger

Closed by: agent · session Claude Code:f14bf995-5565-41eb-9658-d3746dc3188e on Mac-833 · 2026-11-17T02:59:51Z

  • main is green with this change on it — merge SHA
    2b9f9d7d5861da0ce0dbe98cac134b972983303a. 40 check-runs on that SHA,
    zero non-success/non-skipped, including test, workflow pins (S9),
    playwright functional tier, terraform plan, agent skills and all four
    plan legs. infra run 44006226008 concluded success.
  • images — n/a — the diff is one Terraform file in envs/core; nothing
    that goes into an image changed, and detect changes correctly skipped the
    image path.
  • deploy — n/a — no deployable artifact changed. Budgets are an AWS
    API object applied by infra.yml, not something the cluster serves.
  • the push-only surface no pull request can pre-test — this is the item
    that mattered here, since the apply only exists on push: apply (core),
    apply (dev) and apply (prod) all concluded success on the merge SHA.
  • the board card reached Done through the automation rather than by
    hand, and the issue closed: Re-baseline the AWS cost budgets above the measured floor #1095 reads state=CLOSED reason=COMPLETED,
    card Done. Not touched by hand.
  • follow-ups — November 2026 cost review: findings, and why NAT Gateway has no lever #1097 carries the one item this work left open: the
    60 GiB of detached gp3 still needs a kubectl check to tell retained
    PVC data from reclaimable waste. Nothing else is owed.
  • what was learned is written down — the November measurement, the
    ~$320/month two-environment floor and the NAT no-lever result with its
    three closed paths are recorded on November 2026 cost review: findings, and why NAT Gateway has no lever #1097 so they are not re-investigated,
    and in session memory (november-2026-cost-review).

Specific to this change

  • infra.yml's apply on main actually recreated both budgets — read
    back live, not inferred from the apply conclusion:
    aws budgets describe-budgets --account-id 797781631727 \ --query 'Budgets[].[BudgetName,BudgetLimit.Amount]' er-monthly-alarm 1000.0 er-monthly-watch 800.0
    The er-monthly-300 / er-monthly-600 pair is gone; only the two
    role-named budgets remain.
  • the email subscriptions survived the recreate. Checked rather than
    assumed, because a budget with no subscriber looks identical to a working
    one. Both budgets carry ACTUAL 100.0 and FORECASTED 100.0, and
    describe-subscribers-for-notification returns
    EMAIL [email protected] on each.
Context — plan, discoveries, measurements, files

Plan

  1. Re-baseline the limits against measured spend — done.
  2. Rename to role-bearing names so the number lives in one place — done.
  3. Record the measurement and the "bad window" warning in the file header — done.

Discoveries

  • Nothing outside budgets.tf references the budget names, so the rename is
    free (grep -rn 'er-monthly-300|monthly_300' hits only the file itself and
    other worktrees' copies).
  • The two Budgets notifications go to one email by direct subscription, not
    through SNS, so there is no fan-out to re-point.

Measurements

Cost Explorer daily unblended, --group-by Type=DIMENSION,Key=SERVICE, over
2026-11-01..17. Post-prod-launch steady state:

day total
11-10 $22.86
11-11 $23.50
11-12 $23.65
11-13 $23.55
11-14 $22.38
11-15 $22.51

Mean $23.08/day → $702/month. $320/month of that is fixed two-environment
cost: 2 EKS control planes (
$146), 2 Auto Mode system nodes (
$96), 2 NAT
gateways ($64), 5 public IPv4 ($18).

November is a bad window to re-measure from: $228.76 of MTD was one-off S3
egress from sccache, which ended 11-09 when the cache moved to R2 (#920). Full
breakdown and the NAT no-lever result are recorded in #1097.

Files

  • infra/terraform/envs/core/budgets.tf

The $300/$600 ladder was set at bootstrap. Measured steady state is now
$23.08/day (2026-11-10..15, Cost Explorer daily unblended) = ~$702/month, so
the upper tier fired on ordinary operation and stopped carrying information.
New ladder is $800 watch / $1000 alarm.

Names go from amount-bearing to role-bearing, so the amount lives only in
limit_amount and the next re-baseline cannot leave a misleading name behind.
That is a destroy+create of two budgets, which carry no data.

Closes #1095

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

terraform plan

af39b16 · run log and full plans

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

core — 2 to add, 0 to change, 2 to DESTROY
module.identity_center.data.aws_ssoadmin_instances.this: Reading...
data.aws_iam_policy_document.ci_tf_plan_state: Reading...
data.aws_iam_policy_document.ci_tf_plan_state: Read complete after 0s [id=2883378100]
data.aws_caller_identity.current: Reading...
data.aws_iam_policy_document.ci_tf_drift_refresh: Reading...
data.aws_iam_policy_document.ci_tf_drift_refresh: Read complete after 0s [id=2350222434]
data.aws_iam_policy_document.obs_pod_trust: Reading...
data.aws_iam_policy_document.obs_pod_trust: Read complete after 0s [id=819195744]
data.aws_iam_policy_document.ci_tf_apply_no_prod_state: Reading...
data.aws_caller_identity.current: Read complete after 0s [id=797781631727]
module.github_oidc.data.aws_iam_policy_document.trust: Reading...
data.aws_iam_policy_document.ci_tf_apply_no_prod_state: Read complete after 0s [id=2395007408]
module.github_oidc.data.aws_iam_policy_document.trust: Read complete after 0s [id=4060172364]
data.aws_iam_policy_document.config_bucket: Reading...
data.aws_iam_policy_document.cur_delivery: Reading...
module.github_oidc.data.aws_iam_policy_document.push: Reading...
data.aws_iam_policy_document.cur_delivery: Read complete after 0s [id=2207400467]
data.aws_iam_policy_document.sccache_write: Reading...
data.aws_iam_policy_document.sccache_write: Read complete after 0s [id=786296009]
module.github_oidc.data.aws_iam_policy_document.push: Read complete after 0s [id=2177873069]
data.aws_iam_policy_document.sccache_read: Reading...
data.aws_iam_policy_document.config_bucket: Read complete after 0s [id=4067691321]
data.aws_iam_policy_document.sccache_trust_write: Reading...
data.aws_iam_policy_document.sccache_read: Read complete after 0s [id=2701062528]
data.aws_iam_policy_document.sccache_trust_read: Reading...
data.aws_iam_policy_document.ci_tf_apply_trust: Reading...
data.aws_iam_policy_document.ci_tf_plan_trust: Reading...
data.aws_iam_policy_document.ci_tf_drift_trust: Reading...
data.aws_iam_policy_document.sccache_trust_write: Read complete after 0s [id=4060172364]
data.aws_iam_policy_document.ci_tf_apply_trust: Read complete after 0s [id=2538345208]
data.aws_iam_policy_document.sccache_trust_read: Read complete after 0s [id=1630650595]
data.aws_iam_policy_document.ci_tf_plan_trust: Read complete after 0s [id=1630650595]
data.aws_iam_policy_document.ci_tf_drift_trust: Read complete after 0s [id=3359896184]
data.aws_iam_policy_document.openobserve: Reading...
data.aws_iam_policy_document.audit_bucket: Reading...
data.aws_iam_policy_document.openobserve: Read complete after 0s [id=2662704728]
data.aws_iam_policy_document.audit_bucket: Read complete after 0s [id=3031279952]
module.identity_center.data.aws_ssoadmin_instances.this: Read complete after 0s [id=us-east-2]
data.aws_iam_policy_document.ci_tf_apply_prod_trust: Reading...
data.aws_iam_policy_document.ci_tf_apply_prod_trust: Read complete after 0s [id=3513372776]
module.identity_center.data.aws_identitystore_user.admin: Reading...
module.identity_center.data.aws_identitystore_user.admin: Read complete after 1s [id=b17b2500-e0b1-7046-405b-23c088cf392b]

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

Terraform will perform the following actions:

  # aws_budgets_budget.monthly_300 will be destroyed
  # (because aws_budgets_budget.monthly_300 is not in configuration)
  - resource "aws_budgets_budget" "monthly_300" {
      - account_id        = "797781631727" -> null
      - arn               = "arn:aws:budgets::797781631727:budget/er-monthly-300" -> null
      - budget_type       = "COST" -> null
      - id                = "797781631727:er-monthly-300" -> null
      - limit_amount      = "300.0" -> null
      - limit_unit        = "USD" -> null
      - metrics           = [] -> null
      - name              = "er-monthly-300" -> null
      - tags              = {} -> null
      - tags_all          = {
          - "Environment" = "core"
          - "ManagedBy"   = "terraform"
          - "Project"     = "entity-resolution"
        } -> null
      - time_period_end   = "2087-06-15_00:00" -> null
      - time_period_start = "2026-10-01_00:00" -> null
      - time_unit         = "MONTHLY" -> null
        # (2 unchanged attributes hidden)

      - cost_types {
          - include_credit             = true -> null
          - include_discount           = true -> null
          - include_other_subscription = true -> null
          - include_recurring          = true -> null
          - include_refund             = true -> null
          - include_subscription       = true -> null
          - include_support            = true -> null
          - include_tax                = true -> null
          - include_upfront            = true -> null
          - use_amortized              = false -> null
          - use_blended                = false -> null
        }

      - notification {
          - comparison_operator        = "GREATER_THAN" -> null
          - notification_type          = "ACTUAL" -> null
          - subscriber_email_addresses = [
              - "[email protected]",
            ] -> null
          - subscriber_sns_topic_arns  = [] -> null
          - threshold                  = 100 -> null
          - threshold_type             = "PERCENTAGE" -> null
        }
      - notification {
          - comparison_operator        = "GREATER_THAN" -> null
          - notification_type          = "FORECASTED" -> null
          - subscriber_email_addresses = [
              - "[email protected]",
            ] -> null
          - subscriber_sns_topic_arns  = [] -> null
          - threshold                  = 100 -> null
          - threshold_type             = "PERCENTAGE" -> null
        }
    }

  # aws_budgets_budget.monthly_600 will be destroyed
  # (because aws_budgets_budget.monthly_600 is not in configuration)
  - resource "aws_budgets_budget" "monthly_600" {
      - account_id        = "797781631727" -> null
      - arn               = "arn:aws:budgets::797781631727:budget/er-monthly-600" -> null
      - budget_type       = "COST" -> null
      - id                = "797781631727:er-monthly-600" -> null
      - limit_amount      = "600.0" -> null
      - limit_unit        = "USD" -> null
      - metrics           = [] -> null
      - name              = "er-monthly-600" -> null
      - tags              = {} -> null
      - tags_all          = {
          - "Environment" = "core"
          - "ManagedBy"   = "terraform"
          - "Project"     = "entity-resolution"
        } -> null
      - time_period_end   = "2087-06-15_00:00" -> null
      - time_period_start = "2026-10-01_00:00" -> null
      - time_unit         = "MONTHLY" -> null
        # (2 unchanged attributes hidden)

      - cost_types {
          - include_credit             = true -> null
          - include_discount           = true -> null
          - include_other_subscription = true -> null
          - include_recurring          = true -> null
          - include_refund             = true -> null
          - include_subscription       = true -> null
          - include_support            = true -> null
          - include_tax                = true -> null
          - include_upfront            = true -> null
          - use_amortized              = false -> null
          - use_blended                = false -> null
        }

      - notification {
          - comparison_operator        = "GREATER_THAN" -> null
          - notification_type          = "ACTUAL" -> null
          - subscriber_email_addresses = [
              - "[email protected]",
            ] -> null
          - subscriber_sns_topic_arns  = [] -> null
          - threshold                  = 100 -> null
          - threshold_type             = "PERCENTAGE" -> null
        }
      - notification {
          - comparison_operator        = "GREATER_THAN" -> null
          - notification_type          = "FORECASTED" -> null
          - subscriber_email_addresses = [
              - "[email protected]",
            ] -> null
          - subscriber_sns_topic_arns  = [] -> null
          - threshold                  = 100 -> null
          - threshold_type             = "PERCENTAGE" -> null
        }
    }

  # aws_budgets_budget.monthly_alarm will be created
  + resource "aws_budgets_budget" "monthly_alarm" {
      + account_id        = (known after apply)
      + arn               = (known after apply)
      + budget_type       = "COST"
      + id                = (known after apply)
      + limit_amount      = "1000.0"
      + limit_unit        = "USD"
      + name              = "er-monthly-alarm"
      + name_prefix       = (known after apply)
      + tags_all          = {
          + "Environment" = "core"
          + "ManagedBy"   = "terraform"
          + "Project"     = "entity-resolution"
        }
      + time_period_end   = "2087-06-15_00:00"
      + time_period_start = (known after apply)
      + time_unit         = "MONTHLY"

      + cost_filter (known after apply)

      + cost_types (known after apply)

      + notification {
          + comparison_operator        = "GREATER_THAN"
          + notification_type          = "ACTUAL"
          + subscriber_email_addresses = [
              + "[email protected]",
            ]
          + subscriber_sns_topic_arns  = []
          + threshold                  = 100
          + threshold_type             = "PERCENTAGE"
        }
      + notification {
          + comparison_operator        = "GREATER_THAN"
          + notification_type          = "FORECASTED"
          + subscriber_email_addresses = [
              + "[email protected]",
            ]
          + subscriber_sns_topic_arns  = []
          + threshold                  = 100
          + threshold_type             = "PERCENTAGE"
        }
    }

  # aws_budgets_budget.monthly_watch will be created
  + resource "aws_budgets_budget" "monthly_watch" {
      + account_id        = (known after apply)
      + arn               = (known after apply)
      + budget_type       = "COST"
      + id                = (known after apply)
      + limit_amount      = "800.0"
      + limit_unit        = "USD"
      + name              = "er-monthly-watch"
      + name_prefix       = (known after apply)
      + tags_all          = {
          + "Environment" = "core"
          + "ManagedBy"   = "terraform"
          + "Project"     = "entity-resolution"
        }
      + time_period_end   = "2087-06-15_00:00"
      + time_period_start = (known after apply)
      + time_unit         = "MONTHLY"

      + cost_filter (known after apply)

      + cost_types (known after apply)

      + notification {
          + comparison_operator        = "GREATER_THAN"
          + notification_type          = "ACTUAL"
          + subscriber_email_addresses = [
              + "[email protected]",
            ]
          + subscriber_sns_topic_arns  = []
          + threshold                  = 100
          + threshold_type             = "PERCENTAGE"
        }
      + notification {
          + comparison_operator        = "GREATER_THAN"
          + notification_type          = "FORECASTED"
          + subscriber_email_addresses = [
              + "[email protected]",
            ]
          + subscriber_sns_topic_arns  = []
          + threshold                  = 100
          + threshold_type             = "PERCENTAGE"
        }
    }

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

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.

Re-baseline the AWS cost budgets above the measured floor

2 participants