Hashicorp Certified Terraform Associate 003 · Free Practice Question Medium

Question 15

You are writing Terraform to deploy resources, and have included provider blocks as shown below:



When you validate the Terraform configuration, you get the following error:



What additional parameter is required to use multiple provider blocks of the same type, but with distinct configurations, such as cloud regions, authentication, or other desired settings?

  • A

    version

  • B

    label

  • C

    alias

  • D

    multi

Reveal correct answer

Correct answer: C

Explanation

An alias meta-argument is used when using the same provider with different configurations for different resources. This feature allows you to include multiple provider blocks that refer to different configurations. In this example, you would need something like this:



When writing Terraform code to deploy resources, the resources that you want to deploy to the "west" region would need to specify the alias within the resource block. This instructs Terraform to use the configuration specified in that provider block. So in this case, the resource would be deployed to "us-west-2" region and not the "us-east-1" region. This configuration is common when using multiple cloud regions or authentication methods.

https://developer.hashicorp.com/terraform/language/providers/configuration#alias-multiple-provider-instances

A. The "version" parameter is not used to define multiple configurations of the same provider type in Terraform. It is typically used to specify the version of the provider being used.

B. The "label" parameter is not a valid parameter in Terraform for defining multiple configurations of the same provider type. To differentiate between configurations, the "alias" parameter should be used.

C. The correct additional parameter required to use multiple provider blocks of the same type with distinct configurations is the "alias" parameter. This allows you to differentiate between the different configurations of the same provider type.

D. The "multi" parameter is not a valid parameter in Terraform for defining multiple configurations of the same provider type. The correct parameter to achieve this is the "alias" parameter.

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need