Terraform-Associate-004 practice question 13 of 35
A resource block is shown in the Exhibit section of this page. How would you reference the attribute name of this resource in HCL?
Full set: 360 questionsIn HashiCorp Configuration Language (HCL), the standard syntax to reference an attribute of a managed resource is ... For a resource block of type kubernetesnamespace with the local name example, the name attribute is correctly referenced as kubernetesnamespace.example.name. This expression allows other parts of the configuration, such as another resource or an output value, to use the value of this specific attribute.
A. resource.kubernetesnamespace.example.name: The resource. prefix is not part of the standard syntax for referencing resource attributes in general HCL expressions.
C. data.kubernetes.namespace.name: The data. prefix is used to reference attributes from a data source, not a managed resource block as specified in the question.
D. kubernetesnamespace.test.name: This uses the incorrect local name (test). The reference must match the local name defined in the resource block, which is example.
1. HashiCorp Terraform Documentation, "Expressions - References to Resource Attributes": This document explicitly states the syntax for referring to resource attributes is RESOURCETYPE.LOCALNAME.ATTRIBUTE. It provides examples like awsinstance.web.id, which directly supports the structure of the correct answer.
2. HashiCorp Terraform Documentation, "Expressions - Reference Types": This page clarifies the different prefixes for references. It shows that resource references start directly with the resource type (e.g., awsinstance.example), while data source references start with data. (e.g., data.awsami.example). This confirms that options A and C use incorrect prefixes for this scenario.
Keep practicing
Take the free Terraform-Associate-004 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other Terraform-Associate-004 practice questions
- Question 1You should run terraform fnt to rewrite all Terraform configurations within the current w…
- Question 2Module variable assignments are inherited from the parent module and you do not need to e…
- Question 3terraform validate confirms thesyntaxof Terraform files.
- Question 4Using the terraform state rm command against a resource will destroy it.
- Question 5Variables declared within a module are accessible outside of the module.
- Question 6terraform init retrieves and caches the configuration for all remote modules.
