Rain/landing zone compliance - #269
Open
PamilerinId wants to merge 8 commits into
Open
Conversation
Adapts this fork to deploy into the governed rain-frontrunner project under the Rain landing zone, where org policies on the teams/ folder deny public Cloud SQL IPs and pin resource locations to africa-south1. Cloud SQL private IP (constraints/sql.restrictPublicIp): - postgresql: ipv4_enabled = false, private_network on the rain-vpc Shared VPC. Requires Private Service Access peering on the host VPC, provisioned by the landing zone (network-psa.tf). - cloud-run-service: add Direct VPC egress (PRIVATE_RANGES_ONLY). Cloud Run has no VPC path by default, so without this the service cannot reach the private IP at all. Gated on vpc_network so upstream behaviour is unchanged when it is null. - backend: Cloud SQL connector was hardcoded to IPTypes.PUBLIC in three places; all now PRIVATE. Migrations and runtime DB access would otherwise fail against a private-IP-only instance. Data residency (constraints/gcp.resourceLocations, POPIA): - dev.tfvars: gcp_region us-central1 -> africa-south1. API ownership: - Disable google_project_service.apis. The landing zone vends every API this app needs; two Terraform states managing services on one project drift against each other. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Deploys the app's Terraform into the governed rain-frontrunner project using Workload Identity Federation. GitHub mints a short-lived OIDC token, GCP STS exchanges it, and frontrunner-deploy is impersonated for the job — no service account key is created or stored, which is also required since constraints/iam.disableServiceAccountKeyCreation is enforced on the teams/ folder. The WIF provider pins trust to this repository via attribute_condition, so no other repo can mint a token for this identity. Plan runs on PRs and pushes touching infra/; apply is manual (workflow_dispatch) behind the production environment. Plan and apply share a job deliberately: a saved plan stores variable values in cleartext, db_password included, so it is never persisted as an artifact. State bucket is injected via -backend-config from repo variable TF_STATE_BUCKET; backend.tf still carries the upstream example bucket. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Fills every value derivable from the landing zone and the GitHub side: project rain-frontrunner-wkld-01, repo rainsouthafrica/poc-workload, branch main, and the custom-audience project entry. github_conn_name names a Cloud Build GitHub connection that must be created in the console first (Cloud Build > Repositories > Connect host); google_cloudbuildv2_repository takes it as parent_connection and Terraform cannot create it without a GitHub OAuth token in Secret Manager. GOOGLE_TOKEN_AUDIENCE / custom-audience OAuth web client IDs are left as placeholders — they come from the OAuth consent screen and cannot be derived. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Firebase auto-provisioned this client when the Google sign-in provider was enabled. It fills all four placeholders: backend/frontend custom_audiences (validated by Cloud Run at the edge) and the two GOOGLE_TOKEN_AUDIENCE env vars (re-validated in the app by auth_guard.verify_oauth2_token). Both layers must carry the identical client ID. Not a secret — an OAuth web client ID is public by design and ships in the frontend bundle. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Terraform auto-loads only terraform.tfvars and *.auto.tfvars. The environment config here is dev.tfvars, so without an explicit -var-file every root variable came through unset and plan failed with a wall of "No value for required variable". Filename is an env var so other environments can reuse the workflow. apply is unaffected: it consumes the saved plan, which already carries the variable values. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The Cloud Build GitHub App cannot be granted access to rainsouthafrica/poc-workload (no org admin), so google_cloudbuildv2_repository fails with "does not exist or is not accessible to the Cloud Build GitHub App". That connection feeds only the two push triggers, not the app itself: Cloud Run deploys a placeholder image (cloudrun/container/hello) and carries ignore_changes on the image, so the real image is expected to arrive out of band. Gating the repository and both triggers behind enable_cloudbuild_triggers therefore leaves a complete, working environment minus the automatic rebuild-on-push. Images are built and deployed with `gcloud builds submit`, which uploads local source and needs no GitHub link at all. Default stays true so upstream behaviour is unchanged; dev.tfvars sets false. Flip back to true once App access is granted. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
firebase.json hardcoded region us-central1 for the /api/** rewrite to Cloud Run. Only serviceId is templated by cloudbuild-deploy.yaml, so the region was never substituted and every API call would fail to resolve against a backend deployed in africa-south1 under the residency policy. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Firebase Hosting rewrites only support a fixed list of Cloud Run regions and africa-south1 is not among them: Cloud Run region `africa-south1` is not supported or not available: could not find stub for "africa-south1" Moving the backend to a supported region would violate the residency policy on teams/, so the /api/** rewrite is removed and the browser calls the Cloud Run URL directly instead. The backend already sets CORS_ORIGINS to the Firebase Hosting origin, so cross-origin calls are permitted. Deployments must now pass the Cloud Run service URL as _BACKEND_URL rather than the .web.app domain. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Fixes #<issue_number_goes_here>