Terraform Commands:

terraform providers → See what providers you are using.

terraform init → Initialize project and install all needed provider. It creates a .terraform.lock.hcl file to keep track of the provider dependency version.

terraform plan → Pre-check if your configuration is valid or not.

terraform apply → Execute the tf file to create the resources.

terraform destroy → Destroy all the declarated object.

terraform validate → Check your terraform file syntaxes.

terraform fmt → Format terraform to make the code clean to read.

terraform output → To show the outputs of the terraform that have been applied before.

terraform plan & terraform apply -refresh-only → Refresh terraform’s tfstate.

terraform graph → To show dependency graph.

<aside> 💡

You can use terraform console to test terraform functions.

</aside>

Terraform Variables

To declare terraform variables, create variables.tf with the following syntax:

variables var_name {
	type = "string"
	description = "Write the description about the variable purpose."
	default = "default_value"
}

File extensions to auto feed variables value: