Enterprise Infrastructure · Google Cloud Platform

GCP Security
Architecture

A comprehensive security framework for multi-tenant SaaS infrastructure — covering encryption, identity, network isolation, GDPR compliance, and incident response across Google Cloud Platform.

256 AES Encryption
7 Security Layers
100% TLS in Transit
0 Public DB Access
🛡️

// 01 · DEFENCE IN DEPTH

7-Layer Security Architecture

Every component is protected by multiple independent security controls — no single point of failure.

🌐
LAYER 01
Network Perimeter · Cloud Armor & CDN
+
Cloud Armor WAF

Web Application Firewall with pre-configured rulesets blocking OWASP Top 10 threats including SQLi, XSS, RFI, and LFI. Rate limiting enforced per IP with adaptive protection enabled.

DDoS Mitigation

Google's global anycast network absorbs volumetric attacks at the edge. Cloud Armor adaptive protection uses ML to detect and block application-layer DDoS in real time.

TLS Termination

All traffic terminated at Google's edge with TLS 1.3. Certificates auto-provisioned and rotated via Google-managed SSL. HSTS enforced with 1-year max-age.

IP Allowlisting

Admin APIs restricted to allowlisted CIDR ranges. Cloud Armor security policies enforce geographic restrictions and block known malicious IP ranges.

🔒
LAYER 02
Identity & Access Management · IAM + RBAC
+
Principle of Least Privilege

Every service account granted minimum required permissions only. Cloud Run services, Cloud Build, and Cloud SQL use dedicated service accounts with scoped IAM roles — no wildcard permissions.

Service Account Isolation

Each Cloud Run service runs under a dedicated service account. Cross-service communication requires explicit IAM bindings — no shared credentials, no ambient authority.

Workload Identity

Kubernetes Workload Identity Federation used for GKE workloads, eliminating the need for service account key files. Short-lived tokens only — no long-lived credentials.

Admin Access Controls

Console access requires 2FA/MFA. Organisation-level IAM policies enforced via Resource Manager. All privilege escalations logged in Cloud Audit Logs with alerts.

🏗️
LAYER 03
VPC Network Isolation · Private Connectivity
+
VPC Architecture

Dedicated VPC with custom subnet design — application tier, data tier, and management tier separated into distinct subnets with strict firewall rules controlling east-west traffic.

Private Service Connect

Cloud SQL accessed exclusively via Private Service Connect — no public IP. Cloud Run connects to Cloud SQL via Cloud SQL Auth Proxy over private networking, never over public internet.

VPC Service Controls

Security perimeters defined around GCP projects — preventing data exfiltration via API abuse. Cloud Storage, BigQuery, and Cloud SQL enclosed in service perimeters.

Serverless VPC Connector

Cloud Run services connected to VPC via Serverless VPC Access connector — all outbound traffic routed through private network. No direct internet egress from application services.

🗄️
LAYER 04
Data Security · Encryption + Secret Manager
+
Encryption at Rest

All Cloud SQL data encrypted using AES-256 with Google-managed encryption keys. Customer-Managed Encryption Keys (CMEK) available via Cloud KMS for sensitive workloads.

Secret Manager

All secrets — database credentials, API keys, JWT secrets, third-party tokens — stored exclusively in GCP Secret Manager. Secrets accessed at runtime only; never hardcoded or in environment variable plaintext.

Database Isolation (RLS)

Multi-tenant data separated via per-client PostgreSQL schemas with Row-Level Security policies. Application-level tenant context enforced at connection — cross-tenant queries structurally impossible.

Backup Encryption

Automated Cloud SQL backups encrypted with same AES-256 standard. Point-in-time recovery enabled with 7-day retention. Backups stored in geographically separate region.

📦
LAYER 05
Container Security · Cloud Run + Container Registry
+
Container Scanning

Artifact Registry with automated vulnerability scanning on every push. Critical and High CVEs block deployment via Cloud Build approval gates. Base images pinned to specific SHA digests.

Binary Authorization

Cloud Run enforces Binary Authorization policies — only images signed by trusted Cloud Build attestors can be deployed. Unsigned or unverified images are rejected at deploy time.

Minimal Base Images

All containers built on minimal Alpine Linux base images — reducing attack surface. No shell access, no package managers, no unnecessary tooling in production images.

Immutable Infrastructure

Cloud Run revisions are immutable — deployed containers never patched in place. Rollbacks achieved by routing traffic to a previous revision, not by modifying running containers.

📋
LAYER 06
Audit & Observability · Logging + Monitoring
+
Cloud Audit Logs

Admin Activity, Data Access, and System Event logs enabled across all GCP services. Logs immutable — exported to Cloud Storage for 90-day retention with tamper-evident signatures.

Security Command Center

GCP Security Command Center continuously scans for misconfigurations, IAM anomalies, exposed services, and compliance violations. Findings surfaced with remediation guidance.

Cloud Monitoring Alerts

Real-time alerting on failed authentication attempts, unusual API activity, database connection spikes, and Secret Manager access from unexpected identities.

Log-based Metrics

Custom log-based metrics track security events — privilege escalations, denied requests, unusual data volumes. Dashboards in Cloud Monitoring with PagerDuty integration.

LAYER 07
Application Security · OWASP + Input Validation
+
Input Validation

Server-side validation on all API inputs — type checking, length limits, format validation, and sanitisation. SQLAlchemy ORM used throughout — parameterised queries prevent SQL injection structurally.

JWT Authentication

Stateless JWT tokens with RS256 signing, short expiry windows (15 min access, 7 day refresh), and token rotation on refresh. Tokens validated on every request — no session state server-side.

CORS Policy

Strict CORS configuration — only approved origins accepted. Preflight requests validated. No wildcard origins in production. Headers include Content-Security-Policy, X-Frame-Options, and Referrer-Policy.

Rate Limiting

API rate limiting enforced at both Cloud Armor (edge) and application (middleware) layers. Per-tenant rate limits prevent noisy-neighbour abuse. Exponential backoff enforced on failed auth.


// 02 · SECURITY CONTROLS

Core Security Controls

Key technical controls implemented across the infrastructure stack.

🔐

Secret Manager

All credentials, API keys, database passwords, and third-party tokens stored in GCP Secret Manager. Secrets versioned, audited, and accessed via IAM-controlled service accounts at runtime only.

AES-256 Versioned Audit Logged
🌐

VPC Private Connectivity

Cloud SQL has no public IP. All database connections route via Cloud SQL Auth Proxy over private VPC. Zero database exposure to public internet — connection strings never leave GCP infrastructure.

Private IP Only Auth Proxy VPC Peering
🏛️

Row-Level Security

PostgreSQL RLS policies enforce tenant isolation at the database level. Even if application-layer tenant routing fails, the database engine itself rejects cross-tenant data access.

Per-Schema RLS Policies Structural
📊

Cloud Audit Logs

Immutable audit trail across all GCP services — Admin Activity, Data Access, and System Events. 90-day retention exported to Cloud Storage. Tampering structurally prevented by Google's logging infrastructure.

Immutable 90-Day Retention Real-Time
🧱

Cloud Armor WAF

Web Application Firewall protecting against OWASP Top 10 — SQL injection, XSS, CSRF, RFI, and LFI. Adaptive ML-based DDoS protection with rate limiting and geo-restriction capabilities.

OWASP Top 10 DDoS Rate Limiting
📦

Container Hardening

Minimal Alpine base images, no root execution, read-only filesystems, Binary Authorization enforcement. Container images scanned on every build — CVE blocking gates prevent vulnerable images reaching production.

Alpine Linux No Root CVE Scanning

// 03 · ENCRYPTION

Data Encryption Pipeline

End-to-end encryption across every stage — from client browser to database storage.

💻
Client
HTTPS / TLS 1.3
Browser → Edge
🛡️
Edge
Cloud Armor
WAF + DDoS filter
📦
Application
Cloud Run
JWT validation
🔌
Proxy
Auth Proxy
IAM-authenticated
🗄️
Database
AES-256 at rest
Cloud SQL · Private IP

security-audit.sh — cloud-shell
$gcloud sql instances describe prod-db --format="value(settings.ipConfiguration)"
ipv4Enabled: false
privateNetwork: projects/ai-fix-pro-website/global/networks/default
✓ No public IP assigned — private connectivity only

$gcloud secrets list --format="table(name,replication)"
DB_PASSWORD automatic
JWT_SECRET automatic
TWILIO_AUTH_TOKEN automatic
✓ All secrets stored in Secret Manager — no plaintext credentials

$gcloud run services describe rahul-portfolio --region=europe-west2 --format="value(spec.template.spec.containers[0].securityContext)"
✓ runAsNonRoot: true
✓ readOnlyRootFilesystem: true
$

// 04 · IDENTITY & ACCESS

IAM Access Control Flow

Every request authenticated and authorised through multiple independent checkpoints.

👤
User / Service
Authenticated Identity
OAuth 2.0
+ MFA
🔑
IAM Policy
Role binding check
Scoped
Permission
🗄️
Resource
Cloud SQL / Run / GCS

Role / Service Account Permissions Granted Scope Status
cloud-run-sa@ cloudsql.client, secretmanager.accessor Project Active
cloud-build-sa@ run.developer, artifactregistry.writer Project Active
monitoring-sa@ monitoring.viewer, logging.viewer Project Active
Developer Access viewer + limited editor, no secret access Restricted MFA Required
Public / Unauthenticated Cloud Run invoke (frontend only) Service Frontend Only

// 05 · COMPLIANCE

GDPR & Data Governance

Compliance controls for data handling, retention, and subject rights.

Data Minimisation Only data strictly necessary for the service is collected and processed. No third-party analytics or tracking scripts on any internal platform.
Data Subject Rights (DSR) Right to access, rectification, erasure, and portability supported. DSR requests can be fulfilled within 72 hours via database-level operations on per-client schemas.
Data Residency All data stored in GCP europe-west2 (London) region. No data transferred outside UK/EEA without explicit consent and appropriate safeguards.
Encryption Standard Personal data encrypted at rest with AES-256 and in transit with TLS 1.3. Encryption keys managed by Google Cloud KMS with audit logging on all key access.
Retention & Deletion Automated data retention policies enforced at the database level. Tenant offboarding triggers schema-level deletion — no residual data remains after confirmed deletion.
Breach Notification Security Command Center alerts enable detection within hours. Documented incident response procedure ensures regulatory notification within the required 72-hour window.
Processor Agreements Google Cloud operates under a GDPR-compliant Data Processing Agreement. All sub-processors documented and reviewed annually for compliance posture.
Audit Trail All access to personal data captured in Cloud Audit Logs. Immutable audit trail available for regulatory review. Log integrity verified via cryptographic signatures.

// 06 · MULTI-TENANT ISOLATION

Tenant Isolation Architecture

Multiple isolation layers ensure complete data separation between tenants — from network to database.

// GCP · europe-west2 · Cloud SQL · PostgreSQL

Per-Client Schema Isolation with Row-Level Security

Layer 1 · Network — Cloud Run Services (per tenant)
Tenant A
Cloud Run Service
Isolated Container
Tenant B
Cloud Run Service
Isolated Container
Tenant C
Cloud Run Service
Isolated Container
Layer 2 · Database — Per-Client Schemas
Schema A
Completely Isolated
RLS Enforced
Schema B
Completely Isolated
RLS Enforced
Schema C
Completely Isolated
RLS Enforced
Shared Lookups
Read-Only Reference
No PII
Layer 3 · Security — Enforcement Controls
PostgreSQL RLS
Database-level enforcement
Structural
App-Level Routing
Tenant context injection
Application
Connection Pool
Per-tenant pool isolation
Network
Audit Logging
Cross-tenant detection
Monitoring

// 07 · INCIDENT RESPONSE

Security Incident Response

Documented 5-phase incident response procedure aligned with GDPR 72-hour notification requirements.

Phase 01 · T+0
Detection & Triage
Security Command Center alert triggers PagerDuty notification. On-call engineer triages within 15 minutes. Incident severity classified (P1-P4) and incident channel opened.
Phase 02 · T+1hr
Containment
Affected Cloud Run services isolated via IAM deny policies. Compromised service accounts revoked. Cloud SQL connections terminated for affected tenants. Traffic rerouted.
Phase 03 · T+4hr
Investigation
Cloud Audit Logs and VPC Flow Logs reviewed to establish blast radius. Affected data identified. Root cause analysis initiated. Evidence preserved for forensic review.
Phase 04 · T+24hr
Remediation
Patch deployed via Cloud Build pipeline. Affected credentials rotated in Secret Manager. Security controls updated to prevent recurrence. Penetration test scheduled.
Phase 05 · T+72hr
Notification & Review
GDPR regulatory notification filed if personal data involved. Affected clients notified. Post-incident review conducted. Security runbook updated with lessons learned.
incident-response.sh
⚠ ALERT: Unusual API access pattern detected
⚠ Source: 185.220.101.x — not in allowlist

$./contain.sh --revoke-sa cloud-run-sa@
✓ Service account revoked

$gcloud sql connect prod-db --terminate-all
✓ All connections terminated

$./rotate-secrets.sh --all
Rotating DB_PASSWORD...
Rotating JWT_SECRET...
✓ All secrets rotated in Secret Manager

$./notify-gdpr.sh --72hr-window
✓ Regulatory notification prepared
$