Date: 2026-05-11
Time: 15:50
I'll create a summary entry for this GCP teardown example.
This is a GCP resource teardown script that demonstrates how to use FTL2 to delete cloud infrastructure in the correct dependency order. It serves as the complement to examplegcpprovision.py, showing the full lifecycle pattern of provisioning and deprovisioning GCP resources using FTL2's google.cloud.* modules.
The script uses the standard FTL2 async automation pattern:
async with automation(secret_bindings=bindings, verbose=True) as ftl:
await ftl.google.cloud.gcp_compute_instance(
name="ftl2-web01",
zone="us-central1-a",
state="absent",
)
Resources are deleted by calling the same modules used for provisioning but with state="absent". Deletion order is the reverse of creation order to respect dependencies: instance → firewalls → subnet → network.
Environment variables (bound via secret_bindings):
GCP_PROJECT — GCP project IDGCPAUTHKIND — authentication type (e.g. serviceaccount)GCPSERVICEACCOUNT_FILE — path to service account JSON keySecret bindings pattern: "google.cloud.*" wildcard binds all three env vars to every module in the google.cloud namespace, so individual module calls don't need to repeat auth parameters.
Automation options: verbose=True enables detailed output during execution.
state="absent" is the universal pattern for resource deletion across FTL2 modules. The same module handles both creation and removal.ftl.failed is checked at the end to determine if any module call failed during the teardown. This is a property on the automation context, not per-call.examplegcpprovision.py creates the resources this script tears down.ftl2.automation.automation — the async context manager entry point for all FTL2 scripts.gcpcomputeinstance, gcpcomputefirewall, gcpcomputesubnetwork, gcpcomputenetwork — all under the google.cloud namespace.