Hi, terraform -v command not properly working on my pc. + provider registry.terraform.io/hashicorp/local v2.5.1 this part is missing.
I have tested it on VPS and it works exactly. But not works on my local.
I just followed this simple article. But after terraform validate command not respond.
Referring to the article, which step is failing as you are referring to both terraform -v and terraform validate
Is it the
“Setting up Terraform - Verify Installation” step (no number)
or is it
“Step 5 - Validate”
It would also be helpful if you could paste in exactly what you have on your terminal, including as much as you can. When you paste it into your reply be sure to surround it with 3x back-tick characters ``` on an empty line before and after the code/output that you paste in so it is formatted properly in your post.
D:\work\company\pivot-al\terraform-demo>terraform init
Initializing the backend...
Initializing provider plugins...
- Finding latest version of hashicorp/local...
- Installing hashicorp/local v2.5.1...
- Installed hashicorp/local v2.5.1 (signed by HashiCorp)
Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
D:\work\company\pivot-al\terraform-demo>terraform validate
I will respond to this first and go back to the other reply:
The likely reason you’re getting different output here is:
On the VPS the terraform -v is likely being run in the working directory of your module. This means that terraform -v provides the version output for the terraform binary and the modules that have been downloaded by terraform init
I can see on your local you are running terraform -v in C:\Users\Pioneer> whereas your earlier reply shows that your module’s working directory is D:\work\company\pivot-al\terraform-demo>
To get the same output on your local, change into your module’s working directory and run terraform -v there.
The first thing I would do as part of troubleshooting is to remove the main.tf from your module working directory and retry the terraform validate in that directory.
This should return a
Success! The configuration is valid.
If it does not then it indicates something strange with your terraform install or its execution on your local pc. If it does return success then it indicates there may be something strange with your module files. In which case recreate your main.tf but I would recommend doing it directly in a text/code editor rather than following the command-line step as per the tutorial. Leave the main.tf empty and re-run terraform validate and check if you still get a success. Then add back in the code, etc.
Enabling some of the terraform logging is an option if you still see strange issues - but they are somewhat verbose and difficult to interpret.
OK - so we’ve ruled out the terraform binary/install itself being the likely issue and directed ourselves to the content of the file.
The terraform validate command looks at the content of your module files and tries to determine if it is syntactically valid and consistent. Other than this it doesn’t really do anything.
A few more ‘troubleshooting’ steps I would try:
ensure that the main.tf file is not open when running terraform validate
Delete the .terraform folder and .terraform.lock.hcl file from your module’s working directory (Basically every file and folder except the mian.tf file and re-run terraform init
recreate a new main.tf file and type (don’t copy and paste) the code in a line at a time. Saving the file and running terraform validate after typing each line. I would expect you to get an error each time you run terraform validate until you have saved the 4th line (the closing })
On the face of it this seems to be more of an ‘environmental’ or ‘system’ realted issue than anything fundamentally wrong with what you’re doing.
Don’t worry about it - we all started in the same place
So it may be related to some protection software on the PC causing the issue. Possibly blocking a process from accessing something and causing it to hang. I have also done a quick search for similar and seen some posts of people having hanging terraform commands (init works ok, plan etc. don’t) where they have a network block occurring.
The local provider appears to want to create RPC elements, which may be getting blocked.
More verbose logging may provide some further insight. But if it is related to some protection software or network restrictions it may be that, unless you have control over their operation, you may not be able to resolve it. Furthermore, you might spend so long trying to find the issue that just using another machine may be a more efficient approach.