-
Notifications
You must be signed in to change notification settings - Fork 0
feat(infra): add Cloud SQL with VPC peering for preview environments #126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
msantoroks
commented
Dec 8, 2025
- Manage Cloud SQL instances for dev and prod (preview uses dev via peering)
- Auto-generate passwords and store in Secret Manager
- Configure minimal resources for testing
- Implement bidirectional VPC peering between preview and dev
- Organize VPC peering configuration in vpc.tf
- Manage Cloud SQL instances for dev and prod (preview uses dev via peering) - Auto-generate passwords and store in Secret Manager - Configure minimal resources for testing - Implement bidirectional VPC peering between preview and dev - Organize VPC peering configuration in vpc.tf
- Dev: db-custom-2-3840 (2 vCPUs, 3.75GB RAM, 50GB storage) - Prod: db-custom-4-7680 (4 vCPUs, 7.5GB RAM, 100GB storage) - Enable backups, PITR, and deletion protection for prod
Preview Deployment CompleteInfrastructure deployed to preview-pr-126 environment. Access URLs
Note: Custom domain not configured for preview environments. Use Cloud Run URL to access the application. |
Preview Deployment CompleteInfrastructure deployed to preview-pr-126 environment. Access URLs
Note: Custom domain not configured for preview environments. Use Cloud Run URL to access the application. |
| # Reverse peering from dev to preview environments | ||
| # This completes the bidirectional peering connection | ||
| resource "google_compute_network_peering" "dev_to_preview" { | ||
| for_each = var.environment == "dev" ? var.preview_vpc_names : toset([]) | ||
| name = "dev-to-preview-peering-${replace(each.value, "labs-asp-vpc-", "")}" | ||
| network = google_compute_network.main.id | ||
| peer_network = data.google_compute_network.preview_vpcs[each.value].id | ||
|
|
||
| import_custom_routes = true | ||
| export_custom_routes = true | ||
|
|
||
| depends_on = [ | ||
| google_compute_network.main, | ||
| google_service_networking_connection.private_vpc_connection | ||
| ] | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not clear why you are using VPC peering at all. Can't the Cloud SQL instance authorize a specific CIDR ranges. Since preview uses 10.1.0.0/16, why not just add that to the Cloud SQL's authorized networks?
With the current setup I think we would have to manage the dev->preview VPC connection as well right?
I might be a bit ignorant here, anything you can share about why bidirectional VPC peering is a good idea might help me understand better.