Infrastructure as CodeUsing Terraform Data Sources Effectively
Learn how to use Terraform data sources to query existing resources, look up AMIs, reference remote state, and build dynamic configurations. Complete.
Technology
Compare Terraform with OpenTofu, Pulumi, Ansible, AWS CDK and CloudFormation, plus core concept guides like for_each vs count and plan vs apply.
Choosing an Infrastructure-as-Code tool — or just trying to understand how Terraform compares to the alternatives? This hub gathers every head-to-head comparison in one place, from tool choices (Terraform vs OpenTofu, Pulumi, Ansible) to the day-to-day Terraform concepts engineers mix up.
| Tool | Language | State model | Best for |
|---|---|---|---|
| Terraform | HCL (declarative) | Own state file | Multi-cloud IaC, large ecosystems |
| OpenTofu | HCL (Terraform-compatible) | Own state file | Open-source, drop-in Terraform fork |
| Pulumi | TypeScript, Python, Go, C# | Own state/back end | Teams who prefer general-purpose languages |
| Ansible | YAML (procedural) | Stateless | Configuration management & provisioning |
| AWS CDK | TypeScript, Python, Java | CloudFormation stacks | AWS-only teams using real code |
| CloudFormation | YAML/JSON (declarative) | Managed by AWS | AWS-native, fully managed state |
The right choice depends on whether you need multi-cloud support, a managed state back end, or a general-purpose language. The detailed comparisons below break down each trade-off.
The terms below trip up engineers daily. Each guide explains the difference and when to use which:
It depends on your needs. OpenTofu is the closest drop-in replacement (a community fork of Terraform with the same HCL syntax). Pulumi is best if your team prefers a general-purpose language like TypeScript or Python. AWS CDK and CloudFormation are strong AWS-only choices. See the comparisons above for the trade-offs.
OpenTofu is an open-source fork of Terraform created after HashiCorp moved Terraform to the BSL license. It is Terraform-compatible at the HCL and state level, so most configurations work with either. Read the full Terraform vs OpenTofu comparison.
They solve different problems and are often used together. Terraform provisions infrastructure (declarative, stateful); Ansible configures and manages servers (procedural, stateless). See Terraform vs Ansible.
Terraform's CLI is free to use under the BSL license. OpenTofu is fully open source under the MPL. Paid tiers (HCP Terraform) add collaboration, policy, and state-management features.
Infrastructure as CodeLearn how to use Terraform data sources to query existing resources, look up AMIs, reference remote state, and build dynamic configurations. Complete.
Cloud ComputingMaster multi-account AWS management with Terraform. Learn provider aliases, cross-account IAM roles, AWS Organizations integration, and production-ready.
Cloud ComputingLearn how to implement Terraform state locking with AWS DynamoDB to prevent concurrent modifications and state corruption. Complete setup guide with examples.
DevOpsLearn how to integrate Terraform with GitHub Actions for automated infrastructure deployments. Complete guide with workflows, best practices, and.