nerdexam
HashiCorp

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.

Use the Terraform CLI (terraform plan, apply, destroy, fmt, init, validate, workspace, import, taint, providers, output)

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)
  • A
    7% (4)
  • B
    93% (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.

ATrue

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.

BFalseCorrect

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

#Terraform variables#Variable declaration#terraform plan behavior#Configuration syntax

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice