nerdexam
HashiCorp

TA-002-P · Question #335

When using multiple configurations of the same Terraform provider, what meta-argument must be included in any non-default provider configurations?

The correct answer is B. alias. When you need to configure the same Terraform provider multiple times with different settings within a single configuration, you must use the alias meta-argument to differentiate the non-default instances. This allows Terraform to correctly identify and use the specific…

Read, generate, and modify configuration

Question

When using multiple configurations of the same Terraform provider, what meta-argument must be included in any non-default provider configurations?

Options

  • Aname
  • Balias
  • Cdepends_on
  • Did

How the community answered

(47 responses)
  • A
    2% (1)
  • B
    87% (41)
  • C
    2% (1)
  • D
    9% (4)

Why each option

When you need to configure the same Terraform provider multiple times with different settings within a single configuration, you must use the `alias` meta-argument to differentiate the non-default instances. This allows Terraform to correctly identify and use the specific provider configuration for different resources or modules.

Aname

`name` is not a standard meta-argument used to differentiate provider configurations; provider types are implicitly named by their type (e.g., `aws`, `azurerm`).

BaliasCorrect

The `alias` meta-argument is essential for distinguishing between multiple configurations of the same provider type within a single Terraform configuration. Each non-default provider block must have a unique alias, allowing resources or modules to explicitly specify which provider configuration to use.

Cdepends_on

`depends_on` is used to manage explicit dependencies between resources or modules, not to differentiate multiple provider configurations.

Did

`id` is typically an attribute of a specific resource instance, not a meta-argument for provider configuration blocks.

Concept tested: Terraform provider aliases

Source: https://developer.hashicorp.com/terraform/language/providers/configuration#multiple-provider-configurations

Topics

#Terraform providers#Provider configuration#Provider aliases#Meta-arguments

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice