This is a "quick and simple guide" about how to use Terraform in your projects 🤓
First, install Terraform following their installation guide.
Then check your installation...
terraform --version
Now, go to the terraform
directory.
cd <your_project_directory>/terraform
Finally, initialize your working directory.
terraform init
Terraform interactive shell, it looks like a "playground".
terraform console
Terraform workspace, it is a kind of "project" a way that Terraform uses to organize different environments.
terraform workspace list # List available workspaces
terraform workspace new <NAME> # Create a brand new workspace
terraform workspace select <NAME> # Select an existent workspace
Terraform format, this command will format your your Terraform code.
terraform fmt
Terraform validate, this command will check if your stack looks ok.
terraform validate
Terraform plan, this command will show you a stack creation "preview".
This command can anso "output" an execution plan that you can specify at terraform apply
, if you want.
terraform plan
Terraform apply, this command will create all resources from your stack.
If you don't specify a plan file Terraform will create a plan in runtime and ask you to proceed.
terraform apply
Terraform destroy, this command will delete all resources created based on your stack.
terraform destroy