Tech Interview RoomStudy guides

GCP

Explain GCP IAM and networking: resource hierarchy, service accounts, VPC, Shared VPC and Private Google Access.

Advanced · 2 min read · Lesson 6 of 6 in GCP

Resource hierarchy and IAM

  • Organisation → folders → projects → resources. IAM policies are inherited downwards, so grant broad roles high up sparingly and specific roles at project or resource level.
  • Roles: basic (Owner, Editor, Viewer: avoid in production), predefined (for example roles/cloudsql.client, roles/pubsub.subscriber) and custom roles.
  • Organisation policies are guardrails (disable service account key creation, restrict resource locations, require OS Login), comparable to AWS SCPs. IAM Deny policies and IAM Conditions add finer control.
  • Service accounts are workload identities. Attach them to Cloud Run services, VMs or (via Workload Identity) GKE pods; avoid downloadable keys and use Workload Identity Federation for external systems (GitHub Actions, AWS, on-premises).

Networking

  • A VPC is global; subnets are regional, so one VPC spans all regions without peering, unlike AWS where VPCs are regional.
  • Firewall rules and policies apply to instances by network tags or service accounts (stateful).
  • Shared VPC: a host project owns the network and subnets centrally (network team); service projects attach workloads to it (application teams). This is the standard enterprise pattern.
  • Private Google Access: VMs without external IPs can reach Google APIs. Private Service Connect gives private endpoints for Google APIs and published services. Cloud NAT for outbound internet from private instances.
  • Cloud Load Balancing: global external HTTP(S) load balancer with a single anycast IP, Cloud CDN and Cloud Armor (WAF and DDoS).
  • VPC Service Controls: a perimeter around managed services (BigQuery, Cloud Storage) to reduce data exfiltration risk.
Internet
Users
↓anycast HTTPS
Edge
Global external Application Load BalancerCloud Armor + Cloud CDN
↓serverless NEG or GKE backends
Compute
Cloud Run servicesGKE Autopilot workloads
↓private IP via Shared VPC
Data
Cloud SQL (private IP)Memorystore RedisPub/Sub

Follow-up questions interviewers ask

Try answering each one before you open it.

Why are service account keys considered risky?

They are long-lived credentials (JSON files) that are easily leaked through Git, images, laptops or CI logs, and they are hard to track and rotate. Anyone holding the file acts as that service account. Prefer attached service accounts, Workload Identity for GKE, Workload Identity Federation for external workloads, and short-lived impersonation tokens; enforce iam.disableServiceAccountKeyCreation with an organisation policy.