Skip to content

atp-indexer: single-instance stack (collapse ECS+Aurora+ALB onto one box)#87

Open
ludamad wants to merge 6 commits into
mainfrom
atp-indexer-single-instance
Open

atp-indexer: single-instance stack (collapse ECS+Aurora+ALB onto one box)#87
ludamad wants to merge 6 commits into
mainfrom
atp-indexer-single-instance

Conversation

@ludamad
Copy link
Copy Markdown

@ludamad ludamad commented May 29, 2026

What

Adds a self-contained atp-indexer/single-instance/ Terraform stack that collapses the atp-indexer's per-env ECS + Aurora + ALB onto one EC2 box running this repo's atp-indexer image against a local Postgres, fronted by Caddy (Caddy-direct TLS for testnet, CloudFront-front for prod). Mirrors the ignition-monorepo single-instance pattern.

Why this shape (investigated, not assumed)

  • The two repos' atp-indexers have diverged: this one additionally indexes ATP_FACTORY_MATP/LATP and has the zombie/withdrawing provider features (schema 478 vs 425 lines, actively maintained). They are not interchangeable — so each repo runs its own indexer code (own box), rather than sharing ignition's box.
  • They're effectively decoupled today: the custom indexer.*.stake.aztec.network alias is commented out in both; each frontend points at its own atp-indexer's raw CloudFront domain via remote state. Only ignition's shared infra state (WAF/secret/logs) is shared.
  • The frontend is static S3+CloudFront (already ~free), so it stays put — only the expensive indexer moves.

Contents

  • single-instance.tf — EC2 + EIP + persistent gp3 /data EBS + IAM (SSM/ECR) + SG + user_data.
  • templates/docker-compose.yml.tftpl (atp-indexer + local-postgres + caddy), Caddyfile.tftpl (both modes), user_data.sh.tftpl.
  • single-instance-cloudfront.tf — gated prod CloudFront-front (ACM us-east-1, http-only origin via atp-si-origin.<env> → EIP, secret-header gate).
  • README.md — deploy + cutover steps (repoint frontend indexer URL, then tear down old ECS/Aurora/ALB after parity; snapshot Aurora first).

Status / safety

  • terraform validate passes; Caddyfile rendering verified both modes (same template as ignition's, which was rendered-checked).
  • Additive (own state) — does not touch the existing atp-indexer/terraform stack. Not applied. Prod is a separate account; review + terraform plan there before applying.
  • Fleet teardown is a deliberate, documented cutover step (not auto-gated in this PR) to avoid a blind refactor of the existing 600-line app.tf.

🤖 Generated with Claude Code

Adam Domurad and others added 4 commits May 29, 2026 16:41
…ddy/CloudFront-front)

Collapses the atp-indexer's ECS+Aurora+ALB onto one EC2 box running THIS repo's atp-indexer
image (it indexes ATP_FACTORY_MATP/LATP etc. that ignition's does not -> not interchangeable)
against a local Postgres, fronted by Caddy: Caddy-direct (Let's Encrypt) for testnet, or
CloudFront-front (ACM + secret-header gate, http-only origin) for prod. Frontend stays on
S3+CloudFront. Mirrors the ignition single-instance pattern (repos are decoupled; intentional
duplication). Additive, own Terraform state; cutover documented in README. terraform validate
passes; not applied.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…output, cutover docs

Review workflow findings:
- BLOCKER: empty default cloudfront_secret_header_value + Caddy always enforcing the header
  in CF mode would lock out all requests. Add a precondition requiring it non-empty when
  si_front_with_cloudfront=true; clarify the variable description.
- Add mutual-exclusion precondition (si_create_dns_records XOR si_front_with_cloudfront).
- HIGH: add cf_domain_name output (alias) so the frontend's remote-state read keeps working
  at cutover without an output rename.
- Docs: README cutover now spells out the data.tf state-key swap + output name; env-var
  docs point at the full app.tf indexer_env_vars set (required vs tuning).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…refix list in CF mode

Same defense-in-depth as ignition: CF mode locks 80/443 to the CloudFront origin-facing
managed prefix list; Caddy-direct unchanged. SSM (egress) still works.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- BLOCKER: cf_domain_name output now defined in BOTH modes (was CF-only) -> testnet cutover
  no longer fails on a missing output; returns the indexer hostname in Caddy-direct mode.
- Remove superfluous API_PORT from the indexer container ('yarn start' serves the API on
  PORT; API_PORT is only for the separate 'yarn serve' which the box doesn't run).
- README cutover: clarify cf_domain_name in both modes + add the required frontend
  rebuild/redeploy step (indexer URL is baked at build time).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ludamad ludamad marked this pull request as ready for review May 29, 2026 22:11
@ludamad ludamad requested a review from a team as a code owner May 29, 2026 22:11
Adam Domurad and others added 2 commits May 29, 2026 18:18
…AF from shared state

Read the CloudFront secret (SSM) and CLOUDFRONT-scoped WAF from the shared
ignition-infrastructure state — the same ones the existing atp-indexer CloudFront uses — so a
prod CF-front deploy needs no manual secret/WAF inputs and matches the current posture. The
cloudfront_secret_header_value / si_cf_web_acl_arn vars remain as overrides; env_parent added
for the shared-state key. Precondition + Caddy gate now check the resolved secret.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… CloudFront mode

Add a precondition: when si_front_with_cloudfront=true the resolved CLOUDFRONT-scoped WAF
must be non-null (else a silent no-WAF CloudFront would defeat the security model). Points at
the shared backend_waf_arn / si_cf_web_acl_arn override.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

1 participant