Generating one Terraform lock file with Windows and Linux compatibility
We previously learned in Chapter 1, Setting Up the Terraform Environment, in the recipe Upgrading Terraform providers, that the Terraform dependency file (.terraform.lock.hcl
) contains information used by Terraform providers in the Terraform configuration.
Among these providers’ information, there are the name, the version, and also the hashes of the packages for integrity checks.
What is important to know is that the package hashes are different, depending on the operating system (OS) that runs Terraform, since both the Terraform CLI and provider builds (in both cases written in Go) are built for each combination of OS and architecture separately.
And so, the problem you may encounter is that developers work and test their Terraform configuration on a Windows or macOS machine, but the CI pipeline that deploys that same Terraform configuration on other environments is run on a Linux machine...