Terraform Associate Exam QuestionsBrowse all questions from this exam

Terraform Associate 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.

Show Answer
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

6 comments
Sign in to comment
keiffo2
Sep 6, 2022

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
Sep 7, 2022

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

sjokkorein
Apr 12, 2024

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

8876ca1
Jun 20, 2024

Provider block doesnt belong inside the terraform block :D

Tyler2023
Nov 4, 2023

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

Spandrop
Dec 16, 2023

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

Spandrop
Dec 16, 2023

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

alen995454
Jan 14, 2024

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.