Home
›
Articles
›

Terraform Basics

Terraform Basics

By Ibi Hasanli

·

·

2 min read

Terraform is an infrastructure as code tool that lets teams describe cloud and platform resources in configuration files, then create, update, and remove those resources in a predictable way.

What Terraform Does

Instead of clicking through cloud dashboards, you write the desired infrastructure in HashiCorp Configuration Language, usually called HCL. Terraform reads that configuration, compares it with the real environment, and works out what needs to change.

Core Concepts

  • Providers: Plugins that let Terraform talk to platforms such as AWS, Azure, Google Cloud, Kubernetes, Cloudflare, and many others.
  • Resources: The infrastructure objects Terraform manages, such as virtual machines, networks, databases, DNS records, and security rules.
  • Variables: Inputs that make configurations reusable across environments like development, staging, and production.
  • Outputs: Values Terraform prints after applying changes, such as an instance IP address or load balancer hostname.
  • State: Terraform’s record of the resources it manages and how they map to real infrastructure.

The Terraform Workflow

  1. Write: Define infrastructure in .tf files.
  2. Init: Run terraform init to download providers and prepare the working directory.
  3. Plan: Run terraform plan to preview what Terraform will create, update, or destroy.
  4. Apply: Run terraform apply to make the planned changes.
  5. Review: Keep configuration, state, and real infrastructure aligned over time.

Why State Matters

Terraform state is critical because it tracks what Terraform controls. For individual learning, local state may be enough. For teams, remote state with locking is usually safer because it prevents multiple people from changing the same infrastructure at the same time.

Modules and Reuse

Modules are reusable Terraform packages. A module can define a standard network, application stack, or database pattern once, then allow teams to deploy it repeatedly with different inputs. Good modules reduce duplication and help enforce infrastructure standards.

Good Terraform Habits

  • Always review terraform plan before applying changes.
  • Use version control for Terraform configuration.
  • Keep secrets out of plain Terraform files and state where possible.
  • Pin provider versions to avoid unexpected behavior changes.
  • Use remote state and locking for shared environments.
  • Start with small, understandable changes before managing large systems.

Final Thoughts

Terraform’s main value is consistency. It turns infrastructure into code that can be reviewed, reused, tested, and improved over time. Once the fundamentals are clear, teams can move faster while reducing manual configuration mistakes.

AI
Decision models

Jev vs Laya

Jev vs Laya for UK tech leads: when to call TypeSafe's hosted decision API and when to self-host the open-weight Laya model on your own infrastructure.

·

4 min read

Backups
Disaster recovery

Backup restore test

A backup restore test proves copies work on a clock you can live with. Untested backups are hope with a green tick.

·

3 min read

Infrastructure
Cloud

Moving off the server under the desk

Moving off the server under the desk: stage a move to managed hosting or cloud you own — without a big-bang rewrite.

·

3 min read

Infrastructure
Cloud

Cloud bill went up and nobody can say why

Cloud bill went up and nobody can say why: usually orphaned resources, missing tags, or one shared account. Fix ownership first.

·

3 min read

Infrastructure
Cloud

One person knows how to deploy it

If one person knows how to deploy it, you have a person, not a process. Fix ownership, access, and a path the team can run.

·

3 min read

AWS
Infrastructure

AWS vs managed hosting for a small SaaS

AWS vs managed hosting for a small SaaS: when simple platforms fit, and when owned cloud, IAM and infra in git win.

·

3 min read

Infrastructure

AWS CDK Infrastructure

How infrastructure as code with AWS CDK improves delivery, governance, scalability, and long-term cloud maintainability.

·

7 min read

Infrastructure

What is DevOps?

Bridging the Gap Between Development and Operations for Faster, Reliable Software Delivery

·

4 min read