#
Terraform Providers
This tutorial explains what a Terraform provider is.
Terraform is an open-source infrastructure as code (IaC) software tool that enables you to safely and predictably create, change, and improve infrastructure. This includes low-level components like compute instances, storage, and networking, as well as high-level components like DNS entries and SaaS features.
Terraform will not create directly the resource we need. Terraform communicates with a cloud and finally, the cloud is creating that resource.
Terraform Providers allows you that communication. Providers are a logical abstraction of an upstream API. They are responsible for understanding API interactions and exposing resources.
Here we have the Terraform providers.
Each Terraform script starts by defining the provider it uses.
For Azure, we can have :
# 1. Specify the version of the AzureRM Provider to use
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "=3.0.1"
}
}
}
# 2. Configure the AzureRM Provider
provider "azurerm" {
features {}
}
Info
The Azure Provider allows the behaviour of certain resources to be configured using the features
block.
This allows different users to select the behaviour they require, for example some users may wish for the OS Disks for a Virtual Machine to be removed automatically when the Virtual Machine is destroyed - whereas other users may wish for these OS Disks to be detached but not deleted.
For AWS, we can have :
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "4.27.0"
}
}
}
provider "aws" {
# Configuration options
}
For GCP, we can have :
terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "3.5.0"
}
}
}
provider "google" {
# Configuration options
}
One time the Terraform Provider is defined in our script, we can define the resources we need to create.