You are configuring Terraform to use both AWS and Datadog providers. Which approach enables multiple providers in a single configuration?

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

You are configuring Terraform to use both AWS and Datadog providers. Which approach enables multiple providers in a single configuration?

Explanation:
Terraform can work with more than one provider in a single configuration by using separate provider blocks for each service and, if you need multiple configurations of the same provider, giving them aliases. This lets you orchestrate resources across AWS and Datadog together, choosing which provider configuration to apply for each resource. Define a provider block for AWS and another for Datadog. If you ever need more than one configuration of a given provider (for example, different regions or accounts), assign an alias to that provider block and reference that alias in your resources. For instance, you could have AWS configured with an alias like east and Datadog with an alias like prod, then specify in resources which configuration to use (aws.east for AWS resources, datadog.prod for Datadog resources). This is how multiple providers are enabled in one configuration. Using a single provider block with multiple configurations isn’t possible, and while resources do use a provider attribute to pick a configuration, you still need separate provider blocks to define those configurations. It’s consistent to say this approach is the correct way to enable and reference multiple providers in Terraform.

Terraform can work with more than one provider in a single configuration by using separate provider blocks for each service and, if you need multiple configurations of the same provider, giving them aliases. This lets you orchestrate resources across AWS and Datadog together, choosing which provider configuration to apply for each resource.

Define a provider block for AWS and another for Datadog. If you ever need more than one configuration of a given provider (for example, different regions or accounts), assign an alias to that provider block and reference that alias in your resources. For instance, you could have AWS configured with an alias like east and Datadog with an alias like prod, then specify in resources which configuration to use (aws.east for AWS resources, datadog.prod for Datadog resources). This is how multiple providers are enabled in one configuration.

Using a single provider block with multiple configurations isn’t possible, and while resources do use a provider attribute to pick a configuration, you still need separate provider blocks to define those configurations. It’s consistent to say this approach is the correct way to enable and reference multiple providers in Terraform.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy