If you update the version constraint in your Terraform configuration, Terraform will update your lock file the next time you run terraform init.
If you update the version constraint in your Terraform configuration, Terraform will update your lock file the next time you run terraform init.
If you update the version constraint in your Terraform configuration, Terraform will not automatically update your lock file the next time you run terraform init. You need to run terraform init with the -upgrade option to update the lock file and select the newest available version matching the version constraint. Without the -upgrade option, Terraform will re-select the version recorded in the lock file.
You will get an error. You have to run terraform init -upgrade to change the version in .terraform.lock.hcl file.
Correct: "Use the -upgrade option if you want Terraform to ignore the dependency lock file and consider installing newer versions." https://developer.hashicorp.com/terraform/cli/commands/init#plugin-installation
Wrong. The command you used is to override the lock file's current version, installing the latest version, and the version tracked in the lock file will be ignored.
While I chose B (false), the question is not clear. Reason , it will not automatically update the version with terraform init, but there is an option -upgrade that needs to be added (terraform init -upgrade). Not sure if the exam has an implicit assumption that you run `terraform init ` with -upgrade option and if so the answer would be true.
If a particular provider already has a selection recorded in the lock file, Terraform will always re-select that version for installation, even if a newer version has become available. You can override that behavior by adding the -upgrade option when you run terraform init, in which case Terraform will disregard the existing selections and once again select the newest available version matching the version constraint. Tested in lab
Answer is A If a particular provider already has a selection recorded in the lock file, Terraform will always re-select that version for installation, even if a newer version has become available. You can override that behavior by adding the -upgrade option when you run terraform init, in which case Terraform will disregard the existing selections and once again select the newest available version matching the version constraint. https://developer.hashicorp.com/terraform/language/files/dependency-lock#dependency-installation-behavior:~:text=Terraform%20will%20always%20re%2Dselect%20that%20version%20for%20installation%2C%20even%20if%20a%20newer%20version%20has%20become%20available
I believe this is False