GCP cost and cleanup review
Estimate consumption before approval
Count billable resources even when no requests arrive: database capacity, disks, backups, retained objects, NAT processing and IPs, load balancer components, logs, messaging and cross-region or internet data transfer. Actual rates depend on location, service, tier and billing units. Cloud Run may have minimum instances, and GKE may incur cluster and compute charges depending on mode. Do not equate serverless with free or stopped compute with zero charges.
Compute (assumed monthly) $30Database (assumed monthly) $45Storage: 100 GiB-month x $0.02 $2Transfer: 40 GiB x $0.10 $4Logging: 10 GiB x $0.50 $5Illustrative subtotal $86Every rate is invented for arithmetic practice, not a Google Cloud quote. This subtotal excludes taxes, support, API requests, backup growth and other services. Actual budgeting requires dated SKU-level estimates, usage assumptions and a contingency. Budget notifications do not necessarily stop consumption.
Protect storage before reviewing destruction
A private bucket should use narrow IAM permissions and block unintended public access. Uniform bucket-level access removes object ACL-based access management; it does not mean everyone in the project may read the data. Public access prevention is not a replacement for least privilege, nor does it invalidate authorized signed URLs.
# Static fragment; name availability and policy not checked.resource "google_storage_bucket" "documents" { project = "example-catalog-dev" name = "example-catalog-private-documents" location = "US-CENTRAL1" uniform_bucket_level_access = true public_access_prevention = "enforced" force_destroy = false}The force_destroy setting is intentionally false; it is a Terraform behavior control rather than an absolute deletion safeguard. Soft delete, object versioning and retention can preserve data and incur storage charges. Review actual policy, restore procedures and retained cost before any deletion. Do not change retention merely to make destroy succeed. For Cloud SQL, distinguish provider deletion protection from service-side protection and independently verify backups and recovery. No database or bucket is created for this lesson.
Review the plan as a change to an ownership inventory
A destroy plan only addresses resources managed in the selected state, subject to provider behavior and dependencies. A shared network, independently managed DNS, retained backup or a resource created outside the root may remain. Removing a state binding is not deletion. Verify plan identity, project, region and dependency owners; reject unexpected replacement or broad deletion.
Synthetic review (not Terraform output):- catalog service: retire after draining callers- database: deletion blocked pending data-owner approval- network: shared; retain under platform ownership- stored objects: retention policy still active- topic and subscription: review unprocessed messagesDecision: reject blanket teardown; require separate approved steps.In a real authorized sandbox, inventory dependencies and recovery requirements, review scoped plans, verify retirement results against an independent inventory, and reconcile retained billing items. Never delete an entire project as a cleanup shortcut. API disablement can affect unrelated workloads, so do not automatically disable shared services.
Build an offline architecture and cost review
Use the complete local configuration below in a fresh disposable directory only after verifying the CLI. It has no provider or cloud calls and contains no managed resources. Initialize and validate locally, then inspect a plan; there is no need to apply just to review the predicted outputs.
terraform { required_version = "= 1.14.8"}locals { region = "us-central1" network = { name = "catalog-net" subnet = "10.20.0.0/24" } services = { app = { region = local.region, public = false } db = { region = local.region, public = false } } monthly_lines = { compute = 30 database = 45 storage = 100 * 0.02 transfer = 40 * 0.10 logging = 10 * 0.50 }}output "review" { value = { region = local.region public_services = [for name, svc in local.services : name if svc.public] subnet = local.network.subnet estimated_usd = sum(values(local.monthly_lines)) }}Expected outputs: region us-central1, no public_services, subnet 10.20.0.0/24 and estimated_usd 86. This is a toy inventory, not a security scanner or billing estimator. The estimate and address-range checks are independently checked in Python; native Terraform execution was not performed. For real deployments, check actual service prices, retained resources and billing after teardown.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
GCP cost and cleanup review — knowledge check
Review private architecture, resource ownership and cost.
What is the hypothetical subtotal in the worksheet?
What can happen after an object is soft-deleted?
What does removing a state binding prove?
What should a reviewer do with an unexpected database deletion?
What is true of budget alerts?