Terraform syntax: Difference between revisions

From wikinotes
No edit summary
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
Terraform files use the extension <code>*.tf</code>.<br>
Terraform files use the extension <code>*.tf</code>.<br>
It is based on the HCF language.
It is based on the HCF language.<br>
Files must be UTF-8 encoded, and the convention is to use unix line endings.


= Documentation =
= Documentation =
Line 7: Line 8:
|-
|-
| terraform language || https://www.terraform.io/language
| terraform language || https://www.terraform.io/language
|-
| expressions || https://www.terraform.io/language/expressions
|-
|-
|}
|}
</blockquote><!-- Documentation -->
</blockquote><!-- Documentation -->


= Basics =
= Overview =
<blockquote>
<blockquote>
* '''blocks''' contain configuration for an object using a key/value format
* '''blocks''' contain configuration for an object using a key/value format
Line 27: Line 30:
</syntaxhighlight>
</syntaxhighlight>
</blockquote><!-- Basics -->
</blockquote><!-- Basics -->
= Syntax =
<blockquote>
{|
|-
| [[terraform comments]]
|-
| [[terraform datatypes]]
|-
| [[terraform variables]]
|-
| [[terraform operators]]
|-
| [[terraform conditionals]]
|-
| [[terraform loops]]
|-
| [[terraform modules]]
|-
| [[terraform functions]]
|-
|}
</blockquote><!-- Syntax -->
= Features =
<blockquote>
{|
|-
| [[terraform resources]]
|-
| [[terraform providers]]
|-
|}
</blockquote><!-- Features -->

Latest revision as of 17:21, 25 September 2022

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.

Documentation

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

Overview

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

Syntax

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

Features

terraform resources
terraform providers