Day 2/30: Understanding Terraform Providers

Today marks Day 2 of my #30daysofAWSTerraform challenge started by Piyush Sachdeva. Today we will deep dive into the terraform providers. What are terraform providers and how exactly they will work.

Provider:

Provider is simply a plugin tha…


This content originally appeared on DEV Community and was authored by Anil Kumar

Today marks Day 2 of my #30daysofAWSTerraform challenge started by Piyush Sachdeva. Today we will deep dive into the terraform providers. What are terraform providers and how exactly they will work.

Provider:

Provider is simply a plugin that translates our terraform code into a code that your cloud provider can understand. As Cloud Provider doesn't understand HCL language of Terraform, this provider acts as a bridge between our Terraform code and Cloud.

In simple, Providers are plugins that allow Terraform to interact with cloud platforms, SaaS providers, and other APIs. For AWS, we use the hashicorp/aws provider.

terraform providers for AWS

In the above official link, you can view all the services AWS Cloud will provide for the Terraform integration.

terraform {
  required_providers {
    aws = {
      source = "hashicorp/aws"
      version = "6.22.1"
    }
  } 
  required_version = ">= 4.0"
}

provider "aws" {
  # Configuration options
}

Above is the sample code for a terraform provider block:

Here we are trying to provision Infra on AWS Cloud using Terraform.

Why Version Matters:

If you do not mention any version specific, then latest version will always be picked up. This can cause some issues like your configuration might not be compatible with the latest version of Terraform. So Be careful in selecting the version while provisioning the Infrastructure.

Always select the version for which you have developed and tested for Terraform Configuration.

Version Constraints:

required_version = " >= 4.0"
where >= is the operator and 4.0 is the version.
Operator usecases:

  • = -> Exact version
  • != -> Excludes the exact version
  • >, >=, <, <= -> Allow Version when comparison is true.
  • ~> 6.7.0 -> It can be 6.7.1, 6.7.2... but not 6.8.0

Creating Resources

Resources are the things which we would like to create in AWS Cloud.

resource "aws_vpc" "main" {
  cidr_block = "10.0.0.0/16"
}

Here 'main' is not the VPC name, It is the local name of the resource through which we will refer it internally within the Terraform.

If you want to create EC2 instances inside above VPC, you can internally refer that using the above name.

resource "aws_ec2_host" "test" {
  instance_type     = "c5.18xlarge"
  availability_zone = "us-west-2a"
  vpc_id= aws_vpc.main.id
}

Terraform Commands

  1. terraform init: This command initializes the backend, provider plugins. You can see this under the folder created under .terraform/provider/..

  2. aws configure: Before trying to create resources you need to authentication and authorize within the AWS Cloud. For this Create a User with necessary permissions and then create AWS access key and security keys.

  3. terraform plan: This creates a state file which will compare terraform configuration files with actual infrastructure in the Cloud. As Infrastructure is not there initially, it will create the Infrastructure and store it in the statefile, It will be helpful for us in future terraform commands.

Conclusion:

This is all you need to get started with Terraform providers.

Below is the Youtube Video for reference: Tech Tutorials with Piyush — “Terraform AWS Provider Explanation”


This content originally appeared on DEV Community and was authored by Anil Kumar


Print Share Comment Cite Upload Translate Updates
APA

Anil Kumar | Sciencx (2025-11-25T17:01:47+00:00) Day 2/30: Understanding Terraform Providers. Retrieved from https://www.scien.cx/2025/11/25/day-2-30-understanding-terraform-providers/

MLA
" » Day 2/30: Understanding Terraform Providers." Anil Kumar | Sciencx - Tuesday November 25, 2025, https://www.scien.cx/2025/11/25/day-2-30-understanding-terraform-providers/
HARVARD
Anil Kumar | Sciencx Tuesday November 25, 2025 » Day 2/30: Understanding Terraform Providers., viewed ,<https://www.scien.cx/2025/11/25/day-2-30-understanding-terraform-providers/>
VANCOUVER
Anil Kumar | Sciencx - » Day 2/30: Understanding Terraform Providers. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/11/25/day-2-30-understanding-terraform-providers/
CHICAGO
" » Day 2/30: Understanding Terraform Providers." Anil Kumar | Sciencx - Accessed . https://www.scien.cx/2025/11/25/day-2-30-understanding-terraform-providers/
IEEE
" » Day 2/30: Understanding Terraform Providers." Anil Kumar | Sciencx [Online]. Available: https://www.scien.cx/2025/11/25/day-2-30-understanding-terraform-providers/. [Accessed: ]
rf:citation
» Day 2/30: Understanding Terraform Providers | Anil Kumar | Sciencx | https://www.scien.cx/2025/11/25/day-2-30-understanding-terraform-providers/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.