Section 05 · Managing Implementation (~12.5%)

Managing Implementation

Deployment strategies, API management with Apigee, testing frameworks, Gemini Cloud Assist, Cloud SDKs, and Infrastructure as Code with Terraform.

Terraform & IaC
Apigee API Management
Deployment Strategies
Gemini Cloud Assist
Cloud SDKs
Open in Colab Open Notebook in Colab
01

Terraform and Infrastructure as Code

State Management

Terraform state tracks the mapping between configuration and real infrastructure. On GCP, the recommended backend is Google Cloud Storage with state locking.

# Backend configuration — GCS with state locking
terraform {
  backend "gcs" {
    bucket  = "my-project-tf-state"
    prefix  = "terraform/production"
  }

  required_providers {
    google = {
      source  = "hashicorp/google"
      version = "~> 5.0"
    }
  }
}

provider "google" {
  project = "my-project-id"
  region  = "us-central1"
}
Best Practice

Never store Terraform state locally in production. Use a GCS backend with versioning enabled on the bucket. This enables team collaboration, state locking (prevents concurrent modifications), and state recovery from accidental corruption.

Module Patterns

Google provides Cloud Foundation Toolkit (CFT) modules — production-ready, opinionated Terraform modules for common GCP patterns.

CFT ModulePurposeKey Features
project-factoryCreate and configure projectsBilling, APIs, Shared VPC, IAM, labels
networkVPC, subnets, routes, firewallsShared VPC support, NAT, Private Google Access
kubernetes-engineGKE clusters and node poolsAutopilot/Standard, Workload Identity, private clusters
cloud-storageBuckets with best practicesVersioning, lifecycle, CMEK, uniform access
sql-dbCloud SQL instancesHA, backups, private IP, CMEK

Terraform in CI/CD

# cloudbuild.yaml — Terraform plan + apply pipeline
steps:
  - id: 'tf-init'
    name: 'hashicorp/terraform:1.7'
    args: ['init']
    dir: 'infrastructure/'

  - id: 'tf-validate'
    name: 'hashicorp/terraform:1.7'
    args: ['validate']
    dir: 'infrastructure/'

  - id: 'tf-plan'
    name: 'hashicorp/terraform:1.7'
    args: ['plan', '-out=tfplan']
    dir: 'infrastructure/'

  # Apply only on main branch
  - id: 'tf-apply'
    name: 'hashicorp/terraform:1.7'
    args: ['apply', '-auto-approve', 'tfplan']
    dir: 'infrastructure/'
02

Apigee API Management

Architecture

Apigee is Google Cloud's full-lifecycle API management platform. It sits between API consumers and backend services, providing security, analytics, monetization, and developer portal capabilities.

Apigee TierDeploymentBest ForKey Difference
Apigee XGoogle-managed, VPC-peeredEnterprise API programsFull feature set, global distribution
Apigee HybridRuntime on your K8s, management in cloudData residency, on-prem backendsRuntime runs in your GKE/Anthos cluster
API GatewayServerless, fully managedSimple APIs, Cloud Run/Functions backendsLightweight, OpenAPI spec-based

Policies and Features

  • OAuth 2.0 / API Keys — Authentication and authorization for API consumers.
  • Quota / Spike Arrest — Rate limiting to protect backends. Quota is per-consumer, spike arrest is per-proxy.
  • Response Caching — Cache backend responses to reduce latency and backend load.
  • Message Transformation — JSON-to-XML, field masking, header manipulation.
  • Analytics — API traffic metrics, error rates, latency percentiles, developer adoption.
  • Developer Portal — Self-service portal for API consumers to discover, register, and test APIs.
  • Monetization — Billing plans for API usage (freemium, pay-per-call, tiered).
Exam Tip

Apigee vs API Gateway: Use API Gateway for simple serverless APIs (Cloud Run, Cloud Functions) with basic authentication and rate limiting. Use Apigee when you need a full API program with developer portal, monetization, advanced analytics, or complex policy chains.

03

Deployment Strategies

Strategy Comparison

StrategyHow It WorksRiskRollback SpeedGCP Support
Rolling Update Gradually replace instances Medium Medium (reverse roll) GKE, MIGs
Blue/Green Full parallel environment, switch traffic Low Instant (switch back) Cloud Run revisions, GKE
Canary Small % of traffic to new version Lowest Instant (route to old) Cloud Deploy, Cloud Run, GKE
Recreate Kill old, start new (downtime) Highest Slow (redeploy old) Basic K8s deployment
A/B Testing Route by user attributes (not random) Low Instant (route change) Istio/Anthos Service Mesh, Cloud Run

Rollback Patterns

