Which option is used to pass variable values to Terraform from the command line?

Prepare for the HashiCorp Terraform Associate Exam. Utilize flashcards and multiple-choice questions with detailed hints and explanations. Boost your confidence and be ready for success!

Multiple Choice

Which option is used to pass variable values to Terraform from the command line?

Explanation:
Passing values to Terraform from the command line is done with the -var flag. This flag accepts key=value pairs directly on the screen, allowing you to override or set variable values without editing any configuration files. You can supply multiple -var flags to configure several variables at once, for example: terraform apply -var="region=us-east-1" -var="instance_count=3". While there’s also -var-file to load many variables from a file, the direct CLI method for single or ad-hoc values is the -var flag. Other options like -var-file read from files, -var-generate isn’t a valid Terraform CLI option, and -env isn’t a Terraform flag (though you can use environment variables with the TF_VAR_ prefix to influence variables).

Passing values to Terraform from the command line is done with the -var flag. This flag accepts key=value pairs directly on the screen, allowing you to override or set variable values without editing any configuration files. You can supply multiple -var flags to configure several variables at once, for example: terraform apply -var="region=us-east-1" -var="instance_count=3". While there’s also -var-file to load many variables from a file, the direct CLI method for single or ad-hoc values is the -var flag. Other options like -var-file read from files, -var-generate isn’t a valid Terraform CLI option, and -env isn’t a Terraform flag (though you can use environment variables with the TF_VAR_ prefix to influence variables).

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy