RousselTMLEARNING

Article · Terraform: from discovery to expertise

Principles, architecture and workflow

1. Declarative infrastructure as code #

Describing the desired state.

Principle #

With Terraform, you describe the desired state of the infrastructure in HCL files; Terraform computes the actions needed to get there (create, modify, delete) and runs them in the right order thanks to a dependency graph.

Terraform architecture
More than 4,000 providers exist: clouds, Kubernetes, DNS, monitoring, SaaS.

2. The workflow #

init, plan, apply, destroy.

Commands #

Terraform workflow
The plan has no effect: it shows what is going to change.
terraform init          # télécharge les fournisseurs, configure le backend
terraform fmt -recursive && terraform validate
terraform plan -out=plan.tfplan
terraform apply plan.tfplan
terraform output
terraform destroy       # supprime tout ce que gère cette configuration

Reading a plan #

SymbolMeaning
+Creation
~In-place update
-/+Replacement (destroy then create)
-Destruction

3. The ecosystem #

Terraform, OpenTofu, HCP Terraform.

Overview #

ToolDescription
TerraformHashiCorp's tool (BSL license since 2023)
OpenTofuOpen source fork (MPL 2.0) from the Linux Foundation, compatible
HCP TerraformManaged service: remote state, runs, policies, private registry
Terraform RegistryPublic providers and modules
Good practice: Pin the version of Terraform and the providers (required_version, required_providers) for reproducible runs.

📄 Terraform: principles, architecture and workflow →

My progress

  • ⏱ Estimated time : ≈ 4 min

Sign in to track your progress and take notes. Sign in

⭐ Rate this lesson

5.0 initial rating from the teaching team

Sign in to rate this lesson →

💬 Questions about this lesson

No questions yet: be the first to ask for help or share your configuration.

Ask a question about this lesson →

Recommended Articles

Terraform in CI/CD: pipelines, plan review, OIDC and GitOps

Automate Terraform: plan pipeline on merge requests and apply after approval, posting the plan as...

The HCL language: resources, variables, outputs, data and expressions

Writing Terraform: terraform, provider, resource and data blocks, typed variables with validation...

Preparing for the HashiCorp Certified: Terraform Associate certification

Preparation guide for the Terraform Associate: format, official objectives (IaC concepts, workflo...

Terraform best practices: structure, state, security, review and maintenance

Terraform best practices for teams: repository structure, naming, pinned versions, encrypted and ...

Terraform state: remote backends, locking, import and refactoring

Manage Terraform state: the role of the state file, sensitive data, remote backends (S3, azurerm,...

Testing and securing Terraform: validate, terraform test, tflint, Checkov and policies

Ensure the quality of Terraform code: fmt and validate, native terraform test tests with mocked p...

Terraform across multiple clouds: AWS, Azure, Google Cloud, OVHcloud and Kubernetes

Use Terraform with the main providers: aws, azurerm, google, ovh and openstack, kubernetes and he...

Terraform multi-environment, workspaces and repository organization

Organize Terraform for several environments: one folder per environment, tfvars files, CLI worksp...

Infrastructure as Code and GitOps: Terraform, Ansible and Argo CD

Manage infrastructure as code: declarative or imperative, Terraform (providers, state, plan, modu...

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!