nerdexam
HashiCorp

TERRAFORM-ASSOCIATE-003 · Question #214

A resource block is shown in the Exhibit section of this page. How would you reference the attribute name of this resource in HCL?

The correct answer is B. kubernetes_namespace.example.name. In Terraform, the correct way to reference a resource attribute is: resource_type.resource_name.attribute For example, if the resource block is: resource "kubernetes_namespace" "example" { name = "my-namespace" To reference the name attribute, use…

Understand Terraform basics

Question

A resource block is shown in the Exhibit section of this page. How would you reference the attribute name of this resource in HCL?

Options

  • Aresource.kubernetes_namespace.example.name
  • Bkubernetes_namespace.example.name
  • Cdata.kubernetes.namespace.name
  • Dkubernetes_namespace.test.name

How the community answered

(19 responses)
  • A
    5% (1)
  • B
    74% (14)
  • C
    5% (1)
  • D
    16% (3)

Explanation

In Terraform, the correct way to reference a resource attribute is: resource_type.resource_name.attribute For example, if the resource block is: resource "kubernetes_namespace" "example" { name = "my-namespace" To reference the name attribute, use: kubernetes_namespace.example.name Explanation of incorrect answers: A (resource.kubernetes_namespace.example.name) - Incorrect. Terraform does not use the resource. prefix when referencing resources. C (data.kubernetes.namespace.name) - Incorrect. This syntax is used for data sources, not D (kubernetes_namespace.test.name) - Incorrect. The resource name is";exampl";, not";tes";.

Topics

#resource attributes#HCL syntax#resource references

Community Discussion

No community discussion yet for this question.

Full TERRAFORM-ASSOCIATE-003 Practice