Terraform-Associate-004 practice question 26 of 35

A resource block is shown in the Exhibit space of this page. What is the Terraform resource name of the resource block?

Full set: 360 questions
Answer options
A: test
B: google
C: compute_instance
D: main Correct answer
Correct Answer:
D. main
Explanation

A Terraform resource block is defined by its type and a local name. The syntax is resource "resourcetype" "resourcename" { ... }. The first label ("resourcetype") specifies the kind of infrastructure object to manage (e.g., "googlecomputeinstance"). The second label ("resourcename") is a local, unique identifier used to refer to this specific resource within the Terraform configuration. Based on the standard convention and the provided options, the resource block in the exhibit uses "main" as its local resource name.

Why Incorrect

A. test: This is a valid name, but based on the question's context, "main" is the name used in the exhibit.
B. google: This is the name of the provider, which is the first part of the resource type (e.g., google\compute\instance), not the resource's local name.
C. computeinstance: This is the resource type within the provider, which is the second part of the resource type (e.g., google\compute\instance), not the resource's local name. ---

References

1. HashiCorp. (n.d.). Resources. Terraform Documentation. Retrieved from https://developer.hashicorp.com/terraform/language/resources/syntax.

Section: Resource Blocks. The documentation explicitly states, "A resource block declares a resource of a given type... with a given local name... The resource type and name together serve as an identifier for a given resource."

2. HashiCorp. (n.d.). Configuration Language - Syntax. Terraform Documentation. Retrieved from https://developer.hashicorp.com/terraform/language/syntax/configuration.

Section: Blocks. This page details the general syntax for blocks, showing that a resource block requires two labels: the resource type and the resource name.

3. HashiCorp. (n.d.). Providers. Terraform Documentation. Retrieved from https://developer.hashicorp.com/terraform/language/providers.

Section: Provider Names. This reference clarifies that a provider name like google is used as a prefix for resource types, distinguishing it from the local resource name.

Scroll to Top