Troubleshooting: Known Errors¶
Content¶
Terraform is not recognized¶
Terraform is not recognized because it's not installed or not added to your system's PATH
terraform : The term 'terraform' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ terraform init
+ ~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (terraform:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Step 1: Download Terraform¶
Command line¶
- Open your command prompt.
- Use curl to download Terraform. Replace VERSION with the desired version number, for example
1.1.4.
curl -o terraform.zip https://releases.hashicorp.com/terraform/VERSION/terraform_VERSION_windows_amd64.zip
-
Use tar to extract the ZIP file:
tar -xvf terraform.zip
Graphical interface¶
- Go to the Terraform download page.
-
Download the appropriate package for your operating system (e.g., Windows, macOS, Linux).
Step 2: Install Terraform¶
For Windows:¶
- Extract the downloaded ZIP file to a directory of your choice (e.g.,
C:\terraform).
-
Add the directory to your system's PATH:
By command line:
Assuming you have moved terraform.exe to C:\terraform, you can add this directory to the PATH using the following commandsetx PATH "%PATH%;C:\terraform"By GUI: - Open the Start menu and search for
Environment Variables. - Click onEdit the system environment variables
- In the System Properties window, click on `Environment Variables`.
- Under `System variables`, find the `Path` variable and click `Edit`.
- Click `New` and add the path to the directory where you extracted Terraform (e.g., `C:\terraform`).
- Click `OK` to close all windows.
For macOS:¶
- Open a terminal.
- Move the Terraform binary to a directory included in your PATH (e.g.,
/usr/local/bin):sudo mv ~/Downloads/terraform /usr/local/bin/ - Ensure the directory is in your PATH by adding the following line to your
~/.bash_profileor~/.zshrcfile:export PATH=$PATH:/usr/local/bin - Reload your profile:
source ~/.bash_profile # or source ~/.zshrc
For Linux:¶
- Open a terminal.
- Move the Terraform binary to a directory included in your PATH (e.g.,
/usr/local/bin):sudo mv ~/Downloads/terraform /usr/local/bin/ - Ensure the directory is in your PATH by adding the following line to your
~/.bashrcor~/.profilefile:export PATH=$PATH:/usr/local/bin - Reload your profile:
source ~/.bashrc # or source ~/.profile
Step 3: Verify the Installation¶
- Open a new terminal or command prompt.
- Run the following command to verify the installation. You should see the installed version of Terraform.
terraform -version
Step 4: Initialize Terraform¶
Now you can run the terraform init command in your project directory:
terraform init
Resource Group Not Found¶
Please ensure you create your resource group before running the configuration and deployment. This error occurs because the specified resource group does not exist.
Error: Failed to get existing workspaces: Error retrieving keys for Storage Account "examplestorageacct": storage.AccountsClient#ListKeys: Failure responding to request: StatusCode=404 -- Original Error: autorest/azure: Service returned an error. Status=404 Code="ResourceGroupNotFound" Message="Resource group 'RGWorkshopUserName' could not be found." but I want to create it
Resource Not Found¶
Please ensure you create your storage account and container for backend before running the configuration and deployment. This error occurs because the specified storage account does not exist.
Error: Failed to get existing workspaces: Error retrieving keys for Storage Account "examplestorageacct": storage.AccountsClient#ListKeys: Failure responding to request: StatusCode=404 -- Original Error: autorest/azure: Service returned an error. Status=404 Code="ResourceNotFound" Message="The Resource 'Microsoft.Storage/storageAccounts/examplestorageacct' under resource group 'RGWorkshopUserName' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix"