200-301 Question 498
Single answerA network engineer is tasked with automating the deployment of virtual network infrastructure in a cloud environment using Terraform. During the initial configuration, they need to define a resource block for creating a virtual network. Which key attribute is required in the Terraform resource block to ensure the resource is uniquely identified within the configuration?
- A
resource type
- B
provider configuration
- C
resource name
- D
Terraform state file
Show answer and explanation
Correct answer: C
Explanation
In Terraform, every resource block must have a unique resource name within the configuration to identify and manage the specific resource. This name, combined with the resource type, forms the unique identifier in the state file. Without a unique name, Terraform cannot distinguish between resources of the same type within the configuration.
- A. Incorrect.
The resource type defines the kind of resource (e.g., 'aws_instance' or 'azurerm_virtual_network') but does not uniquely identify the resource within the configuration.
- B. Incorrect.
The provider configuration specifies which cloud provider (e.g., AWS, Azure, GCP) to use but does not uniquely identify the resource.
- C. Correct.
The resource name is required to uniquely identify a specific resource within the configuration. Each resource block must have a unique name to avoid conflicts.
- D. Incorrect.
The Terraform state file is used to track the state of resources managed by Terraform but is not an attribute defined in the resource block.