- init
- validate
- plan
- apply
- destroy
Terraform configuration files (aka terraform manifests) are files with .tf extension.
HCL HashiCorp Language:
- Blocks
- Arguments
- Identifiers
- Comments
# Template
<BLOCK TYPE> "<BLOCK LABEL>" "<BLOCK LABEL>" {
# Block body
<IDENTIFIER> = <EXPRESSION> # Argument
}
# AWS Example
resource "aws_instance" "ec2demo" { # BLOCK
ami = "ami-04d29b6f966df1537" # Argument
instance_type = var.instance_type # Argument with value as expression (Variable value replaced from varibales.tf
}
# Line comment
// Line comment
/* Multi
line
comments*/
An argument assigns a value to a particular name.
The meta-arguments within resource blocks allow to define the behavior of a resource behavior.
- Fundamental blocks
- Terraform (settings) block: special block used to define some behaviors;
- Required Terraform version
- List required providers
- Terraform backend
- Only constant values can be used!
- Provider block: Terraform relies on providers to ineract with remote systems;
- Resource block: each resource block describes one or more infrastructure objects;
- Terraform (settings) block: special block used to define some behaviors;
- Variable blocks
- Input variables block
- Output values block
- Local values block
- Calling / Referencing blocks
- Data sources block
- Modules block
Each Terraform block can contain a number of settings related to Terraform's behavior.
- Required Terraform version
- Required providers
- Terraform backend
Every Resource Type is implemented by a provider.
- Provider requirements
- Provider configuration
- Dependency lock file