On GCP using Terraform
Describes production grade infrastructure provisioning using Terraform on GCP cloud
This guide provisions a production-shaped Hyperswitch stack entirely on GCP, using Terraform modules composed with a Terragrunt Stack.
Architecture at a glance
Networking
VPC, Subnets, Cloud DNS, Cloud CDN, Proxies, NAT etc.,
Storage
AlloyDB, Memory Store, GCS
Compute
VM, GKE
Managed Resources
Cloud Monitoring, Armor, Cloud IAM, etc.,
The Terraform stack provision the GCP infrastructure. Argo CD then deploys the required applications on top of that infrastructure
Prerequisites
Install and authenticate, from official sources:
Step 1 — Define the Infra stack using Terragrunt/Terraform
Save the stack definition in the following path of your repository terraform/gcp/live:
bash
mkdir -p terraform/gcp/live
curl -o terraform/gcp/live/terragrunt.stack.hcl \
https://raw.githubusercontent.com/juspay/hyperswitch-suite/refs/heads/main/terraform/gcp/live/terragrunt.stack.hclYour file should look like below — update the values as per your finalized stack blueprint,which would have been done in finalising stack blueprint,
Step 2 — Generate & Bootstrap
The following step generates the terragrunt units required for the stack setup:
bash
Check the directory — you should see all the modules required for the hyperswitch stack in that folder.
Step 3 — Plan & Apply
Since modules are dependent on other modules, run terragrunt in phases, in the order below. Skip items based on your requirement.
Reply yes only when the plan shows creates and nothing else.
bash
Step 4 — Create the logical databases and their users
We have 4 applications, each needing its own database. Generate every password with openssl rand -base64 32:
hyperswitch-app
superposition
decision-engine
locker
Hyperswitch App
Fetch the Cloud SQL connection host from terragrunt output --working-dir alloydb, then connect. Get the postgres password from Secret Manager (Cloud SQL auto-generates and stores it there if you provisioned it that way, or set it explicitly in the module).
bash
sql
Database Schema Creation
bash
Cloud SQL note: for private-IP-only instances you'll typically connect via the Cloud SQL Auth Proxy or from within the VPC (e.g. the jump host) rather than a public endpoint — adjust
<host>accordingly.
Superposition
Fetch host from terragrunt output --working-dir application-stack/apps/superposition, then connect (same psql pattern as above).
sql
Database Schema Creation
bash
Locker
Fetch host from terragrunt output --working-dir application-stack/locker, then connect.
sql
Database Schema Creation
bash
Step 5 — Create secrets
Create the following secrets in Secret Manager and update the KMS-encrypted (Cloud KMS) sensitive data of each respective application there.
hyperswitch-app
prod_hyperswitch
recon
prod_hyperswitch-recon
revenue-recovery
prod_revenue-recovery
Step 6 — Validation
Output decides the validation. Exit code 0 = no changes, 1 = error, 2 = changes pending.
Last updated
Was this helpful?

