Terraform Series part 2: Terraform Language Components

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

Components of terraform

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"
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s