terraform init
terraform plan
terraform apply
terraform destroy
terraform output
terraform plan -var-file=<filename.tfvars>
terraform apply -var-file=<filename.tfvars>
terraform destroy -var-file=<filename.tfvars>
There is two type of variables.
-
simple value
- string
- number
- bool
-
Collection Variable
- map
- list
- set, etc
The main difference between locals and variables is their scope and visibility. Locals are only visible within the module or block where they are defined, while variables can be accessed and used throughout the entire configuration. Additionally, variables can be set from the command line or using environment variables, allowing for more flexibility when deploying infrastructure.
- Loops with count
- Loops with for_each
- for loop
-
Generic Provisioners
- file
- local-exec
- remote-exec
-
Vendor Provisioners
- chef
- nabitat
- puppet
- salt-masterless
Generic Provisioners- Generally vendor independent and can be used with any cloud vendor(GCP, AWS, AZURE)
Vendor Provisioners - It can only be used only with its vendor. For example, chef provisioner can only be used with chef for automating and provisioning the server configuration.
- source
- destination
- content
dynamic blocks allow you to define a nested block multiple times dynamically based on a variable value. This is useful when you need to create multiple similar resources with different settings.