# Cloud Run — instant rollback to previous revision
gcloud run services update-traffic my-api \
    --to-revisions=my-api-00005-abc=100 \
    --region=us-central1

# GKE — rollback a deployment
kubectl rollout undo deployment/my-app
kubectl rollout status deployment/my-app

# Cloud Deploy — rollback a release
gcloud deploy rollbacks create my-rollback \
    --delivery-pipeline=my-pipeline \
    --release=release-001 \
    --region=us-central1
04

Gemini Cloud Assist

Capabilities

Gemini Cloud Assist is an AI-powered assistant integrated into the Google Cloud Console. It helps architects and operators with natural-language queries about their infrastructure.

💬

Natural Language Queries

Ask questions about your GCP resources in plain English. "Which VMs are over-provisioned?" or "Show me the firewall rules for project-x."

🛠

Troubleshooting

Diagnose issues with network connectivity, permission errors, and service misconfigurations. Suggests remediation steps.

📝

Code Generation

Generate gcloud commands, Terraform configurations, and Cloud Build pipelines from natural-language descriptions.

📈

Cost Insights

Analyze spending patterns, identify optimization opportunities, and explain billing line items in context.

Architecture Role

Gemini Cloud Assist is an operational tool, not an architecture replacement. It accelerates implementation by generating configurations and troubleshooting issues, but architecture decisions still require human judgment about trade-offs, compliance, and business requirements.

05

Cloud SDKs and Tools

gcloud Deep Dive

ToolPurposeKey Commands
gcloudPrimary CLI for GCP resourcesgcloud compute, gcloud container, gcloud run
gsutil / gcloud storageCloud Storage operationsgsutil cp, gcloud storage cp
bqBigQuery operationsbq query, bq mk, bq load
kubectlKubernetes cluster managementkubectl apply, kubectl get
terraformInfrastructure as Codeterraform plan, terraform apply

Client Libraries

Google Cloud provides idiomatic client libraries for Python, Java, Go, Node.js, C#, Ruby, and PHP. These are preferred over REST API calls for application integration.

# Python — Cloud Storage client library
from google.cloud import storage

client = storage.Client(project="my-project")
bucket = client.bucket("my-bucket")
blob = bucket.blob("data/report.csv")
blob.upload_from_filename("/tmp/report.csv")

# Python — BigQuery client library
from google.cloud import bigquery

client = bigquery.Client(project="my-project")
query = """
    SELECT name, COUNT(*) as count
    FROM `my-project.my_dataset.my_table`
    GROUP BY name ORDER BY count DESC LIMIT 10
"""
results = client.query(query).result()
for row in results:
    print(f"{row.name}: {row.count}")
06

Testing Frameworks

For the PCA exam, understand the testing pyramid and how it applies to cloud architectures:

  • Infrastructure Tests — Validate Terraform plans with terraform validate, policy checks with Sentinel or OPA/Gatekeeper, and drift detection.
  • Container Image Scanning — Artifact Registry automatically scans for CVEs. Binary Authorization enforces that only scanned images deploy to GKE.
  • Integration Testing — Test service interactions in a staging environment that mirrors production. Cloud Build can orchestrate multi-service test suites.
  • Smoke Testing — Post-deployment health checks to verify the new version serves traffic correctly before promoting.
Exam Tip

Binary Authorization is the exam-favorite answer for "ensure only trusted containers run in GKE." It requires container images to be signed by trusted attestors before deployment. Combined with Artifact Registry vulnerability scanning, it forms a complete supply chain security solution.

07

Exam Tips

Scenario 1

"A company wants to manage their cloud infrastructure as code with proper state management, team collaboration, and CI/CD..."
Answer: Terraform with GCS backend for state, Cloud Build for CI/CD pipeline (plan on PR, apply on merge to main), Cloud Foundation Toolkit modules for standardized resource creation.

Scenario 2

"An enterprise wants to expose internal APIs to partners with rate limiting, authentication, and a developer portal..."
Answer: Apigee X. Full API management with OAuth 2.0, quota policies, response caching, analytics, and a developer portal. API Gateway is too basic for this use case.

Scenario 3

"A team wants to deploy a new version of their Cloud Run service with minimal risk..."
Answer: Canary deployment using Cloud Run traffic splitting. Deploy the new revision, route 10% of traffic to it, monitor error rates and latency in Cloud Monitoring, then gradually increase to 100%. Use gcloud run services update-traffic for instant rollback.

General Strategy

Implementation questions test your ability to execute, not just design. Know the specific gcloud commands, Terraform patterns, and deployment configurations. The exam may present code snippets and ask you to identify errors or choose the correct configuration.

Previous Section
04 · Analyzing and Optimizing
Next Section
06 · Operations Excellence
Operations Excellence