Architectural Rules and Report Audit Checklist
To ensure secure, resilient, and cost-effective multi-tier cloud deployments, enforce the following 9 architectural guards across solution design reports (assets/output-template.md) and Infrastructure as Code (assets/main.tf). Understanding the engineering rationale behind each rule enables accurate architectural decisions across diverse workloads:
- Ingress Bypass Defense (
internal-and-cloud-load-balancing):- Rule: Configure Tier 1 Frontend ingress to
INGRESS_TRAFFIC_INTERNAL_LOAD_BALANCER. - Why: If a public Cloud Run service uses default unrestricted ingress (
all), external clients can send HTTP requests directly to the default*.run.appURL, completely bypassing the external Application Load Balancer, SSL termination policies, and Cloud Armor WAF screening rules. Restricting ingress tointernal-and-cloud-load-balancingensures public traffic can only reach the container after passing through edge inspection.
- Rule: Configure Tier 1 Frontend ingress to
- VPC-Internal Backend Ingress (
INGRESS_TRAFFIC_INTERNAL_ONLY):- Rule: Configure internal application microservice tiers (T2..TN, e.g.,
backend_application) strictly toINGRESS_TRAFFIC_INTERNAL_ONLY. - Why: Internal business logic, data processing, and backend microservices should never be directly reachable from the public internet. Restricting ingress to
VPC-internalensures that these services reject any traffic originating outside the private network boundary, eliminating external attack surface.
- Rule: Configure internal application microservice tiers (T2..TN, e.g.,
- Direct VPC Egress (
vpc_access) & Cloud DNS (google_dns_managed_zone):- Rule: Attach
vpc_accessacross compute tiers (egress = "ALL_TRAFFIC"when calling internal*.run.appURLs). When Tier 1 usesALL_TRAFFICegress, deploy agoogle_dns_managed_zoneforrun.app.bound tovpc_networkwithgoogle_dns_record_setmapping*.run.appdirectly to Private Google Access VIPs (199.36.153.4/30 / 199.36.153.8/30). - Why: By default, public Google DNS resolves
*.run.apphostnames to public IPv4 virtual IP addresses (216.58.x.x). UnderALL_TRAFFICegress, packets sent from containers targeting216.58.x.xtraverse the VPC and hit default-deny (0.0.0.0/0) egress firewalls. Even when allowed outside the VPC, requests arriving from public VIPs are rejected by downstreamVPC-internal(INGRESS_TRAFFIC_INTERNAL_ONLY) ingress guards with HTTP 403 or 404 errors. Implementing a private Cloud DNS zone maps these hostnames inside the VPC to internal Private Google Access endpoints (199.36.153.x), allowing traffic to cleanly traverse the private backbone and preserve internal VPC sender identity.
- Rule: Attach
- Least-Privilege Cloud NGFW Egress Firewalls & Sidecar Cert Exchange (
443):- Rule: Enforce explicit Cloud NGFW global or regional network firewall policies (
google_compute_network_firewall_policy,google_compute_network_firewall_policy_association, andgoogle_compute_network_firewall_policy_rule) restricting outbound traffic precisely between tiers (deny 0.0.0.0/0,Frontend -> Backend 443/8080, andBackend -> Data Tier 5432/6379). For database egress (allow_backend_db_egress), permit TCP port443to Private Google Access VIPs (199.36.153.4/30, 199.36.153.8/30) in addition to TCP port5432(Cloud SQL PSC IP). - Why: Least-privilege egress policies prevent compromised containers from scanning internal networks or exfiltrating data to arbitrary external destinations. Authorizing TCP port
443to PGA VIPs alongside port5432is essential because when Cloud Run initializescloud_sql_instancevolumes (IAM Auth), the sidecar container queriessqladmin.googleapis.com(port443) and OAuth metadata endpoints across startup to exchange short-lived tokens for ephemeral client certificates; blocking this handshake under default-deny (deny 0.0.0.0/0) causes container initialization to crash.
- Rule: Enforce explicit Cloud NGFW global or regional network firewall policies (
- Firewall Policy Logging for Network Auditing:
- Rule: Enable
enable_logging = var.enable_monitoringon Cloud NGFW network firewall policy rules. - Why: Capturing connection metadata (source/destination IP, port, protocol, and allow/deny decisions) produces verifiable audit trails for security operations, SIEM integration, and troubleshooting zero-trust network policies during incident response.
- Rule: Enable
- Cloud CDN Edge Caching (
enable_cdn):- Rule: Enable
enable_cdn = trueon the global Application Load Balancer backend service (google_compute_backend_service). For European or regional data residency compliance using a regional Application Load Balancer (google_compute_region_backend_service), omit CDN, provision an explicit regional proxy-only subnet (purpose = "REGIONAL_MANAGED_PROXY"), specifynetworkon the regional forwarding rule (google_compute_forwarding_rule), and explain the residency trade-off. - Why: Caching static assets at Google's edge points-of-presence (
PoPs) significantly reduces latency for end users, lowers serverless container invocation frequency, and replaces higher Cloud Run data egress costs with lower Cloud CDN edge delivery rates.
- Rule: Enable
- Private Service Connect (
psc_enabled = true) & Private Redis (PSA):- Rule: Disable public IPs (
ipv4_enabled = false) on Cloud SQL instances and connect via Private Service Connect (psc_enabled = true,google_compute_forwarding_rule). Connect Memorystore for Redis via Private Services Access (connect_mode = "PRIVATE_SERVICE_ACCESS"overauthorized_network). - Why: Exposing relational databases or in-memory caches on public IPv4 addresses introduces unnecessary vulnerability to brute-force and DDoS attacks. Private Service Connect provisions localized endpoints directly inside the consumer VPC without
/16CIDR peering requirements or transitive routing risks, ensuring data storage remains 100% private.
- Rule: Disable public IPs (
- Cloud SQL Auth Proxy & IAM Database Auth (
DB_SOCKET_PATH):- Rule: Mount the built-in Cloud SQL Auth Proxy sidecar via
cloud_sql_instancevolumes (/cloudsql/project:region:instanceUnix domain socket) and enable IAM-based database authentication (cloudsql.iam_authentication = on,roles/cloudsql.client). When configuring database connection strings in application drivers, advise usingDB_SOCKET_PATH(/cloudsql/...Unix socket) over direct TCP (DB_PSC_ENDPOINT). - Why: Hardcoded database passwords risk credential leakage, require operational maintenance for frequent password rotation, and lack granular identity auditing. The built-in Auth Proxy sidecar handles transparent short-lived OAuth token exchange (
cloudsql.iam_authentication), automatic rotation, and mutual TLS encryption natively over Unix sockets without adding rotation logic or custom token handlers inside application code.
- Rule: Mount the built-in Cloud SQL Auth Proxy sidecar via
- Organization API Perimeter (
enable_vpc_sc):- Rule: Provide configuration variables (
enable_vpc_sc = true) and documentation for wrappingrun.googleapis.com,sqladmin.googleapis.com, andsecretmanager.googleapis.comwithin an Organization-level VPC Service Controls (VPC-SC) service perimeter. - Why: While network firewalls secure data-plane traffic (
TCP 5432), they do not restrict API management planes (sqladmin.googleapis.com). A VPC-SC service perimeter prevents cross-project data exfiltration—such as an attacker exporting database backups (sqladmin.instances.export) to an unauthorized external Cloud Storage bucket—even if legitimate IAM administrative credentials are used.
- Rule: Provide configuration variables (
Modular IaC Alignment and Best Practices
- Building Block Modules (
assets/main.tf): Base Tier 1 parameters precisely onSection 5.1("Tier 1 presentation tier: frontend reverse proxy") inassets/main.tfand Tiers 2..N onSection 5.2("Tier 2 application tier: private backend application") inassets/main.tf, ensuring appropriateroles/run.invokerbindings are granted directly between calling service account identities. - Terraform Best Practices (
general-style-structure): Adhere to Google Cloud HCL style guidelines including typed variables (type,description), unit-named numbers (memory_size_gb), positive boolean switches (enable_cdn), explicit outputs, and stateful deletion protection (deletion_protection = true).