In this post let us see what are different types of Terraform components available.

Resources
Creates components of your infrastructure.
Example:
# Create a resource group in azure
resource "azurerm_resource_group" "example" {
name = "example-resources"
location = "West Europe"
}
Providers
It provides resources
# Configure the Microsoft Azure Provider
provider "azurerm" {
features {}
}
Variables
Input variables to use in your configuration
variable environment_tag {
type = "string"
default = "staging"
description = "Env Tags"
}
Outputs
Outputs are highlighted infrastructure values
output "resource_group_id" {
value = azurerm_resource_group.rg.id
}
Data Sources
Data sources are used to fetch information outside of the current configuration.
# Get Resources from a Resource Group
data "azurerm_resources" "example" {
resource_group_name = "example-resources"
}