Skip to main content

Command Palette

Search for a command to run...

Day 2 — Terraform Basics, Workflow & Version Constraints

Updated
2 min read
Day 2 — Terraform Basics, Workflow & Version Constraints
S

DevOps Enginner

Today’s learning focused on the core concepts of Terraform, its workflow, and why versioning is critical when managing infrastructure at scale.

Terraform uses HCL (HashiCorp Configuration Language), a declarative language where we define the desired state of infrastructure rather than writing procedural scripts.

Terraform Workflow

Terraform follows a simple and reliable workflow:

  1. terraform init – Initializes the project and downloads required providers and plugins

  2. terraform plan – Previews the changes Terraform will make

  3. terraform apply – Applies the changes to create or update resources

This workflow helps avoid unexpected changes and provides visibility before execution.

Terraform Registry & Providers

Terraform interacts with cloud platforms and services through providers, which act as plugins to communicate with target APIs.

Providers are available via the Terraform Registry:

  • Official

  • Partner

  • Community

Common providers include AWS, Azure, and GCP, along with services like Docker, Kubernetes, and Datadog.

Terraform Versions & Why They Matter

By default, Terraform may use the latest version, but newer versions can introduce breaking changes. This can cause existing configurations to fail or behave differently.

To maintain stability, Terraform supports version constraints for both Terraform itself and providers.

Example: Version Constraints

Below is a simple example of defining version constraints in Terraform:

terraform {
  required_version = "~> 1.6"

  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.0"
    }
  }
}

What this means:

  • required_version = "~> 1.6" → Allows Terraform versions 1.6.x but blocks 1.7+

  • version = "~> 5.0" → Allows AWS provider versions 5.x but blocks 6.0+

This ensures your configuration remains compatible, predictable, and safe across environments.

Getting Started with AWS

Finally, I explored the basics of configuring Terraform with AWS, including setting up credentials and defining the AWS provider to provision cloud resources.

For more detail watch this:- https://youtu.be/JFiMmaktnuM?si=rwDLT-reuhCdZEPw
Github link:- https://github.com/sidharthhhh/terraform

More from this blog

Sidharth

40 posts