Terraform Associate Exam QuestionsBrowse all questions from this exam

Terraform Associate Exam - Question 268


If you update the version constraint in your Terraform configuration, Terraform will update your lock file the next time you run terraform init.

Show Answer
Correct Answer: B

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.

Discussion

6 comments
Sign in to comment
tom_catOption: B
Jun 23, 2023

You will get an error. You have to run terraform init -upgrade to change the version in .terraform.lock.hcl file.

DevoteamAnalytix
Jun 26, 2023

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

shanx910
Nov 13, 2023

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.

090200f
Aug 3, 2024

yes me too think that true is the correct ans in this situation

090200f
Aug 3, 2024

yes me too think that true is the correct ans in this situation

VSMuOption: B
Jul 25, 2023

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.

March2023Option: B
Jun 22, 2023

I believe this is False

shanx910Option: A
Nov 13, 2023

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

Newuser95Option: B
Feb 20, 2024

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

MatttOption: A
Sep 17, 2024

A is correct