Hashicorp Configuration Language: Difference between revisions
Jump to navigation
Jump to search
(→Block) |
|||
Line 10: | Line 10: | ||
=Block= | =Block= | ||
==Terraform Block== | |||
<syntaxhighlight lang='text'> | |||
terraform { | |||
required_version = ">= 0.12" | |||
} | |||
</syntaxhighlight> | |||
==Resource Block== | ==Resource Block== | ||
Revision as of 02:02, 14 November 2019
External
Internal
Overview
Comments
# This is a comment
Block
Terraform Block
terraform {
required_version = ">= 0.12"
}
Resource Block
Declares a resource.
Data Block
Module Block
Declares the intent to use a module.
Interpolation Expression
Input Variable
variable "region" {
default = "us-east-1"
}
To use the variable:
region= var.region
This is also an interpolation expression, prefixed with “var.”
Variables can be assigned in multiples way, and this is the descending order of precedence:
- command-line flags (-var = ‘region=something’)
- from a file (.tfvars, -var-file=…) terraform.tfvars or *.auto.tfvars in the current directory are automatically loaded. Multiple -var-file can be used.
- From environment variables: TF_VAR_name. This can only be used for string variables.
- UI Input
- Variable defaults (“default” keyword).
Lists
Maps
Output Variable
Output variables are a way to organize data to be easily queried and shown back to the Terraform user. Terraform usually stores hundred or thousands of attribute values, but only a few of those are important. Output variables can be used as an input to other modules.
Also see: