title | description |
---|---|
Terraform Configuration Language Syntax |
Learn Terraform Configuration Language Syntax like Blocks, Arguments, Comments etc |
- Understand Terraform Language Basics
- Understand Blocks
- Understand Arguments, Attributes & Meta-Arguments
- Understand Identifiers
- Understand Comments
- Understand Blocks
- Understand Arguments
- Understand Identifiers
- Understand Comments
- Terraform Configuration
- Terraform Configuration 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
}
- Arguments can be
required
oroptional
- Attribues format looks like
resource_type.resource_name.attribute_name
- Meta-Arguments change a resource type's behavior (Example: count, for_each)
- Additional Reference
- Resource: Azure Resource Group
- Resource: Azure Resource Group Argument Reference
- Resource: Azure Resource Group Attribute Reference
- Resource: Meta-Arguments
- 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