nerdexam
HashiCorp

TA-002-P · Question #316

Which of the following is an invalid variable name?

The correct answer is A. count. count is a reserved keyword in Terraform and cannot be used as a variable name.

Read, generate, and modify configuration

Question

Which of the following is an invalid variable name?

Options

  • Acount
  • Bweb
  • Cvar1
  • Dinstance_name

How the community answered

(36 responses)
  • A
    92% (33)
  • C
    3% (1)
  • D
    6% (2)

Why each option

`count` is a reserved keyword in Terraform and cannot be used as a variable name.

AcountCorrect

Terraform has reserved keywords that cannot be used as variable names to avoid conflicts with built-in language features. `count` is a meta-argument used within resource blocks to create multiple instances of a resource, making it an invalid choice for a custom variable name.

Bweb

`web` is a valid and commonly used identifier for a variable.

Cvar1

`var1` is a valid identifier following typical naming conventions for variables.

Dinstance_name

`instance_name` is a valid and descriptive identifier for a variable.

Concept tested: Terraform reserved keywords

Source: https://developer.hashicorp.com/terraform/language/meta-arguments/count

Topics

#Terraform variables#Reserved keywords#Configuration syntax

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice