Skip to content

Comments

Automated indexer deployment with API endpoint under same domain#40

Open
koenmtb1 wants to merge 26 commits intomainfrom
km/automted-deployment
Open

Automated indexer deployment with API endpoint under same domain#40
koenmtb1 wants to merge 26 commits intomainfrom
km/automted-deployment

Conversation

@koenmtb1
Copy link

Summary

  • Add automated blue-green deployment for the Ponder indexer via two GitHub Actions workflows: one deploys to the slave color and exits, a cron (every 30 min) polls the new backend's sync status and switches over once ready
  • Route /api/* requests through the frontend CloudFront distribution (stake.aztec.network/api/*) to the live indexer origin, eliminating the need for a separate API domain and frontend redeployments on indexer switchovers
  • Add /api/sync-status endpoint that compares the indexer's max indexed block against the chain head, used by the cron to detect when re-indexing is complete
  • Replace the 404 custom_error_response with a CloudFront Function for SPA routing, since custom_error_response is distribution-wide and would swallow API 404s

How it works

  • Trigger Deploy Indexer (Blue-Green) workflow → deploys to the slave color (opposite of live), writes a pending switchover to S3, exits (~5 min)
  • Check Indexer Sync cron runs every 30 min → hits /api/sync-status on the slave's CloudFront → if synced, updates the indexerOrigin on the frontend CloudFront via AWS CLI, clears the pending state, and triggers a deploy to the old live so both end up updated
  • The frontend always hits /api/* on its own domain — CloudFront routes it to whichever indexer backend is live. No frontend redeploy needed for switchovers.

Setup
Run scripts/init-deployment-state.sh <environment> <live_color> once per environment to create the S3 state file before using the blue-green workflow.

@koenmtb1 koenmtb1 requested a review from a team February 19, 2026 11:50
@koenmtb1 koenmtb1 requested a review from a team as a code owner February 19, 2026 11:50
@koenmtb1 koenmtb1 requested a review from Maddiaa0 February 19, 2026 11:50
environment: [dev, staging, testnet, prod]
environment: ${{ matrix.environment }}
env:
STATE_BUCKET: aztec-token-sale-terraform-state
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may aswell be staking dashboard no?
prolly a good thing that this doesnt write to the same folder as the terraform managed bucket

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The terraform has historically used aztec-token-sale-terraform-state so leaving this as is for now. We can move the state if needed to a new name

name = "AWSManagedRulesBotControlRuleSet"
vendor_name = "AWS"

# Optionally exclude a URI prefix (e.g. /api/) from bot evaluation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure we need this if the rule has been disabled

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to allow teams to use the API programatically, without this it acts finicky when using curl or in code. Even with User-Agent set

Copy link
Member

@Maddiaa0 Maddiaa0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

over all looks good, theres some further cleanup we can do in following prs.

Something that need to be changed / tested

  • the buffer for falling behind is a bit too large
  • we no longer need to have two cloudfront dist's created for the backends.

# MIGRATION from single indexerOrigin: temporarily comment out the
# lifecycle block, apply, then uncomment. This lets Terraform replace
# the old single origin with the red/green origins + origin group.
# lifecycle {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think you might want to uncomment this - everything this runs it will bring the order back to what is defined here, not what is overwritten in the cli?

origin_id = "indexerOriginGroup"

failover_criteria {
status_codes = [502, 503, 504]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something to look out here for

  • even when the primary is switched, it will not respect app versions, might end up flopping between two different app versionos

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, kept that in mind, but felt like separate PR / issue.

@koenmtb1
Copy link
Author

  • we no longer need to have two cloudfront dist's created for the backends.

I'll make a separate issue for this, which can also include versioning the APIs

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.

2 participants