Exam Terraform Associate All QuestionsBrowse all questions from this exam
Question 139

You are creating a Terraform configuration which needs to make use of multiple providers, one for AWS and one for Datadog.

Which of the following provider blocks would allow you to do this?

A.

B.

C.

    Correct Answer:

    The correct provider block configuration in this context is option B. Terraform allows you to specify multiple providers within the same configuration file. The correct syntax for declaring a provider block is by using the 'provider' keyword followed by the name of the provider in quotes. Option B correctly declares the AWS and Datadog providers using this syntax. Option A is incorrect because it does not use the provider keyword, and C is incorrect because it incorrectly nests the provider blocks inside a 'terraform' block.

Discussion
keiffo2

I think B is correct as you are configuring the provider not declaring it terraform { required_providers { aws = { source = "hashicorp/aws" version = "~> 4.0" } } } # Configure the AWS Provider provider "aws" { region = "us-east-1" }

depal_dhir

B is correct https://www.terraform.io/language/providers/configuration

sjokkorein

*CREATING* then it should be C as you need the root terraform block

8876ca1

Provider block doesnt belong inside the terraform block :D

alen995454

The question seems to hinge on the word "needs" ... if it was asking for "required_providers" then they would need to nested inside a terraform block however none of the examples show the correct syntax for a required_providers block terraform { required_providers { mycloud = { source = "mycorp/mycloud" version = "~> 1.0" } } } I'm going with B.

Spandrop

Question says "you are creating" your configuration, not configuring. It should be C

Spandrop

well paying more attention in the alternatives, I think none is correct

Tyler2023

https://developer.hashicorp.com/terraform/language/providers/requirements