Hi,
since I would like to implement a tool which makes use of the terraform state file, I would like to know whether there is some kind of official changelog or documentation regarding the different terraform state versions (e.g. for differences between version 3 and version 4).
I found some blog posts about the structure of the tfstate file, but none really explains the full json structure.
When there is no documentation available, I would also be happy to receive hints like golang structs which represent the statefile etc. so I can gather more information.
Kind regards,
Dominik
Hi @dominikmueller,
For now, the state snapshot format that Terraform reads and writes itself is not subject to compatibility promises for external consumers. Terraform itself is able to read and upgrade older versions, but for the moment Terraform’s architecture is still evolving which tends to require changes to these internal file formats.
However, we offer the terraform show -json
command, which is intended for public consumption. For the moment that format still carries a 0.x
version number in recognition of the fact that small breaking changes might be required, but because this format does not need to round-trip state in full fidelity it has more room for accommodating changes, and so we have more confidence that it will only change in minor ways before finalizing it.
The formats used by terraform show -json
are documented in Internals: JSON Output Format. There’s also a Go package containing types that can be used with json.Unmarshal
.