TA-002-P · Question #108
You have declared a variable name my_var in terraform configuration without a value associated with it. variable my_var {} After running terraform plan it will show an error as variable is not…
The correct answer is B. False. When a variable is declared without a default value in Terraform configuration, terraform plan will prompt for its value rather than immediately showing an error.
Question
You have declared a variable name my_var in terraform configuration without a value associated with it. variable my_var {} After running terraform plan it will show an error as variable is not defined.
Options
- ATrue
- BFalse
How the community answered
(60 responses)- A7% (4)
- B93% (56)
Why each option
When a variable is declared without a default value in Terraform configuration, `terraform plan` will prompt for its value rather than immediately showing an error.
The statement is false because Terraform does not show an immediate error; it attempts to obtain a value for the undefined variable by prompting the user in an interactive session.
If an input variable is declared without a `default` value and no value is provided via `tfvars` files, environment variables, or command-line arguments, Terraform will interactively prompt the user to enter a value for the variable during `terraform plan` or `terraform apply`.
Concept tested: Terraform variable declaration and input
Source: https://developer.hashicorp.com/terraform/language/values/variables#declaring-an-input-variable
Topics
Community Discussion
No community discussion yet for this question.