Terraform¶
Terraform is an open-source Infrastructure as Code (IaC) tool developed by HashiCorp. It allows you to safely create, modify, and stop infrastructure, and version these operations just like any other code. Terraform can manage multiple cloud service providers (such as AWS, Azure, Google Cloud Platform, etc.), network devices, and other resources.
TrueWatch provides a Terraform Provider for managing TrueWatch resources. Users can define and write TrueWatch related resources through the Provider and manage them using the Terraform command-line tool.
Install Terraform¶
For detailed installation instructions for Terraform, please refer to the official documentation. Below are installation methods for some operating systems, with Terraform version 1.9.5.
macOS¶
Package Manager
Binary Package
Windows¶
Binary Package
Linux¶
Package Manager
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install terraform
Binary Package
Basic Terraform Commands¶
After installing Terraform, you can verify the installation with the following command.
Terraform provides a series of commands to help you manage and operate cloud resources. Here are some commonly used commands:
Initialize¶
The terraform init command is used to initialize a Terraform project, including downloading and installing plugins, configuring local state storage, initializing remote state storage, etc.
Plan and Apply¶
- The
terraform plancommand is used to generate a plan of the changes to be executed and display the operations to be performed. - The
terraform applycommand is used to execute the change plan, creating, modifying, or deleting resources. - The
terraform destroycommand is used to delete resources.
State Management¶
- The
terraform state listcommand is used to list all resources in the current state. - The
terraform state showcommand is used to display detailed information about a specified resource. - The
terraform state rmcommand is used to delete a specified resource.
Output¶
The terraform output command is used to display the output values defined in the current state.
Others¶
- The
terraform validatecommand is used to validate if the configuration files are correct. - The
terraform fmtcommand is used to format configuration files.