-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Output Value not returning values as expected even when the syntax is correct. #35186
Comments
Hi @yashdeored, The only way I can see you getting the result shown here is if the configuration was never applied, so there is no |
Yes I have ran the terraform plan and terraform apply code and there was a tfstate file which was created but I have debugged it after running the code several time but this bug could be reproduced so I request you to look into this matter. |
Thanks @yashdeored, If that's the case, since it does work under normal circumstances, we're going to need more detail to determine what is different in your case. What would be useful is a minimal reproducible example, with all the exact steps required to go from scratch to the situation you outlined above. |
So it is reproduced if we install a fully new installed terraform cli on vs code and then write the output code it generates error but if it is refreshed multiple times then it generates the correct output. To regenerate it just setup a new terraform and type 'terraform plan' or 'terraform output' it generates an error. |
If you are setting up a new configuration and have not run |
I have ran the |
If that's the case, please show all the steps, meaning the entire configuration and exact commands as executed, required to replicate the issue starting from an empty configuration. If I copy the above configuration exactly and apply it, it will not produce that warning with |
Firstly, I installed terraform on MacOS CLI using Homebrew:
Now, install Terraform with hashicorp/tap/terraform.
This installs a signed binary and is automatically updated with every new official release.
Then, run the upgrade command to download and use the latest Terraform version.
Once this is done we will run a sample tf code for outputs:
Then we have to save this file as
OR
Problems starts to occurs here as you run
|
Hi @yashdeored There is no step in your instructions where you apply any plan (running |
What if prior to this we have already applied terraform and then destroyed it and then running |
If you've destroyed the prior state, then there is no state, and hence no output. |
Ok I was following a guide wherein he destroyed the prior state and even got output after that. |
Terraform Version
Terraform Configuration Files
Debug Output
│ Warning: No outputs found
│
│ The state file either has no outputs defined, or all the defined outputs are empty. Please define an output in your configuration with the
output
│ keyword and run
terraform refresh
for it to become available. If you are using interpolation, please verify the interpolated value is not empty. You│ can use the
terraform console
command to assist.Expected Behavior
It should have outputted the value for private ip address for an ec2 instance.
Outputs:
private_ip = "xyz"
Actual Behavior
When I ran the terraform configuration file "terraform output" command it resulted in no outputs even when it was specifies with the correct syntax on the official page.
Steps to Reproduce
Additional Context
Terraform is running in VS Code on Mac OS.
References
No response
The text was updated successfully, but these errors were encountered: