The Four Phases
You MUST complete each phase before proceeding to the next.
Phase 1: Architecture & Security (The Blueprint)
BEFORE writing a single line of YAML or Terraform:
Define the Topology
- Draw the network diagram (VPCs, Subnets, Firewalls).
- Where does the data live? Is it public or private?
- Rule: nothing talks to the internet unless explicitly required. Default to private.
Identity & Access Management (IAM)
- Define "Who" needs access to "What."
- Principle of Least Privilege: A build service should not have Admin access.
- No Hardcoded Secrets: Plan where keys/passwords live (Secret Manager, Vault).
Cost Estimation
- Check the pricing calculator.
- Set up Budget Alerts before deploying resources.
- Avoid "Cloud Shock" by defining retention policies (logs, backups) now.
Phase 1.5: FinOps & Cost Optimization (2026)
Cloud costs are the #2 startup killer (after running out of customers):
Tagging Strategy (Cost Accountability)
- Required Tags: environment, team, project, cost-center
- Enable: Cost allocation reports, blame tracking
- Enforcement: Tag policies (reject untagged resources)
resource "google_storage_bucket" "data" {
labels = {
environment = var.environment
team = "data-platform"
project = "analytics"
}
}
Right-Sizing & Committed Use
- Spot/Preemptible Instances: 60-90% cheaper for fault-tolerant workloads
- Reserved Instances: 1-3 year commit for predictable loads (40-60% savings)
- Savings Plans: Flexible commitment (AWS/Azure)
- Auto-scaling: Scale down aggressively (nights, weekends)
- Tool: Infracost (estimate before deploy), Kubecost (k8s)
Cost Alerts & Anomaly Detection
- Budget Alerts: 50%, 80%, 100%, 120% thresholds
- Per-Service Budgets: Separate for Compute, Storage, Network
- Anomaly Detection: Alert on 2x daily average
- Example: "BigQuery cost is 10x higher today vs yesterday"
Storage Lifecycle Policies
- Hot → Warm → Cold → Archive
- S3: Standard → IA → Glacier → Deep Archive
- GCS: Standard → Nearline → Coldline → Archive
- Auto-delete: Logs after 90 days, temp files after 7 days
- Savings: 50-90% on storage costs
Phase 2: Infrastructure as Code (IaC)
Treat infrastructure like software:
Codify Resources (Terraform/OpenTofu)
- Rule: Never click in the Console to create production resources ("ClickOps").
- Use Modules for repeatable patterns (e.g., a standard bucket configuration).
- Store state remotely and lock it (e.g., GCS bucket with state locking).
Immutability Strategy
- Don't SSH into servers to patch them.
- Plan to replace infrastructure, not repair it ("Cattle, not Pets").
- Define your container strategy (Dockerfiles, Base Images).
Environment Parity
- Staging should look like Production (just smaller).
- Use variables to handle differences, not different logic.
- Goal: If it works in Staging, it works in Prod.
Phase 2.5: GitOps & Modern Deployment
The infrastructure deployment evolution:
GitOps Pattern
- Git as Source of Truth: Desired state lives in Git
- Pull-Based Deployment: Cluster pulls config (vs push)
- Auto-Sync: Changes to Git automatically deploy
- Tools: ArgoCD (k8s), Flux, Atlantis (Terraform)
- Benefits: Audit trail, easy rollback, no CI/CD credentials in cluster
Drift Detection
- Problem: Someone clicks in console, state diverges from Git
- Solution: Automated drift detection + alerts
- terraform plan in CI/CD on schedule
- ArgoCD: Visual diff of desired vs actual state
Progressive Delivery
- Blue/Green: Deploy new version, switch traffic instantly
- Canary: Route 5% → 25% → 100% traffic gradually
- Feature Flags: Enable features for subset of users
- Tools: Flagger (k8s), LaunchDarkly, Split.io
Phase 3: The Pipeline (CI/CD)
Automate the factory:
Continuous Integration (CI)
- Lint the code (TFSec, Hadolint).
- Run unit tests.
- Build the artifact (Container Image, Binary).
- Rule: The build fails if the tests fail. No exceptions.
Continuous Deployment (CD)
- Automate the rollout.
- Gatekeeping: Require approval for Prod deployment?
- Strategy: Blue/Green? Canary? Rolling Update? Choose one to minimize downtime.
Rollback Strategy
- "Break Glass" procedure: How do we undo the last deploy instantly?
- Test the rollback mechanism. A rollback that fails is an outage.
Phase 4: Observability & Reliability (SRE)
Flying the plane:
Logging & Tracing
- Centralize logs (don't leave them on the instance).
- Ensure logs are structured (JSON) so they can be queried.
- Correlate logs across services (Trace ID).
Metrics & Alerting
- The Golden Signals: Latency, Traffic, Errors, Saturation.
- Alert on symptoms (User sees 500 error), not just causes (CPU high).
- Rule: If an alert wakes you up, it must be actionable. If not, delete the alert.
Disaster Recovery (DR)
- Automate backups.
- Crucial: Test the Restore. A backup you haven't restored is just a file you hope works.
Red Flags - STOP and Follow Process
If you catch yourself thinking:
- "I'll just change this firewall rule in the console quickly to test."
- "I'll hardcode the API key just for this commit."
- "I'll write the Terraform import later."
- "It works on my laptop, just ship the container."
- "We don't need logs for this service."
- "I'll ssh in and restart the service manually."
- Using
admin or owner permissions for a service account.
ALL of these mean: STOP. Return to Phase 1/2.
Your Human Partner's Signals You're Doing It Wrong
Watch for these complaints:
- Dev: "The build takes 20 minutes." (Your pipeline is bloated).
- PM: "Why did Staging break?" (You lacked Environment Parity).
- Sec: "Why is port 22 open to the world?" (You failed Phase 1).
- Fin: "Why is the bill 3x higher this month?" (You failed Cost Estimation).
- Dev: "I can't debug this without SSH." (You failed Observability).
When you see these: STOP. Fix the platform/process.
Common Rationalizations
| Excuse |
Reality |
| "ClickOps is faster for prototyping" |
It creates "Configuration Drift" instantly. |
| "We'll secure the bucket later" |
You will be hacked/scraped before "later" comes. |
| "I don't need a budget alert" |
One infinite loop can cost $10k overnight. |
| "Terraform is too complex for this" |
Manual maintenance is infinitely more complex over time. |
| "I'll document the manual steps" |
Docs get outdated. Code (IaC) is the documentation. |
| "Logs are too expensive" |
Downtime is more expensive. Sample/filter them. |
Quick Reference
| Phase |
Key Activities |
Success Criteria |
| 1. Architecture |
Topology, IAM, Cost |
Secure design, Budget set |
| 2. IaC |
Terraform, Docker, State |
Reproducible infra, No manual clicks |
| 3. Pipeline |
Lint, Build, Test, Deploy |
Automated flow from Git to Prod |
| 4. Observability |
Golden Signals, Logs, Backups |
You know it's broken before users do |
When Process Reveals "Legacy Drift"
When you inherit a project built via "ClickOps" (manual console work):
- Don't nuke it.
- Audit: Use tools (like
terraformer or gcp-export) to read the current state.
- Import: Systematically import resources into Terraform state.
- Lock Down: Once imported, remove write access to the Console to force usage of the pipeline.
Supporting Techniques
superpowers:infrastructure-as-code - Writing clean Terraform modules.
superpowers:container-security - Scanning images for vulnerabilities.
superpowers:post-mortem - Learning from outages (Blameless RCA).
Real-World Impact
- "SysAdmin" Approach: Manual servers, "it works on my machine," fear of Friday deploys, 3 AM wake-up calls.
- "DevOps" Approach: Immutable infrastructure, automated pipelines, deploys on Friday at 4 PM without sweating, sleeping through the night.
🛠️ Modern Platform Stack (2026)
Infrastructure as Code
- Terraform/OpenTofu: Multi-cloud IaC
- Pulumi: Code-native IaC (TypeScript, Python, Go)
- CDK (AWS/GCP): Cloud-native IaC
Container Orchestration
- Kubernetes: Industry standard (GKE, EKS, AKS)
- Nomad: Simpler alternative (HashiCorp)
- Cloud Run / Fargate: Serverless containers
GitOps
- ArgoCD: Kubernetes deployments
- Flux: CNCF GitOps
- Atlantis: Terraform pull requests
Serverless
- Functions: AWS Lambda, Cloud Functions, Cloudflare Workers
- Edge Compute: Cloudflare Workers (ms latency globally)
- Containers: Cloud Run, Fargate, Fly.io
Observability
- OpenTelemetry: Unified standard
- Platforms: Datadog, Grafana Cloud, New Relic
- Logs: Loki, CloudWatch, Mezmo
- Metrics: Prometheus, VictoriaMetrics
CI/CD
- GitHub Actions: Popular, integrated
- GitLab CI: Full DevOps platform
- CircleCI / Buildkite: Specialized
💰 FinOps Best Practices
Cost Optimization Checklist
Cost Monitoring Dashboard
| Metric |
Alert Threshold |
Why |
| Daily spend |
2x 7-day average |
Detect runaway costs |
| Per-service budget |
80% of monthly |
Prevent overruns |
| Egress traffic |
10% increase |
Network costs spike |
| Storage growth |
20% month-over-month |
Lifecycle policies failing |
| Idle resources |
> 7 days unused |
Wasted spend |
1---2name: platform-engineer3description: Platform Engineer Skill4---5## The Four Phases67You MUST complete each phase before proceeding to the next.89### Phase 1: Architecture & Security (The Blueprint)1011**BEFORE writing a single line of YAML or Terraform:**12131. **Define the Topology**14 - Draw the network diagram (VPCs, Subnets, Firewalls).15 - Where does the data live? Is it public or private?16 - **Rule:** nothing talks to the internet unless explicitly required. Default to private.17182. **Identity & Access Management (IAM)**19 - Define "Who" needs access to "What."20 - **Principle of Least Privilege:** A build service should not have Admin access.21 - **No Hardcoded Secrets:** Plan where keys/passwords live (Secret Manager, Vault).22233. **Cost Estimation**24 - Check the pricing calculator.25 - Set up Budget Alerts *before* deploying resources.26 - Avoid "Cloud Shock" by defining retention policies (logs, backups) now.2728### Phase 1.5: FinOps & Cost Optimization (2026)2930**Cloud costs are the #2 startup killer (after running out of customers):**31321. **Tagging Strategy (Cost Accountability)**33 - **Required Tags:** environment, team, project, cost-center34 - **Enable:** Cost allocation reports, blame tracking35 - **Enforcement:** Tag policies (reject untagged resources)36 ```terraform37 resource "google_storage_bucket" "data" {38 labels = {39 environment = var.environment40 team = "data-platform"41 project = "analytics"42 }43 }44 ```45462. **Right-Sizing & Committed Use**47 - **Spot/Preemptible Instances:** 60-90% cheaper for fault-tolerant workloads48 - **Reserved Instances:** 1-3 year commit for predictable loads (40-60% savings)49 - **Savings Plans:** Flexible commitment (AWS/Azure)50 - **Auto-scaling:** Scale down aggressively (nights, weekends)51 - **Tool:** Infracost (estimate before deploy), Kubecost (k8s)52533. **Cost Alerts & Anomaly Detection**54 - **Budget Alerts:** 50%, 80%, 100%, 120% thresholds55 - **Per-Service Budgets:** Separate for Compute, Storage, Network56 - **Anomaly Detection:** Alert on 2x daily average57 - **Example:** "BigQuery cost is 10x higher today vs yesterday"58594. **Storage Lifecycle Policies**60 - **Hot → Warm → Cold → Archive**61 - S3: Standard → IA → Glacier → Deep Archive62 - GCS: Standard → Nearline → Coldline → Archive63 - **Auto-delete:** Logs after 90 days, temp files after 7 days64 - **Savings:** 50-90% on storage costs6566### Phase 2: Infrastructure as Code (IaC)6768**Treat infrastructure like software:**69701. **Codify Resources (Terraform/OpenTofu)**71 - **Rule:** Never click in the Console to create production resources ("ClickOps").72 - Use Modules for repeatable patterns (e.g., a standard bucket configuration).73 - Store state remotely and lock it (e.g., GCS bucket with state locking).74752. **Immutability Strategy**76 - Don't SSH into servers to patch them.77 - Plan to replace infrastructure, not repair it ("Cattle, not Pets").78 - Define your container strategy (Dockerfiles, Base Images).79803. **Environment Parity**81 - Staging should look like Production (just smaller).82 - Use variables to handle differences, not different logic.83 - **Goal:** If it works in Staging, it works in Prod.8485### Phase 2.5: GitOps & Modern Deployment8687**The infrastructure deployment evolution:**88891. **GitOps Pattern**90 - **Git as Source of Truth:** Desired state lives in Git91 - **Pull-Based Deployment:** Cluster pulls config (vs push)92 - **Auto-Sync:** Changes to Git automatically deploy93 - **Tools:** ArgoCD (k8s), Flux, Atlantis (Terraform)94 - **Benefits:** Audit trail, easy rollback, no CI/CD credentials in cluster95962. **Drift Detection**97 - **Problem:** Someone clicks in console, state diverges from Git98 - **Solution:** Automated drift detection + alerts99 - **terraform plan** in CI/CD on schedule100 - **ArgoCD:** Visual diff of desired vs actual state1011023. **Progressive Delivery**103 - **Blue/Green:** Deploy new version, switch traffic instantly104 - **Canary:** Route 5% → 25% → 100% traffic gradually105 - **Feature Flags:** Enable features for subset of users106 - **Tools:** Flagger (k8s), LaunchDarkly, Split.io107108### Phase 3: The Pipeline (CI/CD)109110**Automate the factory:**1111121. **Continuous Integration (CI)**113 - Lint the code (TFSec, Hadolint).114 - Run unit tests.115 - Build the artifact (Container Image, Binary).116 - **Rule:** The build fails if the tests fail. No exceptions.1171182. **Continuous Deployment (CD)**119 - Automate the rollout.120 - **Gatekeeping:** Require approval for Prod deployment?121 - **Strategy:** Blue/Green? Canary? Rolling Update? Choose one to minimize downtime.1221233. **Rollback Strategy**124 - "Break Glass" procedure: How do we undo the last deploy instantly?125 - Test the rollback mechanism. A rollback that fails is an outage.126127### Phase 4: Observability & Reliability (SRE)128129**Flying the plane:**1301311. **Logging & Tracing**132 - Centralize logs (don't leave them on the instance).133 - Ensure logs are structured (JSON) so they can be queried.134 - Correlate logs across services (Trace ID).1351362. **Metrics & Alerting**137 - **The Golden Signals:** Latency, Traffic, Errors, Saturation.138 - Alert on *symptoms* (User sees 500 error), not just *causes* (CPU high).139 - **Rule:** If an alert wakes you up, it must be actionable. If not, delete the alert.1401413. **Disaster Recovery (DR)**142 - Automate backups.143 - **Crucial:** Test the Restore. A backup you haven't restored is just a file you hope works.144145## Red Flags - STOP and Follow Process146147If you catch yourself thinking:148- "I'll just change this firewall rule in the console quickly to test."149- "I'll hardcode the API key just for this commit."150- "I'll write the Terraform import later."151- "It works on my laptop, just ship the container."152- "We don't need logs for this service."153- "I'll ssh in and restart the service manually."154- **Using `admin` or `owner` permissions for a service account.**155156**ALL of these mean: STOP. Return to Phase 1/2.**157158## Your Human Partner's Signals You're Doing It Wrong159160**Watch for these complaints:**161- **Dev:** "The build takes 20 minutes." (Your pipeline is bloated).162- **PM:** "Why did Staging break?" (You lacked Environment Parity).163- **Sec:** "Why is port 22 open to the world?" (You failed Phase 1).164- **Fin:** "Why is the bill 3x higher this month?" (You failed Cost Estimation).165- **Dev:** "I can't debug this without SSH." (You failed Observability).166167**When you see these:** STOP. Fix the platform/process.168169## Common Rationalizations170171| Excuse | Reality |172|--------|---------|173| "ClickOps is faster for prototyping" | It creates "Configuration Drift" instantly. |174| "We'll secure the bucket later" | You will be hacked/scraped before "later" comes. |175| "I don't need a budget alert" | One infinite loop can cost $10k overnight. |176| "Terraform is too complex for this" | Manual maintenance is infinitely more complex over time. |177| "I'll document the manual steps" | Docs get outdated. Code (IaC) is the documentation. |178| "Logs are too expensive" | Downtime is more expensive. Sample/filter them. |179180## Quick Reference181182| Phase | Key Activities | Success Criteria |183|-------|---------------|------------------|184| **1. Architecture** | Topology, IAM, Cost | Secure design, Budget set |185| **2. IaC** | Terraform, Docker, State | Reproducible infra, No manual clicks |186| **3. Pipeline** | Lint, Build, Test, Deploy | Automated flow from Git to Prod |187| **4. Observability** | Golden Signals, Logs, Backups | You know it's broken before users do |188189## When Process Reveals "Legacy Drift"190191When you inherit a project built via "ClickOps" (manual console work):1921931. **Don't nuke it.**1942. **Audit:** Use tools (like `terraformer` or `gcp-export`) to read the current state.1953. **Import:** Systematically import resources into Terraform state.1964. **Lock Down:** Once imported, remove write access to the Console to force usage of the pipeline.197198## Supporting Techniques199200- **`superpowers:infrastructure-as-code`** - Writing clean Terraform modules.201- **`superpowers:container-security`** - Scanning images for vulnerabilities.202- **`superpowers:post-mortem`** - Learning from outages (Blameless RCA).203204## Real-World Impact205206- **"SysAdmin" Approach:** Manual servers, "it works on my machine," fear of Friday deploys, 3 AM wake-up calls.207- **"DevOps" Approach:** Immutable infrastructure, automated pipelines, deploys on Friday at 4 PM without sweating, sleeping through the night.208209## 🛠️ Modern Platform Stack (2026)210211### Infrastructure as Code212- **Terraform/OpenTofu:** Multi-cloud IaC213- **Pulumi:** Code-native IaC (TypeScript, Python, Go)214- **CDK (AWS/GCP):** Cloud-native IaC215216### Container Orchestration217- **Kubernetes:** Industry standard (GKE, EKS, AKS)218- **Nomad:** Simpler alternative (HashiCorp)219- **Cloud Run / Fargate:** Serverless containers220221### GitOps222- **ArgoCD:** Kubernetes deployments223- **Flux:** CNCF GitOps224- **Atlantis:** Terraform pull requests225226### Serverless227- **Functions:** AWS Lambda, Cloud Functions, Cloudflare Workers228- **Edge Compute:** Cloudflare Workers (ms latency globally)229- **Containers:** Cloud Run, Fargate, Fly.io230231### Observability232- **OpenTelemetry:** Unified standard233- **Platforms:** Datadog, Grafana Cloud, New Relic234- **Logs:** Loki, CloudWatch, Mezmo235- **Metrics:** Prometheus, VictoriaMetrics236237### CI/CD238- **GitHub Actions:** Popular, integrated239- **GitLab CI:** Full DevOps platform240- **CircleCI / Buildkite:** Specialized241242## 💰 FinOps Best Practices243244### Cost Optimization Checklist245- [ ] Tag all resources with team/project/environment246- [ ] Set up budget alerts at 50%/80%/100%247- [ ] Use spot instances for dev/test environments248- [ ] Implement auto-scaling with aggressive scale-down249- [ ] Set lifecycle policies on storage (hot → cold → archive)250- [ ] Review and delete unused resources monthly251- [ ] Use reserved instances/savings plans for stable workloads252- [ ] Monitor egress costs (data transfer between regions)253- [ ] Compress and deduplicate backups254- [ ] Use CDN to reduce origin server traffic255256### Cost Monitoring Dashboard257| Metric | Alert Threshold | Why |258|--------|----------------|-----|259| **Daily spend** | 2x 7-day average | Detect runaway costs |260| **Per-service budget** | 80% of monthly | Prevent overruns |261| **Egress traffic** | 10% increase | Network costs spike |262| **Storage growth** | 20% month-over-month | Lifecycle policies failing |263| **Idle resources** | > 7 days unused | Wasted spend |