I’ve recently joined a team where Terraform v0.12.x with S3 state backend is in use.
The apply processes are regularly executed from different environments where binary TF version has been pinned for a while to 0.12.24 (with plans to upgrade ASAP).
Recently some apply has been executed with latest v0.12 version (0.12.30) and we’re now wondering if we’re supposed to ensure that each new apply is run using 0.12.30.
Error: Error loading state: state snapshot was created by Terraform v0.12.30, which is newer than current v0.12.24; upgrade to Terraform v0.12.30 or greater to work with this state
If you check the terraform changeling of latest versions (0.12.x, 0.13.x, 0.14.x) the version lock of state-file was “removed”.
IMHO, I wouldn’t be too concerned about upgrading to the latest minor version.
As @tbugfinder noted, this check is relaxed in more recent version of Terraform, but it remains in v0.12. Until relatively recently, new releases of Terraform were routinely changing the state format in minor ways that could potentially cause problems if teams were using mixed Terraform versions. However, as we’re currently stabilizing things in preparation for a forthcoming Terraform v1.0 we’re not expecting any breaking changes to the state format in the near future, and so we’ve switched to using a separate versioning scheme just for the state format, which is independent from the Terraform CLI version.
That means that in recent versions of Terraform (later v0.13.x releases and v0.14.x releases) Terraform will accept any state snapshot created by a version greater than the first one that introduced this relaxation, as long as the state snapshot format remains at the current version 4. Some future release might introduce state version 5, in which case older versions of Terraform CLI would not be compatible with that version, although there’s nothing planned on the immediate horizon that would cause that to be true.
All of this aside, another thing to be mindful of is that providers are versioned too, and the most important data items in a state snapshot are created by the provider. This means that using a newer version of a provider might make those parts of the state unreadable to earlier versions of the provider, independently of Terraform CLI version. This need to coordinate provider upgrades across a team is one of the motivations for Terraform v0.14 introducing the dependency lock file: changes to providers can therefore be discussed through code review like any other change, rather than having to coordinate out-of-band as before.