TA-002-P · Question #396
TA-002-P Question #396: Real Exam Question with Answer & Explanation
The correct answer is D: Modify the terraform.tfvars with the instance type and issue terraform plan and then terraform. To override a specific variable such as instance type without altering other default values, the teammate should update terraform.tfvars with the new value and then run terraform plan followed by terraform apply.
Question
Terraform is currently being used by your organisation to create resources on AWS for the development of a web application. One of your coworkers wants to change the instance type to "t2.large" while keeping the default set values. What adjustments does the teammate make in order to meet his goal?
Options
- AIssue Terraform plan instance.type".t2.large" and it deploys the instance
- BModify the tf.variableswith the instance type and issue terraform apply
- CCreate a new file my.tfvars and add the type of the instance and issue terraform plan and apply
- DModify the terraform.tfvars with the instance type and issue terraform plan and then terraform
Explanation
To override a specific variable such as instance type without altering other default values, the teammate should update terraform.tfvars with the new value and then run terraform plan followed by terraform apply.
Common mistakes.
- A. 'terraform plan instance.type="t2.large"' is not valid Terraform CLI syntax and would not successfully pass a variable value to the configuration.
- B. Modifying the variable declaration files changes the default values in the source code itself rather than overriding them externally, which is not the correct pattern for environment-specific or user-specific overrides.
- C. Creating a custom my.tfvars file would only work if explicitly passed with the -var-file flag; without it, Terraform does not auto-load non-standard .tfvars filenames - only terraform.tfvars and *.auto.tfvars are loaded automatically.
Concept tested. Overriding Terraform variable defaults with terraform.tfvars
Topics
Community Discussion
No community discussion yet for this question.