In talking with Paul, it would be great if Terraform supported a -format=json
flag to terraform show
. Right now, it's easy to cat terraform.tfstate
(for local state), but it would be nice to have a jq-able API for querying information.
0.7.1 (3af6796)
Any plans to impl this?
Since Terraform 0.9 there has been a command to retrieve the state and print it to stdout
:
$ terraform state pull
This then gives the same result as accessing the terraform.tfstate
file but works for all state storage backends.
I think that takes care of the use-case that originally motivated this request, so I'm going to close this. (@devth, thanks for bumping this so that I could notice that it's actually been addressed!)
I don't see an option to format it as json though. Wasn't the point to be able to slice up state with jq
?
The output of that command is the raw state data, which is itself JSON-serialized.
I should note that the exact structure of state is _not_ currently considered a compatibility constraint, so anyone parsing it should be prepared for it to change in future, though in practice so far it has changed pretty infrequently and only in minor ways.
I don't think this should have been closed. Asking someone to parse terraform.tfstate
is a drastically different task than adding -json
to state show
and parsing that.
Thoughts?
+1 for @cornfeedhobo. Getting state show -json
would be really appreciated.
alsoalso for outputing terraform plan information
terraform state pull will dump the entire state, correct? including any sensitive info, which terraform currently stores.
I think there is definitely a need to selectively get specific resources that don't involve handling all the state, and adding a 'json' flag to 'show' would certainly cover that need.
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
+1 for @cornfeedhobo. Getting
state show -json
would be really appreciated.