🔙 Back to README.
🌐 Language: English | Português
Install Terraform: https://developer.hashicorp.com/terraform/install
-
Download the zip file for Windows AMD64 (available in the link above);
-
Extract file
terraform.exe
in the parent folder (that is, in the same folder asmain.tf
file); -
Open PowerShell in the parent folder and run
./terraform version
to confirm it was installed successfully. You should see something like this:> ./terraform version Terraform v1.8.5 on windows_amd64
-
Download the zip file for Windows AMD64 (available in the link above);
-
Create folder
C:\Programs\Terraform
and extract fileterraform.exe
inside it; -
Open Windows Start menu, search for "system variables" and click on "Edit the system environment variables"
-
Click on "Environment Variables..." button in the bottom right
-
Select "Path" inside "System variables" and click on "Edit" in the bottom part:
-
Click on "New" in the right side and add
C:\Programs\Terraform
. Then, click on "OK" on all windows. -
Open Command Prompt or PowerShell and run
terraform version
to confirm it was installed successfully. You should see something like this:> terraform version Terraform v1.8.5 on windows_amd64
Run the following commands:
sudo apt update && sudo apt install -y gnupg software-properties-common
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 -y terraform
Run command terraform version
to confirm that Terraform is installed. You
should see something like this:
$ terraform version
Terraform v.18.5
on linux_amd64
An access key comprises an access key ID (AK) and secret access key (SK), and is used as a long-term identity credential to sign your requests for Huawei Cloud APIs (made by Terraform provider). AK is used together with SK to sign requests cryptographically, ensuring that the requests are secret, complete, and correct. For more details, see Access Keys documentation
To create an access key for your Huawei Cloud account, first log in to Huawei Cloud Console.
-
Put your mouse over your username in the top right corner (A) and click on "My Credentials" (B) in the dropdown menu;
-
On the left side menu, click on "Access Keys" and then click on "Create Access Key";
-
Enter a description (optional) and then click on "OK";
-
Click on "Download" (G) in the modal message. A file named
credentials.csv
will be saved; -
Open the
credentials.csv
file in Notepad. It should have the following layout:User Name,Access Key Id,Secret Access Key "username",**********,##########
-
On the second line, the second part is the Access Key (AK), and the third part is the Secret Key (SK).
terraform init
- Initializes Terraform provider and modules
terraform fmt
- Formats the Terraform code automatically
terraform validate
- Checks if code syntax is correct
terraform plan
- Outputs what will be executed by Terraform
terraform apply
- Executes the infrastructure changes
terraform graph > graph.txt
- Generate a instructure description in a graph
format (DOT language) and saves it to graph.txt
file. You can use the
https://dreampuf.github.io/GraphvizOnline/ website to view the graph.
If you encounter an error message that is unclear, or if you identified a
problem while using the provider, it is possible to configure Terraform to
generates debug logs by configuring environment variables TF_LOG
and
TF_LOG_PATH
.
If you are on Windows, run the following commands in PowerShell:
$Env:TF_LOG="DEBUG"
$Env:TF_LOG_PATH="tf_log.txt"
If you are on Linux, run the following commands in your shell:
export TF_LOG="DEBUG"
export TF_LOG_PATH="tf_log.txt"
Then run the Terraform command again. The debug logs will be saved in the
tf_log.txt
file. Please note that this debug configuration only applies to
the same terminal where the environment variables were previously configured.