Which of the following is a typical way to provide variables to Terraform when using multiple providers?

Prepare for the HashiCorp Terraform Associate Exam with quizzes, flashcards, and multiple-choice questions. Each question includes hints and explanations. Boost your confidence and ace your exam!

Multiple Choice

Which of the following is a typical way to provide variables to Terraform when using multiple providers?

Explanation:
When you have multiple providers, you still feed Terraform with values through its variable system. The usual and most practical way to provide those values is by using environment variables, -var flags, or .tfvars files. This setup allows you to keep your configuration generic and reusable while supplying environment-specific values at plan or apply time, even when you’re configuring several providers with aliases in the same configuration. For example, you can declare variables and reference them in each provider block, then drive those values with TF_VAR_ environment variables, or with -var/-var-file at the command line, or via a .tfvars file that Terraform loads. The other options don’t align with how Terraform handles variable input in multi-provider setups: a single provider block is insufficient for multiple providers, splitting configurations per provider isn’t how variable values are typically injected across a single run, and it is indeed possible to provide variables.

When you have multiple providers, you still feed Terraform with values through its variable system. The usual and most practical way to provide those values is by using environment variables, -var flags, or .tfvars files. This setup allows you to keep your configuration generic and reusable while supplying environment-specific values at plan or apply time, even when you’re configuring several providers with aliases in the same configuration. For example, you can declare variables and reference them in each provider block, then drive those values with TF_VAR_ environment variables, or with -var/-var-file at the command line, or via a .tfvars file that Terraform loads. The other options don’t align with how Terraform handles variable input in multi-provider setups: a single provider block is insufficient for multiple providers, splitting configurations per provider isn’t how variable values are typically injected across a single run, and it is indeed possible to provide variables.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy