Terraform syntax

From wikinotes

Terraform files use the extension *.tf.
It is based on the HCF language.
Files must be UTF-8 encoded, and the convention is to use unix line endings.


terraform language https://www.terraform.io/language
expressions https://www.terraform.io/language/expressions


  • blocks contain configuration for an object using a key/value format
  • labels can optionally be assigned a block (as many as you'd like)
  • arguments are how the key-value assignments within a block are referred to.
# ${BLOCK_TYPE} [${LABEL}..] {
#   ${IDENTIFIER} = ${EXPRESSION}  # argument
# }

resource "aws_vpc" "main" {
  cidr_block = var.base_cidr_block


terraform comments
terraform datatypes
terraform variables
terraform operators
terraform conditionals
terraform loops
terraform modules
terraform functions


terraform resources
terraform providers