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.
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)- B95% (19)
- C5% (1)
Why each option
In a typical Terraform resource block structure like `resource "type" "name" { ... }`, `resource` identifies the block type.
`"aws_instance"` identifies the resource type (e.g., an AWS EC2 instance), not the block type itself.
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.
`"db"` is the local name given to the resource instance, not the block 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
Community Discussion
No community discussion yet for this question.