nerdexam
HashiCorp

TA-002-P · Question #317

In the following code snippet, the block type is identified by which string?

The correct answer is B. resource. In a typical Terraform resource block structure like resource "type" "name" { ... }, resource identifies the block type.

Understand Terraform basics

Question

In the following code snippet, the block type is identified by which string?

Options

  • A"aws_instance"
  • Bresource
  • C"db"
  • Dinstance_type

How the community answered

(20 responses)
  • B
    95% (19)
  • C
    5% (1)

Why each option

In a typical Terraform resource block structure like `resource "type" "name" { ... }`, `resource` identifies the block type.

A"aws_instance"

`"aws_instance"` identifies the resource type (e.g., an AWS EC2 instance), not the block type itself.

BresourceCorrect

In Terraform, blocks define containers for configuration settings. The `resource` keyword signifies that the following block defines a managed infrastructure resource. The block type (e.g., `resource`), followed by a label (e.g., `"aws_instance"`) and a local name (e.g., `"db"`), constitutes the typical structure.

C"db"

`"db"` is the local name given to the resource instance, not the block type.

Dinstance_type

`instance_type` is likely an argument within the resource block, specifying a characteristic of the resource, not the block type.

Concept tested: Terraform block types and structure

Source: https://developer.hashicorp.com/terraform/language/syntax/configuration

Topics

#HCL syntax#Block types#Configuration structure#Resource block

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice