indexer: add indexer_enabled teardown gate for internal-mainnet wind-down - #170
Open
UnbornAztecKing wants to merge 2 commits into
Open
Conversation
…down (ENG-3056)
Introduce two workspace-scoped switches that let the internal-mainnet indexer be
torn down while retaining Terraform state + config for an emergency rebuild:
- indexer_enabled (default true): master existence gate. Every resource/module
is count-gated on it, and the service/AZ source locals (services,
lambda_services, service_names, azs) empty out when false so every for_each
collapses. false => full destroy of all indexer + indexer-full-node infra.
- indexer_teardown_disarm (default false): drops delete guards one apply before
the destroy — RDS deletion_protection and the snapshot bucket force_destroy.
Both default to today's behavior, so dev/staging/testnet (which share this root
in separate workspaces) are unaffected. teardown_moved.tf carries 54 moved blocks
so adding count to previously count-less resources migrates existing state
(default indexer_enabled=true) with zero resource changes instead of
destroy+recreate.
Also drops the prevent_destroy lifecycle literals on the main ElastiCache group
and ACM cert (cannot be variable-driven) so the gated destroy can proceed.
Validated with `terraform validate` (tf 1.3.2). Speculative plans on
dev/staging/testnet (expected: 0 resource changes) gate the merge.
Wiz Scan Summary
To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension. |
Make the internal-mainnet teardown intrinsic to the workspace instead of
dependent on a workspace variable that could be unset or forgotten. Internal
mainnet is the only workspace with environment = "mainnet", so derive the gate:
local.indexer_enabled = override ?? (environment != "mainnet")
local.indexer_teardown_disarm = override ?? (environment == "mainnet")
The indexer_enabled / indexer_teardown_disarm variables become nullable overrides
(default null). All gating now references the locals. Effect:
- mainnet: enabled=false, disarm=true -> full teardown, effective on merge, and
an errant apply cannot re-provision (it can only re-confirm torn-down state).
- dev/staging/testnet: values identical to before -> no-op (0 resource changes).
- restore: set indexer_enabled=true (and indexer_teardown_disarm=false) on the
mainnet workspace.
Verified derived values per environment with terraform console; terraform validate
(tf 1.3.2) passes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Winds down the internal-mainnet indexer to zero cost while keeping its Terraform state and config intact for a one-switch rebuild. The gate is derived from
environment— mainnet is torn down by default and no errant apply can re-provision it — so every other workspace is untouched.What it is
A teardown gate on the shared
indexer/root. Internal mainnet is the onlyenvironment = "mainnet"workspace, so the behavior is derived, not variable-driven:indexer_enabled = trueCapabilities
Testing
terraform validate(tf 1.3.2) andfmtpass; validate exercises the non-mainnet path and proves every gated reference resolves.terraform consoleconfirms the derived values per environment — mainnet off, others on, override restores.Reviewer brief
teardown.tf— the whole contract: two override variables and the environment-derived gate. Confirm it keys onenvironment == "mainnet".locals.tf— the service/AZ source collections that empty out when disabled, collapsing everyfor_each.teardown_moved.tf— 54 state-address migrations; a missing one makes a workspace propose destroy+recreate (caught by the merge gate).Everything else is the mechanical gating those three drive.
Out of scope
metric_ingestor/andamplitude_api_gateway/workspaces.Test plan
terraform validate+fmt(tf 1.3.2)terraform console— derived values per environment