exam questions

Exam Terraform Associate All Questions

View all questions & answers for the Terraform Associate exam

Exam Terraform Associate topic 1 question 5 discussion

Actual exam question from HashiCorp's Terraform Associate
Question #: 5
Topic #: 1
[All Terraform Associate Questions]

A provider configuration block is required in every Terraform configuration.
Example:

  • A. True
  • B. False
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
pabrojo
Highly Voted 2 years, 10 months ago
Selected Answer: B
It's B. From the official documentation: Unlike many other objects in the Terraform language, a provider block may be omitted if its contents would otherwise be empty. Terraform assumes an empty default configuration for any provider that is not explicitly configured.
upvoted 47 times
gargaditya
2 years, 3 months ago
Still need atleast 1 provider in the terraform configuration-If I am deploying to Azure, I can skip the AWS provider. But without the provider block containing details like authentication, how will the deployment actually happen?
upvoted 7 times
marcin3dm
2 years, 1 month ago
AZ CLI can be used as an authentication source.
upvoted 1 times
Sekir
1 year, 8 months ago
This question is basically asking "is this formatting correct", in which case it is.
upvoted 1 times
...
...
...
...
softarts
Highly Voted 3 years, 1 month ago
Selected Answer: A
vote A
upvoted 36 times
...
d170621773
Most Recent 5 days, 19 hours ago
Selected Answer: B
No doubt is B
upvoted 1 times
...
karamkb
4 months, 3 weeks ago
Selected Answer: B
A provider block is not required for all Terraform configurations – it is only required when you need to interact with an external system (e.g., AWS, Azure, Google Cloud). If your Terraform configuration only uses local resources (like terraform local-exec provisioner or null_resource), then you do not need a provider block. However, in most real-world Terraform projects, a provider is needed because Terraform is designed to manage infrastructure on external platforms. Example Where No Provider is Needed hcl Copy Edit resource "null_resource" "example" { provisioner "local-exec" { command = "echo Hello, Terraform!" } } This configuration does not require a provider because it does not interact with any external infrastructure. False. A provider block is only required when using a provider to manage infrastructure. However, most Terraform configurations do require it.
upvoted 2 times
...
DataEngDP
7 months ago
Selected Answer: B
It refers to a BLOCK so this {} that is not mandatory.
upvoted 1 times
...
erif
8 months, 4 weeks ago
Selected Answer: B
A provider configuration block is not required in every Terraform configuration. In some cases, Terraform can automatically discover providers, or the provider configuration can be inherited from other modules. Additionally, if the provider has been set up globally or within shared modules, it's possible to use the resources without explicitly declaring the provider block in every configuration file.
upvoted 1 times
...
foreverlearner
9 months, 1 week ago
Selected Answer: B
I can see the confusion here. https://developer.hashicorp.com/terraform/language/providers/configuration says "all Terraform configurations must declare which providers they require so that Terraform can install and use them", which makes people think the answer is A/True. The question says "A provider configuration block is required" (emphasis on BLOCK). The above link also says " a provider block may be omitted if its contents would otherwise be empty. Terraform assumes an empty default configuration for any provider that is not explicitly configured.", which confirms that the answer is B/FALSE, a provider BLOCK is not required, Terraform assumes a default one for you. So a provider is required, a provider BLOCK is not
upvoted 5 times
...
Bere
9 months, 1 week ago
Selected Answer: B
Here is an example without using the provider: terraform { required_version = ">= 0.13" } resource "null_resource" "example_provisioner" { provisioner "local-exec" { command = "echo 'Hello, Terraform!' > example.txt" } } In this example, we are using a null_resource with a local-exec provisioner to run a simple shell command that creates a file named "example.txt" with the text "Hello, Terraform!". Since this configuration doesn't involve any cloud provider resources or external backends, there is no need to include a provider configuration block. Terraform will execute the local-exec provisioner using the local machine's shell without requiring any cloud provider credentials or settings.
upvoted 6 times
...
samimshaikh
9 months, 1 week ago
Selected Answer: B
False. A provider configuration block is not required in every Terraform configuration. It is only required when you are using a Terraform provider to interact with a specific infrastructure platform or service. A provider configuration block typically includes details such as the provider's name, version, and any required authentication or connection information. If you're not using any provider in your Terraform configuration, you may not need a provider configuration block. Here's an example of a provider configuration block for AWS: provider "aws" { region = "us-west-2" access_key = "your-access-key" secret_key = "your-secret-key" } This block specifies the AWS provider, sets the region, and provides access and secret keys for authentication. If you're not working with AWS or any other provider, you can have a Terraform configuration without a provider block.
upvoted 1 times
...
hrajkuma
11 months, 3 weeks ago
vote for B. False A provider configuration block is not required in every Terraform configuration. Provider configuration blocks are only required when you are using a particular provider to interact with a specific type of infrastructure resource. If your configuration does not interact with any resources provided by external providers, then you do not need to include a provider configuration block. :)
upvoted 2 times
...
brundabanm
1 year ago
Selected Answer: B
Unlike many other objects in the Terraform language, a provider block may be omitted if its contents would otherwise be empty. Terraform assumes an empty default configuration for any provider that is not explicitly configured. https://developer.hashicorp.com/terraform/language/providers/configuration
upvoted 1 times
...
Molly1994
1 year ago
the answer is false. Terraform requires provider. but it does not require specifically to define a provider block {}. Terraform could use the default providers. so the answer is B false.
upvoted 1 times
...
liuyomz
1 year, 2 months ago
Selected Answer: B
B. i got it wrong but its on docs
upvoted 2 times
...
Bedmed
1 year, 3 months ago
Each Terraform module must declare which providers it requires, so that Terraform can install and use them. Provider requirements are declared in a required_providers block. A provider requirement consists of a local name, a source location, and a version constraint:
upvoted 1 times
...
vibzr2023
1 year, 3 months ago
If your Terraform configuration only includes resources from a single provider and doesn't require any special configuration for that provider, you might not need an explicit provider block. Terraform can automatically download and use the latest version of the required provider based on the resource types used. # Example without an explicit provider block resource "aws_instance" "example" { ami = "ami-0c55b159cbfafe1f0" instance_type = "t2.micro" } In this example, Terraform can infer that the AWS provider is needed because of the aws_instance resource. It will use the default configuration for the AWS provider, assuming credentials and region are configured through environment variables or shared credentials files.
upvoted 2 times
vibzr2023
1 year, 3 months ago
Saying the Selected Answer:B When You Need an Explicit Provider Block: Example: In scenarios where you need to configure specific settings for a provider, like credentials, region, or aliases for managing resources in multiple regions or with different accounts, you will need an explicit provider block. # Example with an explicit provider block provider "aws" { region = "us-west-2" access_key = "my-access-key" secret_key = "my-secret-key" } resource "aws_instance" "example" { ami = "ami-0c55b159cbfafe1f0" instance_type = "t2.micro" } In this example, the AWS provider is explicitly configured with a specific region and credentials. This is necessary if you're not relying on the default credential chain or if you want to set parameters that differ from the defaults.
upvoted 2 times
...
...
6957dbd
1 year, 3 months ago
Selected Answer: A
https://developer.hashicorp.com/terraform/language/providers/configuration Additionally, all Terraform configurations must declare which providers they require so that Terraform can install and use them. The Provider Requirements page documents how to declare providers so Terraform can install them.
upvoted 2 times
...
AWSCurt
1 year, 4 months ago
Selected Answer: B
False. A provider configuration block is not required in every Terraform configuration. Provider configuration blocks are only required when you are using a particular provider to interact with a specific type of infrastructure resource. If your configuration does not interact with any resources provided by external providers, then you do not need to include a provider configuration block.
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...