Skip to main content

Chapter 8 - Terraform Dependency lock file

Learn what the Terraform Dependency lock file is.

Terraform Dependency lock file


Only tracks provider dependencies. Check this into your code repo so that other runs across your team are consistent.

Upgrading your provider across major versions, this may introduce breaking changes to your code. The lock file prevents the upgrade without taking the extra step to actually upgrade the provider.

Random string provider


https://registry.terraform.io/providers/hashicorp/random/latest/docs

Documentation


You will need to switch to the matching documentation in the terraform registry when selecting previous versions. The documentation defaults to the latest and may or may not be valid for your provider version.
image.png

Short dependency lab


  1. Build out a storage account and a RG using 1.44.0 of the provider
  2. update to a newer provider version
    image.png
  3. run terraform init -update to update to the newer provider
    image.png
  4. Check the version in the lock.hcl file.
  5. Run the terraform plan and then you'll notice that there are unsupported arguments and changes to blocks in the code that previously worked.
    image.png
  6. You can then refer to the documentation for the newer provider to update the terraform code per that new documentation
    image.png

The updating of the code should get you into a no changes state.