- HCL - Hashicorp configuration language
- Example
resource "aws_vpc" "main" { cidr_block = var.base_cidr_block } <BLOCK TYPE> "<BLOCK LABEL>" "<BLOCK LABEL>" { # Block body <IDENTIFIER> = <EXPRESSION> # Argument }
- Resources
- describe one or more infrastructure objects
- resources are declared with a resource block
- resources define behavior so that they can be
- created
- destroyed
- updated in place
- destroyed and recreated
- Datasources
- special type of read only
resource
- used to retrieve data for resources that already exist
- requested using block
- special type of read only
- Providers
- plugins that define how to interact with a cloud provider, saas provider or any api
- includes a set of
resources
anddatasources
- providers are typically found and managed in the Terraform Registry
- Variables
- Input - used as parameters for a module
- Output - returned values from a module
- local - convenience to name an expression
- Modules
- containers for multiple resources
- types
- root module - ex: this
main.tf
- child module
- a module called by another module
- can be defined locally
- can be called multiple times
- ex: argocd module
- published module
- remote module
- can be found in Terraform Registry
- could be third party/opensource
- root module - ex: this
- State
- a file created by terraform to track managed infrastructure
- stores identifiers and metadata needed to link infrastructure to resources
- the state is refreshed against actual infrastructure before configurations are applied
- state can be stored locally or remotely
- s3 is a recommended remote store to enable state to be shared
- state can contain sensitive data