Google Cloud Platform (GCP) Quick Reference
Goals
- Understanding GCP basics and architecture
- Using key services (Compute, Storage, Networking, Kubernetes)
- Leveraging Free Tier ($300 credit for 90 days + always free tier)
- Preparing for corporate GCP environments
- Combining with Terraform for Infrastructure as Code
Prerequisites
- Google Account (personal or workspace)
- GCP Free Trial: https://cloud.google.com/free
- Google Cloud SDK (
gcloud) installed - Basic Linux/bash knowledge
- Credit card (won't charge during trial, can set billing alerts)
4-WEEK LEARNING PLAN
Week 1: FUNDAMENTALS + COMPUTE + NETWORKING
Day 1-2: GCP Console + IAM + Cloud SDK
Why important: Identity and access management is foundational. GCP uses Projects for resource organization.
Exercises:
Create GCP Project
Understand IAM (Identity and Access Management)
Create Service Account
Assign IAM roles (Owner, Editor, Viewer)
Install and configure gcloud CLI
Enable Billing and set budget alerts
Understand resource hierarchy (Organization → Folder → Project)
Hands-on:
-
Create project:
-
Service Account (for automation):
# Create service account gcloud iam service-accounts create my-service-account \ --display-name="My Service Account" # Grant roles gcloud projects add-iam-policy-binding my-learning-project-12345 \ --member="serviceAccount:my-service-account@my-learning-project-12345.iam.gserviceaccount.com" \ --role="roles/compute.admin" # Create and download key gcloud iam service-accounts keys create ~/key.json \ --iam-account=my-service-account@my-learning-project-12345.iam.gserviceaccount.com -
Verify identity:
Key concepts: - Project: Isolated resource container (billing, quotas, permissions) - Service Account: Machine identity (for applications, automation) - IAM Role: Collection of permissions (Owner, Editor, Viewer, custom) - gcloud: Command-line tool for GCP
GCP IAM concepts used in companies: - Workload Identity (Kubernetes service accounts → GCP service accounts) - Organization policies - Least privilege access - Service account impersonation
Day 3-5: Compute Engine (GCE) - Virtual Machines
Why important: Fundamental compute service, equivalent to AWS EC2.
Exercises:
Create VM instance (e2-micro, Free Tier eligible)
SSH into instance
Configure firewall rules
Attach persistent disk
Create snapshot
Create custom image
Startup script (metadata)
Instance templates
Hands-on Project: Web Server on Compute Engine
-
Create VM instance:
gcloud compute instances create web-server \ --zone=us-central1-a \ --machine-type=e2-micro \ --image-family=ubuntu-2204-lts \ --image-project=ubuntu-os-cloud \ --boot-disk-size=10GB \ --tags=http-server,https-server \ --metadata=startup-script='#!/bin/bash apt-get update apt-get install -y nginx echo "<h1>Hello from GCP Compute Engine!</h1>" > /var/www/html/index.html systemctl start nginx systemctl enable nginx' -
Create firewall rule:
-
SSH into instance:
-
Get external IP and test:
-
Create snapshot:
Key concepts: - Machine Type: CPU/RAM configuration (e2-micro = 2 vCPUs, 1 GB RAM) - Image: OS template (Ubuntu, CentOS, Windows) - Persistent Disk: Block storage (standard, SSD) - Preemptible VM: Cheaper, but can be terminated (like AWS Spot) - Instance Group: Collection of VMs (managed or unmanaged)
GCE concepts used in companies: - Managed Instance Groups (MIG) for auto-scaling - Load balancers (regional, global) - Live migration (zero downtime maintenance) - Custom machine types
Day 6-7: VPC (Virtual Private Cloud) + Networking
Why important: Network isolation, critical for production environments.
Exercises:
Create custom VPC network
Create subnets (regional)
Configure firewall rules
Cloud NAT (for private instances)
VPC Peering
Cloud Router (dynamic routing)
Understand Shared VPC
Hands-on: Build Custom Network
VPC: my-custom-vpc
Subnet: web-subnet (us-central1, 10.0.1.0/24)
Firewall: Allow HTTP/HTTPS
Subnet: db-subnet (us-central1, 10.0.2.0/24)
Firewall: Allow internal traffic only
Commands:
# Create VPC
gcloud compute networks create my-custom-vpc \
--subnet-mode=custom
# Create subnets
gcloud compute networks subnets create web-subnet \
--network=my-custom-vpc \
--region=us-central1 \
--range=10.0.1.0/24
gcloud compute networks subnets create db-subnet \
--network=my-custom-vpc \
--region=us-central1 \
--range=10.0.2.0/24
# Firewall rule (allow HTTP)
gcloud compute firewall-rules create allow-http-custom \
--network=my-custom-vpc \
--allow=tcp:80,tcp:443 \
--source-ranges=0.0.0.0/0 \
--target-tags=web-server
# Cloud NAT (for private instances to reach internet)
gcloud compute routers create my-router \
--network=my-custom-vpc \
--region=us-central1
gcloud compute routers nats create my-nat \
--router=my-router \
--region=us-central1 \
--auto-allocate-nat-external-ips \
--nat-all-subnet-ip-ranges
Key concepts: - VPC: Isolated virtual network - Subnet: Regional IP range within VPC - Firewall Rules: Ingress/egress traffic control - Cloud NAT: Outbound internet access for private instances - VPC Peering: Connect two VPCs - Shared VPC: Multi-project network sharing
Week 2: STORAGE + DATABASE + CONTAINERS
Day 1-2: Cloud Storage (Object Storage)
Why important: GCP's equivalent to AWS S3. Used for backups, logs, artifacts.
Exercises:
Create Cloud Storage bucket
Upload/download files (gsutil)
Configure bucket lifecycle policies
Enable versioning
Set IAM permissions on bucket
Host static website
Signed URLs (temporary access)
Hands-on: Static Website on Cloud Storage
-
Create bucket:
-
Upload website:
-
Configure as website:
-
Make public:
-
Access:
-
Lifecycle policy (delete old objects):
Key concepts: - Bucket: Container for objects - Storage Classes: Standard, Nearline, Coldline, Archive - Lifecycle: Automatic deletion/archival - Versioning: Keep old versions of objects - Signed URL: Temporary access URL
Cloud Storage concepts used in companies: - Artifact storage (build outputs, container images) - Log aggregation - Data lake - Cross-region replication
Day 3-4: Cloud SQL (Managed Relational Database)
Why important: Managed MySQL, PostgreSQL, SQL Server. Used in production.
Exercises:
Create Cloud SQL instance (PostgreSQL/MySQL)
Configure authorized networks
Connect with Cloud SQL Proxy
Create database and tables
Configure automated backups
Create manual snapshot
Understand High Availability (HA) configuration
Hands-on: PostgreSQL on Cloud SQL
-
Create Cloud SQL instance:
-
Get connection info:
-
Connect using Cloud SQL Proxy:
-
Database operations:
-
Automated backups:
Key concepts: - Cloud SQL: Managed MySQL, PostgreSQL, SQL Server - HA configuration: Regional HA with automatic failover - Read replicas: Scale read operations - Cloud SQL Proxy: Secure connection without whitelisting IPs - Automated backups: Daily backups with point-in-time recovery
Day 5-7: Google Kubernetes Engine (GKE)
Why important: Managed Kubernetes, heavily used in enterprises. GCP's strength.
Exercises:
Create GKE cluster
Deploy containerized application
Expose service with LoadBalancer
Configure autoscaling (HPA, Cluster Autoscaler)
Rolling updates
Workload Identity (GKE → GCP service accounts)
Hands-on: Deploy Nginx on GKE
-
Create GKE cluster:
-
Get credentials:
-
Deploy application:
# nginx-deployment.yaml apiVersion: apps/v1 kind: Deployment metadata: name: nginx spec: replicas: 3 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:latest ports: - containerPort: 80 --- apiVersion: v1 kind: Service metadata: name: nginx spec: type: LoadBalancer selector: app: nginx ports: - protocol: TCP port: 80 targetPort: 80 -
Apply and access:
-
Horizontal Pod Autoscaler:
Key concepts: - GKE: Managed Kubernetes - Node Pool: Group of nodes with same configuration - Cluster Autoscaler: Add/remove nodes based on demand - HPA: Horizontal Pod Autoscaler (scale pods) - Workload Identity: Kubernetes SA → GCP service account - Autopilot: Fully managed GKE (GCP manages nodes)
GKE concepts used in companies: - Multi-cluster management - Service mesh (Anthos Service Mesh / Istio) - GitOps (ArgoCD, Flux) - Config Connector (manage GCP resources via Kubernetes)
Week 3: MONITORING + SECURITY + SERVERLESS
Day 1-2: Cloud Monitoring & Logging (formerly Stackdriver)
Why important: Unified monitoring and logging for GCP resources.
Exercises:
View metrics (CPU, memory, disk)
Create alerting policies
View logs in Cloud Logging
Create log-based metrics
Build custom dashboards
Set up uptime checks
Hands-on: Monitoring Setup
-
View Compute Engine metrics:
# List metrics gcloud monitoring metrics-descriptors list \ --filter="metric.type:compute.googleapis.com" # Query CPU utilization gcloud monitoring time-series list \ --filter='metric.type="compute.googleapis.com/instance/cpu/utilization"' \ --interval-start-time="2024-03-18T00:00:00Z" \ --interval-end-time="2024-03-18T23:59:59Z" -
Create alerting policy:
-
View logs:
-
Export logs to Cloud Storage:
Key concepts: - Cloud Monitoring: Metrics collection and alerting - Cloud Logging: Centralized log management - Log-based metrics: Create metrics from log entries - Uptime checks: Monitor endpoint availability - Notification channels: Email, SMS, Slack, PagerDuty
Day 3-4: Secret Manager + Cloud KMS
Why important: Secure secrets management and encryption key management.
Exercises:
Create secret in Secret Manager
Access secret from Compute Engine
Create encryption key in Cloud KMS
Encrypt/decrypt data with KMS
Configure IAM permissions for secrets
Hands-on: Database Password Management
-
Create secret:
-
Grant access to service account:
-
Access secret (from application):
-
Cloud KMS (encryption keys):
# Create keyring gcloud kms keyrings create my-keyring --location=global # Create key gcloud kms keys create my-key \ --location=global \ --keyring=my-keyring \ --purpose=encryption # Encrypt file gcloud kms encrypt \ --location=global \ --keyring=my-keyring \ --key=my-key \ --plaintext-file=secret.txt \ --ciphertext-file=secret.txt.enc
Key concepts: - Secret Manager: Store API keys, passwords, certificates - Cloud KMS: Encryption key management - Key rotation: Automatic key rotation - Envelope encryption: Data encrypted with DEK, DEK encrypted with KEK
Day 5-7: Cloud Functions (Serverless) + Cloud Run
Why important: Event-driven automation and serverless containers.
Exercises:
Create Cloud Function (HTTP trigger)
Cloud Storage trigger function
Pub/Sub trigger function
Deploy containerized app to Cloud Run
Cloud Run autoscaling
Cloud Scheduler (cron jobs)
Hands-on 1: Image Resize Function (Cloud Storage trigger)
-
Function code (Python):
# main.py from google.cloud import storage from PIL import Image import io def resize_image(event, context): """Triggered by Cloud Storage upload.""" bucket_name = event['bucket'] file_name = event['name'] if not file_name.startswith('uploads/'): return storage_client = storage.Client() bucket = storage_client.bucket(bucket_name) blob = bucket.blob(file_name) # Download image image_data = blob.download_as_bytes() image = Image.open(io.BytesIO(image_data)) # Resize image.thumbnail((200, 200)) # Upload thumbnail output = io.BytesIO() image.save(output, format='JPEG') output.seek(0) thumbnail_blob = bucket.blob(f'thumbnails/{file_name.split("/")[-1]}') thumbnail_blob.upload_from_file(output, content_type='image/jpeg') print(f'Resized {file_name}') -
Deploy function:
-
Test:
Hands-on 2: API on Cloud Run
-
Containerized app (Flask):
# app.py from flask import Flask, jsonify import os app = Flask(__name__) @app.route('/') def hello(): return jsonify({"message": "Hello from Cloud Run!"}) @app.route('/health') def health(): return jsonify({"status": "healthy"}) if __name__ == '__main__': app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 8080))) -
Dockerfile:
-
Build and deploy:
Key concepts: - Cloud Functions: Event-driven serverless functions - Cloud Run: Serverless containers (any language) - Pub/Sub: Asynchronous messaging - Cloud Scheduler: Cron jobs in the cloud - Eventarc: Event routing to Cloud Run
Week 4: ADVANCED + DATA + CI/CD
Day 1-2: BigQuery (Data Warehouse)
Why important: Serverless, highly scalable analytics database.
Exercises:
Create dataset
Load data from Cloud Storage
Run SQL queries
Partitioned tables
Scheduled queries
Data Studio visualization
Hands-on: Analyze Web Logs with BigQuery
-
Create dataset:
-
Load CSV data:
-
Query data:
-- Top 10 IPs by request count SELECT ip, COUNT(*) as requests FROM `PROJECT_ID.analytics.web_logs` GROUP BY ip ORDER BY requests DESC LIMIT 10; -- Error rate by hour SELECT EXTRACT(HOUR FROM timestamp) as hour, COUNTIF(status >= 400) / COUNT(*) * 100 as error_rate FROM `PROJECT_ID.analytics.web_logs` GROUP BY hour ORDER BY hour; -
Scheduled query:
Key concepts: - BigQuery: Serverless data warehouse - Partitioning: Improve query performance - Clustering: Optimize queries on specific columns - Streaming inserts: Real-time data ingestion - Data Studio: BI visualization tool
Day 3-4: Cloud Build + Artifact Registry (CI/CD)
Why important: Native CI/CD for GCP, container registry.
Exercises:
Create Artifact Registry repository
Push Docker image to Artifact Registry
Create Cloud Build trigger
Build Docker image with Cloud Build
Deploy to Cloud Run from Cloud Build
Multi-stage build pipeline
Hands-on: CI/CD Pipeline
-
Create Artifact Registry:
-
Cloud Build configuration (cloudbuild.yaml):
steps: # Build Docker image - name: 'gcr.io/cloud-builders/docker' args: ['build', '-t', 'us-central1-docker.pkg.dev/$PROJECT_ID/my-repo/my-app:$COMMIT_SHA', '.'] # Push to Artifact Registry - name: 'gcr.io/cloud-builders/docker' args: ['push', 'us-central1-docker.pkg.dev/$PROJECT_ID/my-repo/my-app:$COMMIT_SHA'] # Deploy to Cloud Run - name: 'gcr.io/google.com/cloudsdktool/cloud-sdk' entrypoint: gcloud args: - 'run' - 'deploy' - 'my-app' - '--image=us-central1-docker.pkg.dev/$PROJECT_ID/my-repo/my-app:$COMMIT_SHA' - '--region=us-central1' - '--platform=managed' images: - 'us-central1-docker.pkg.dev/$PROJECT_ID/my-repo/my-app:$COMMIT_SHA' -
Trigger build:
-
Automated trigger (GitHub):
Key concepts: - Cloud Build: Serverless CI/CD - Artifact Registry: Docker and language package repository - Build triggers: Automatic builds on Git push - Substitution variables: $PROJECT_ID, $COMMIT_SHA, $BRANCH_NAME
Day 5-7: Terraform + GCP (Infrastructure as Code)
Exercises:
Terraform GCP provider
Create VPC with Terraform
Deploy Compute Engine instances
Create Cloud Storage buckets
GKE cluster with Terraform
State management (Cloud Storage backend)
Hands-on: Terraform GCP
-
Provider configuration:
# main.tf terraform { required_providers { google = { source = "hashicorp/google" version = "~> 5.0" } } backend "gcs" { bucket = "my-terraform-state" prefix = "terraform/state" } } provider "google" { project = var.project_id region = var.region } variable "project_id" { description = "GCP Project ID" } variable "region" { default = "us-central1" } -
Create VPC and VM:
# network.tf resource "google_compute_network" "vpc" { name = "my-vpc" auto_create_subnetworks = false } resource "google_compute_subnetwork" "subnet" { name = "my-subnet" ip_cidr_range = "10.0.1.0/24" region = var.region network = google_compute_network.vpc.id } # compute.tf resource "google_compute_instance" "web" { name = "web-server" machine_type = "e2-micro" zone = "${var.region}-a" boot_disk { initialize_params { image = "ubuntu-os-cloud/ubuntu-2204-lts" } } network_interface { subnetwork = google_compute_subnetwork.subnet.id access_config {} } metadata_startup_script = file("startup.sh") tags = ["http-server"] } -
Deploy:
GCP Services Priority (For Corporate Environment)
| Priority | Service | Why important |
|---|---|---|
| ** HIGH** | IAM | Access management |
| ** HIGH** | Compute Engine | Virtual machines |
| ** HIGH** | VPC | Networking |
| ** HIGH** | GKE | Kubernetes (widely used) |
| ** HIGH** | Cloud Storage | Object storage |
| ** MEDIUM** | Cloud SQL | Managed databases |
| ** MEDIUM** | Cloud Monitoring/Logging | Observability |
| ** MEDIUM** | Secret Manager | Secrets management |
| ** MEDIUM** | Cloud Build | CI/CD |
| ** LOW** | Cloud Functions | Serverless automation |
| ** LOW** | BigQuery | Data analytics |
Learning Resources
Official GCP: - Free Tier: https://cloud.google.com/free - Documentation: https://cloud.google.com/docs - Architecture Center: https://cloud.google.com/architecture - Qwiklabs: https://www.qwiklabs.com/
Hands-on Labs: - Google Cloud Skills Boost: https://www.cloudskillsboost.google/ - Codelabs: https://codelabs.developers.google.com/ - GCP Free Tier: https://cloud.google.com/free
YouTube: - Google Cloud Tech (official) - GCP podcast - Fireship (GCP tutorials)
COST MANAGEMENT
Free Tier:
| Service | Free Tier | Duration |
|---|---|---|
| Trial Credit | $300 credit | 90 days |
| Compute Engine | 1 e2-micro instance/month | Always Free |
| Cloud Storage | 5 GB standard storage | Always Free |
| Cloud Functions | 2M invocations/month | Always Free |
| Cloud Run | 2M requests/month | Always Free |
| BigQuery | 1 TB queries/month | Always Free |
| Cloud Build | 120 build-minutes/day | Always Free |
Cost Protection:
-
Set budget alerts:
-
Monitor costs:
- Cloud Console → Billing → Cost Table
-
Enable cost breakdown by project/service
-
Clean up resources:
Weekly Checklist
Week 1:
- GCP project created
- gcloud CLI configured
- Service account created
- VM instance launched and accessed
- Custom VPC created
- Budget alert set
Week 2:
- Cloud Storage bucket created
- Static website hosted
- Cloud SQL instance created
- GKE cluster deployed
- Application running on GKE
Week 3:
- Cloud Monitoring dashboard created
- Alerting policy configured
- Secret Manager secret created
- Cloud Function deployed
- Cloud Run service deployed
Week 4:
- BigQuery dataset and queries
- Cloud Build pipeline created
- Artifact Registry repository
- Terraform configuration written
- Infrastructure deployed with Terraform
Ready? Start with Week 1, Day 1-2: IAM + Cloud SDK!