Lesson 3 of 9 · 26m
Terraform Across Clouds: Useful Automation, Expensive Illusion
Use Terraform for consistent delivery and inventory while avoiding provider-agnostic wrappers that collapse under day-two operations.
Terraform is excellent at making cloud infrastructure declarative, reviewable, and repeatable. It is much less magical at making AWS, Azure, and GCP equivalent. A junior engineer sees one workflow — plan, apply, state — and assumes one mental model. The senior engineer knows each provider leaks through authentication, resource semantics, eventual consistency, quota behavior, and error messages.
Standardize workflow before resources
A strong multi-cloud Terraform layout usually standardizes directories, state isolation, variables, review gates, and ownership:
infra/
aws/prod/network/main.tf
aws/prod/eks/main.tf
azure/prod/network/main.tf
azure/prod/aks/main.tf
gcp/prod/network/main.tf
gcp/prod/gke/main.tf
modules/
baseline-logging/
workload-identity/Shared modules should encode organizational policy — required tags, logging destinations, private endpoints, key rotation — not pretend that an AWS VPC and an Azure virtual network are the same object.
Avoid fake provider-neutral objects
This kind of module interface looks elegant and rots quickly:
module "database" {
source = "../../modules/database"
cloud = "aws"
instance_size = "large"
replication = true
}What is large? How many connections? Is replication synchronous? Is failover automatic? Does backup include point-in-time recovery? Does encryption use a customer-managed key? The provider-specific answers matter more than the shared noun. When the module cannot express a needed feature, teams fork it, bypass it, or wedge in escaped provider blocks.
Prefer thin composable modules
A better module has a sharp responsibility and exposes provider-specific truth directly: engine version, instance class, storage encryption, KMS key, backup retention, and deletion protection. That resource is not provider-neutral, and that is exactly why it is honest. The portability boundary is the surrounding delivery process: review, testing, tagging, inventory, backup validation, and rollout ordering.
Day two is where abstraction debt appears
Provider upgrades, drift detection, quota increases, regional expansion, IAM changes, and incident recovery all hit the parts of Terraform your abstraction hid. Test them deliberately:
terraform plan -refresh-only
terraform state list | grep -E 'db_instance|sql_database|sql_database_instance'
terraform import aws_db_instance.orders orders-prodImporting and repairing state require provider-specific knowledge. Nobody imports a resource through an abstraction layer during a noisy incident without understanding what is underneath.
Field notes
- One Terraform workflow does not mean one cloud operating model; train people in each provider they can modify.
- Version constraints differ by provider maturity. Pin providers and test upgrades in lower environments.
- Cross-cloud state sharing is a coupling decision. Use remote state outputs carefully and keep failure domains separate.
- If a module needs a long decision tree to support both clouds, split it. Clarity beats elegance.
Was this lesson helpful?