Skip to content

Terraform Configuration Language Syntax

Step-01: Introduction

  • Understand Terraform Language Basics
  • Understand Blocks
  • Understand Arguments, Attributes & Meta-Arguments
  • Understand Identifiers
  • Understand Comments

Step-02: Terraform Configuration Language Syntax

# Template
<BLOCK TYPE> "<BLOCK LABEL>" "<BLOCK LABEL>"   {
  # Block body
  <IDENTIFIER> = <EXPRESSION> # Argument
}

# Azure Example
# Create a resource group
resource "azurerm_resource_group" "myrg" { # Resource BLOCK
  name = "myrg-1" # Argument
  location = "East US" # Argument 
}
# Create Virtual Network
resource "azurerm_virtual_network" "myvnet" { # Resource BLOCK
  name                = "myvnet-1" # Argument
  address_space       = ["10.0.0.0/16"]
  location            = azurerm_resource_group.myrg.location # Argument with value as expression
  resource_group_name = azurerm_resource_group.myrg.name # Argument with value as expression
}

Step-03: Understand about Arguments, Attributes and Meta-Arguments.

Step-04: Understand about Terraform Top-Level Blocks

  • Discuss about Terraform Top-Level blocks
  • Terraform Settings Block
  • Provider Block
  • Resource Block
  • Input Variables Block
  • Output Values Block
  • Local Values Block
  • Data Sources Block
  • Modules Block