DEV Community

Stephanie Makori
Stephanie Makori

Posted on

Getting Started with Multiple Providers in Terraform

Day 14 of my 30-Day Terraform Challenge focused on understanding how Terraform providers work and why they are so important in real-world infrastructure.

A provider is the plugin Terraform uses to communicate with a platform like AWS. When you run terraform init, Terraform reads the required_providers block, downloads the correct provider versions from the Terraform Registry, and records the exact versions in .terraform.lock.hcl.

That lock file turned out to be one of the most important things I learned about today. It keeps provider versions consistent across machines and CI/CD pipelines, which helps avoid “it works on my machine” problems. It should always be committed to version control.

Why Provider Versioning Matters

I used version constraints such as:

  • ~> 6.0 for AWS
  • ~> 3.6 for the random provider

This means Terraform can use safe updates within a version range while avoiding unexpected breaking changes.

Multi-Region Deployment with Provider Aliases

The most practical part of today was using provider aliases to deploy resources into multiple AWS regions.

I configured:

  • a default AWS provider for us-east-1
  • an aliased AWS provider for us-west-2

Then I used them to create:

  • a primary S3 bucket in one region
  • a replica S3 bucket in another region

This made it much easier to understand how Terraform decides which AWS API endpoint to call for each resource.

Key Takeaways

What stood out to me most today:

  • Providers are what connect Terraform to cloud APIs
  • terraform init is where provider installation and setup happens
  • .terraform.lock.hcl is essential for consistency
  • Provider aliases make multi-region deployments clean and manageable

Day 14 gave me a much deeper understanding of how Terraform works under the hood, and it made multi-region infrastructure feel much more approachable.

Terraform #IaC #AWS #DevOps #MultiRegion #CloudComputing #30DayTerraformChallenge #TerraformChallenge

Top comments (0)