GCP Core Concepts
Understand GCP's fundamental concepts: projects, regions, IAM, APIs, and how they work together.
What you'll accomplish
Clear understanding of GCP architecture and how to organize resources
Prerequisites
- GCP account created
- gcloud CLI installed
GCP Resource Hierarchy
GCP organizes resources in a hierarchy:
Organization (optional)
└── Folders (optional)
└── Projects (required)
└── Resources (VMs, databases, etc.)
For personal projects, you typically just need a Project.
Projects
A Project is the fundamental organizing entity:
| Aspect | Description |
|---|---|
| Project ID | Globally unique identifier (cannot change) |
| Project Name | Human-readable name (can change) |
| Project Number | System-generated number |
| Billing | Each project links to a billing account |
| APIs | Each project enables its own APIs |
| IAM | Permissions are set at project level |
bash# List your projects gcloud projects list # Get project details gcloud projects describe my-project-id # Create a new project gcloud projects create my-new-project --name="My New Project"
Organizations (Enterprise)
For companies using Google Workspace or Cloud Identity:
- Central administration
- Policy inheritance
- Cross-project billing
Personal accounts don't have an Organization.
Regions and Zones
GCP infrastructure is distributed globally.
Regions
A Region is a geographic location (e.g., us-central1 = Iowa, USA).
Region: us-central1 (Iowa)
├── Zone: us-central1-a
├── Zone: us-central1-b
├── Zone: us-central1-c
└── Zone: us-central1-f
Zones
A Zone is an isolated location within a region. Different zones have independent power, cooling, and networking.
Choosing a Region
| Factor | Recommendation |
|---|---|
| Latency | Choose closest to your users |
| Price | US regions are typically cheapest |
| Compliance | Data residency requirements |
| Services | Not all services available everywhere |
Common Regions
| Region | Location | Notes |
|---|---|---|
us-central1 | Iowa | Cheapest, most services |
us-east1 | South Carolina | US East |
us-west1 | Oregon | US West |
europe-west1 | Belgium | GDPR-friendly |
asia-east1 | Taiwan | Asia Pacific |
Multi-Region
Some services support multi-region deployment:
us- All US regionseu- All EU regionsasia- All Asia regions
bash# Set default region gcloud config set compute/region us-central1 # List available regions gcloud compute regions list
APIs and Services
GCP services are accessed through APIs. Each API must be enabled per project.
How APIs Work
Your Code → API Call → GCP API Endpoint → GCP Service
Common APIs
| API | Service |
|---|---|
run.googleapis.com | Cloud Run |
compute.googleapis.com | Compute Engine |
storage.googleapis.com | Cloud Storage |
cloudbuild.googleapis.com | Cloud Build |
artifactregistry.googleapis.com | Artifact Registry |
sqladmin.googleapis.com | Cloud SQL |
secretmanager.googleapis.com | Secret Manager |
Managing APIs
bash# Enable an API gcloud services enable run.googleapis.com # Enable multiple APIs gcloud services enable \ run.googleapis.com \ cloudbuild.googleapis.com \ artifactregistry.googleapis.com # List enabled APIs gcloud services list --enabled # Disable an API (careful!) gcloud services disable run.googleapis.com
Identity and Access Management (IAM)
IAM controls who can do what with your resources.
The IAM Model
WHO (Principal) + WHAT (Role) + WHERE (Resource)
Example: "Alice can edit Cloud Run services in project my-app"
Principals (Who)
| Type | Format |
|---|---|
| Google Account | user:[email protected] |
| Service Account | serviceAccount:[email protected] |
| Google Group | group:[email protected] |
| Domain | domain:company.com |
| Everyone | allUsers or allAuthenticatedUsers |
Roles (What)
Primitive Roles (broad, legacy):
roles/owner- Full controlroles/editor- Edit everythingroles/viewer- Read-only
Predefined Roles (recommended):
roles/run.admin- Manage Cloud Runroles/run.invoker- Invoke Cloud Run servicesroles/storage.admin- Manage Cloud Storageroles/cloudsql.admin- Manage Cloud SQL
Custom Roles (fine-grained):
- Create your own with specific permissions
Managing IAM
bash# View project IAM policy gcloud projects get-iam-policy PROJECT_ID # Add a member to a role gcloud projects add-iam-policy-binding PROJECT_ID \ --member="user:[email protected]" \ --role="roles/run.admin" # Remove a member from a role gcloud projects remove-iam-policy-binding PROJECT_ID \ --member="user:[email protected]" \ --role="roles/run.admin"
Service Accounts
Service accounts are identities for applications (not humans).
Types
| Type | Use Case |
|---|---|
| Default | Auto-created for some services |
| User-managed | Created by you for specific purposes |
| Google-managed | Used internally by GCP |
Creating Service Accounts
bash# Create service account gcloud iam service-accounts create my-service-account \ --display-name="My Service Account" # Grant roles gcloud projects add-iam-policy-binding PROJECT_ID \ --member="serviceAccount:my-service-account@PROJECT_ID.iam.gserviceaccount.com" \ --role="roles/run.invoker" # Create key (for external use) gcloud iam service-accounts keys create key.json \ --iam-account=my-service-account@PROJECT_ID.iam.gserviceaccount.com
Note
Avoid creating keys when possible. Use Workload Identity Federation or attached service accounts instead.
Networking Basics
VPC (Virtual Private Cloud)
Every project has a default VPC with:
- Subnets in each region
- Default firewall rules
- Internet access
bash# List VPC networks gcloud compute networks list # List subnets gcloud compute networks subnets list
Firewall Rules
Control traffic to/from your resources:
bash# List firewall rules gcloud compute firewall-rules list # Create a rule (allow HTTP) gcloud compute firewall-rules create allow-http \ --allow=tcp:80 \ --target-tags=http-server \ --description="Allow HTTP traffic"
Cloud Run Networking
Cloud Run is serverless - networking is mostly handled for you:
- Ingress: Control who can access (all, internal, load balancer)
- Egress: Serverless VPC connector for private resources
Labels and Tags
Organize and track resources with labels.
Labels
Key-value pairs attached to resources:
bash# Add labels when creating gcloud run deploy my-service \ --image=gcr.io/PROJECT_ID/my-app \ --labels=env=production,team=backend # Update labels gcloud run services update my-service \ --update-labels=version=v2 # Filter by label gcloud run services list --filter="labels.env=production"
Common Label Patterns
env: production/staging/development
team: backend/frontend/data
app: myapp-name
cost-center: engineering
owner: [email protected]
Quotas and Limits
GCP enforces limits to prevent abuse and ensure fair usage.
Viewing Quotas
- Go to IAM & Admin → Quotas
- Filter by service
- View current usage vs limits
bash# View compute quotas gcloud compute project-info describe --format="json" | jq '.quotas'
Requesting Increases
- Go to IAM & Admin → Quotas
- Select the quota
- Click Edit Quotas
- Submit request with justification
Billing Concepts
Billing Accounts
A billing account is where charges are billed:
- Linked to payment method
- Can be used by multiple projects
- Managed separately from projects
bash# List billing accounts gcloud billing accounts list # Link project to billing account gcloud billing projects link PROJECT_ID \ --billing-account=BILLING_ACCOUNT_ID
Cost Breakdown
Typical costs:
- Compute - VMs, Cloud Run, Cloud Functions
- Storage - Cloud Storage, disks, databases
- Network - Egress (outbound) traffic
- APIs - Some APIs charge per call
Free Tier
GCP offers:
- $300 credit for 90 days (new accounts)
- Always Free tier (ongoing):
- Cloud Run: 2M requests/month
- Cloud Functions: 2M invocations/month
- Cloud Storage: 5GB
- And more...
Resource Naming
Naming Conventions
[company]-[project]-[env]-[resource-type]-[identifier]
Examples:
- acme-webapp-prod-vm-01
- myapp-staging-bucket
- api-service-prod
Rules
- Lowercase letters, numbers, hyphens
- Start with a letter
- No spaces or special characters
- Check specific service limits (length varies)
Putting It Together
A typical deployment uses multiple concepts:
Project: my-company-prod
├── IAM: [email protected] has roles/run.admin
├── Service Account: cloudrun-sa (for Cloud Run)
├── APIs Enabled:
│ ├── Cloud Run
│ ├── Artifact Registry
│ └── Cloud SQL
├── Region: us-central1
├── Resources:
│ ├── Cloud Run Service: api-service
│ ├── Cloud SQL: postgres-main
│ └── Artifact Registry: docker-images
└── Labels: env=production, team=backend
Note
Checkpoint: List your project's enabled APIs with gcloud services list --enabled and verify the key services are available.