nerdexam
HashiCorp

TA-002-P · Question #69

What is the name assigned by Terraform to reference this resource?

The correct answer is A. compute_instance. Terraform references a resource using its resource type and a local name defined within the resource block. In the provided configuration, google_compute_instance is the type and compute_instance is the local name used for referencing.

Understand Terraform basics

Question

What is the name assigned by Terraform to reference this resource?

Options

  • Acompute_instance
  • Bmain
  • Cgoogle
  • Dteat

How the community answered

(62 responses)
  • A
    87% (54)
  • B
    6% (4)
  • C
    3% (2)
  • D
    3% (2)

Why each option

Terraform references a resource using its resource type and a local name defined within the resource block. In the provided configuration, `google_compute_instance` is the type and `compute_instance` is the local name used for referencing.

Acompute_instanceCorrect

In Terraform's resource block syntax, `resource "<RESOURCE_TYPE>" "<LOCAL_NAME>" { ... }`, the local name `compute_instance` is assigned by the user to uniquely identify and reference this specific instance of the `google_compute_instance` resource within the configuration.

Bmain

"main" is commonly a filename for Terraform configurations, not the name assigned to reference a resource itself.

Cgoogle

"google" typically refers to the cloud provider block or the provider itself, not a specific resource name.

Dteat

"teat" is not present in the provided Terraform configuration block and is irrelevant to resource naming.

Concept tested: Terraform resource addressing and naming

Source: https://developer.hashicorp.com/terraform/language/resources

Topics

#Resource naming#Resource reference#Configuration syntax#Local name

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice