TF-004 Understand Terraform basics Practice Question
Exhibit
resource "aws_instance" "web" {
ami = "ami-0c55b159cbfafe1f0"
instance_type = "t2.micro"
tags = {
Name = "WebServer"
}
}
resource "aws_eip" "web" {
instance = aws_instance.web.id
}Refer to the exhibit. A user applies this configuration and then runs 'terraform state list'. Which resource addresses would appear in the output?
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
aws_instance.web and aws_eip.web
The configuration defines two resources: aws_instance.web and aws_eip.web. Both will be in the state after apply. Option A lists both correct addresses.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
aws_instance.web and aws_eip.web
Why this is correct
Upon a successful `terraform apply`, all resources defined in the configuration and successfully provisioned by Terraform are recorded in the Terraform state file. Since both `aws_instance.web` and `aws_eip.web` are distinct resources specified in the configuration and are successfully created, both will have corresponding entries in the state file, reflecting their current attributes and IDs in the cloud provider.
- ✗
aws_instance.web only
Why it's wrong here
This option is incorrect because if the Terraform configuration defines both an `aws_instance.web` and an `aws_eip.web` resource, a successful `terraform apply` will provision both. The `aws_eip.web` resource, being a distinct entity, would also be created in AWS and subsequently recorded in the Terraform state file alongside the `aws_instance.web` resource, not excluded from it.
- ✗
aws_instance.web and aws_eip.web (but aws_eip.web might not appear if the EIP fails to associate)
Why it's wrong here
This option is incorrect because it introduces a conditional failure scenario that contradicts the premise of a successful `terraform apply` where resources are created and recorded in state. Assuming the `apply` operation completed successfully, both the `aws_instance.web` and `aws_eip.web` resources would have been provisioned and their details accurately reflected in the Terraform state file, regardless of any potential association issues that would typically cause the `apply` to fail or result in a different state.
- ✗
aws_eip.web only
Why it's wrong here
This option is incorrect because if the Terraform configuration includes definitions for both `aws_instance.web` and `aws_eip.web`, a successful `terraform apply` operation will provision both resources. The `aws_instance.web` resource, representing the EC2 instance itself, is a fundamental component and would certainly be created and recorded in the state file, making it impossible for only the `aws_eip.web` to appear.
Go deeper
Related to this question
About these practice questions
Courseiva writes every TF-004 question from scratch — 428 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This TF-004 practice question is part of Courseiva's free HashiCorp certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the TF-004 exam.