Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document usage of .terraform.lock.hcl #2

Open
hjhsalo opened this issue Feb 4, 2021 · 2 comments
Open

Document usage of .terraform.lock.hcl #2

hjhsalo opened this issue Feb 4, 2021 · 2 comments
Labels
documentation Improvements or additions to documentation

Comments

@hjhsalo
Copy link
Collaborator

hjhsalo commented Feb 4, 2021

Document

  1. Point to Terraform documentation about lockfile
  2. Code in
    required_providers {
    azurerm = {
    source = "hashicorp/azurerm"
    version = "~> 2.45.1"
    }
    kubernetes = {
    source = "hashicorp/kubernetes"
    version = ">= 2.0.2"
    }
    helm = {
    source = "hashicorp/helm"
    version = ">= 2.0.1"
    }
    }
    contains version constraints for terraform providers.
    TODO: Check if there are more constraints somewhere else in code.
  3. How to update .terraform.lock.hcl (delete and run terraform init OR run terraform init -upgrade)

When a Terraform provider is updated, variables used by the provider might be updated.
E.g.

Error: Unsupported argument

  on modules/k8s_csi_driver_azure/main.tf line 3, in provider "helm":
   3:         load_config_file       = false

An argument named "load_config_file" is not expected here

This is a bit of headache when you cannot simply run tf plan anymore without updating the code.
Maybe Terraform provides a way to lock the dependencies (e.g. in script source) and/or provides a mechanism to output current versions of all dependencies. It might be good to store this output with the code in repo.

@hjhsalo
Copy link
Collaborator Author

hjhsalo commented Feb 4, 2021

This seems to be addresses by Terraform 0.14 which bring support for lock files.
https://www.hashicorp.com/blog/terraform-0-14-introduces-a-dependency-lock-file-for-providers

Seems that JouHouFin already did some of the initial work: smaddis/smad-terraform-azure@2a92344#diff-ad2c33b49112c808ea24699b01e9e020735e894c9438ace109477b3e6098cc43

@hjhsalo
Copy link
Collaborator Author

hjhsalo commented Feb 4, 2021

Let's discuss IRL what is proper way (basically when to fetch dependency updates) to update the lock file.

@JouHouFin JouHouFin added the documentation Improvements or additions to documentation label Feb 11, 2021
@hjhsalo hjhsalo changed the title Document Terraform and Terraform provider versions that are known to work. Document usage of .terraform.lock.hcl Mar 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants