Courseiva
← Back to HashiCorp Terraform Associate TF-004 questions

Scenario-based practice

Refer to the Exhibit Practice Questions

Practise HashiCorp Terraform Associate TF-004 practice questions — original exam-style scenarios covering every exam domain, with detailed explanations, wrong-answer analysis, and common exam traps.

15
scenario questions
TF-004
exam code
HashiCorp
vendor

Scenario guide

How to approach refer to the exhibit practice questions

Practise exhibit-style questions that ask you to read a topology, table, command output or diagram before choosing the best answer.

Quick answer

Exhibit-style questions test whether you can read a topology, command output, diagram or table before choosing the best answer.

How to extract the relevant detail from an exhibit.

How topology, command output or routing information affects the answer.

How to avoid answering from memory before reading the evidence.

How to map the exhibit back to the exam objective.

Related practice questions

Related TF-004 topic practice pages

Scenario questions usually connect to one or more exam topics. Use these links to review the underlying concepts behind the scenario.

Practice set

Practice scenarios

Question 1mediummultiple choice
Full question →

Refer to the exhibit. What does this output indicate?

Exhibit

Plan: 0 to add, 1 to change, 0 to destroy.
Question 2easymultiple choice
Full question →

Refer to the exhibit. What is the purpose of this output block?

Exhibit

output "instance_ip" {
  value = aws_instance.web.public_ip
}
Question 3hardmultiple choice
Full question →

Refer to the exhibit. What is the purpose of the data source?

Exhibit

resource "aws_instance" "web" {
  ami = data.aws_ami.ubuntu.id
  instance_type = "t2.micro"
}

data "aws_ami" "ubuntu" {
  most_recent = true
  owners = ["099720109477"]

  filter {
    name   = "name"
    values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"]
  }
}
Question 4hardmultiple choice
Full question →

Refer to the exhibit. A team is troubleshooting a Terraform deployment. What information can be inferred from this state file?

Exhibit

{
  "version": 4,
  "terraform_version": "1.5.0",
  "resources": [
    {
      "mode": "managed",
      "type": "aws_instance",
      "name": "web",
      "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
      "instances": [
        {
          "attributes": {
            "id": "i-0a1b2c3d4e5f67890",
            "instance_type": "t2.micro"
          },
          "dependencies": [
            "aws_security_group.web_sg"
          ]
        }
      ]
    }
  ]
}
Question 5mediummultiple choice
Full question →

Refer to the exhibit. A developer runs `terraform plan -out=tfplan` and then `terraform apply "tfplan"`. During apply, network fails and apply is interrupted. The developer then runs `terraform apply` again (without a plan file). What will happen?

Exhibit

Refer to the exhibit.

```
$ terraform plan -out=tfplan
$ terraform apply "tfplan"
```
The developer runs the commands above. During the apply, the network connection is lost and the command fails halfway through. The developer re-establishes connectivity and runs `terraform apply` again without specifying a plan file. What will happen?
Question 6easymultiple choice
Read the full VPN explanation →

Refer to the exhibit. The configuration fails with an error indicating that the module does not support the 'enable_vpn_gateway' argument. What is the most likely cause?

Exhibit

Refer to the exhibit.

```hcl
module "vpc" {
  source  = "terraform-aws-modules/vpc/aws"
  version = "3.18.0"

  name = "my-vpc"
  cidr = "10.0.0.0/16"

  azs             = ["us-east-1a", "us-east-1b"]
  private_subnets = ["10.0.1.0/24", "10.0.2.0/24"]
  public_subnets  = ["10.0.101.0/24", "10.0.102.0/24"]

  enable_nat_gateway = true
  enable_vpn_gateway = true

  tags = {
    Terraform = "true"
    Environment = "dev"
  }
}
```
Question 7hardmultiple choice
Full question →

Refer to the exhibit. An engineer runs 'terraform plan' and receives an error: 'Error refreshing state: state data in S3 does not have the expected content.' The state file exists and is not corrupted. What is the most likely cause?

Exhibit

terraform {
  backend "s3" {
    bucket         = "my-terraform-state"
    key            = "prod/terraform.tfstate"
    region         = "us-east-1"
    dynamodb_table = "terraform-locks"
    encrypt        = true
  }
}

resource "aws_instance" "web" {
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "t2.micro"
}
Question 8hardmultiple choice
Full question →

An operator runs terraform apply and receives the exhibit error. The instance was created but Terraform reports a failure. What is the most likely cause?

Exhibit

Refer to the exhibit.

```
Error: Error applying plan!

  on main.tf line 12, in resource "aws_instance" "web":
  12:   ami = "ami-0c55b159cbfafe1f0"

The resource "aws_instance" "web" was successfully created but failed to initialize after creation. The following errors may help:

Error: timeout - last error: SSH connection failed (unreachable)
```
Question 9hardmultiple choice
Full question →

Refer to the exhibit. A user runs `terraform plan` and receives this error. The user is using a local backend. Which of the following is the most likely cause?

Exhibit

Error: Error loading state: 
    Terraform state file does not exist.
Question 10mediummultiple choice
Full question →

Refer to the exhibit. A user attempts to run terraform apply with this configuration. What error will occur?

Exhibit

provider "aws" {
  region = "us-east-1"
}

resource "aws_s3_bucket" "mybucket" {
  bucket = "my-unique-bucket-12345"
  acl    = "private"
}

resource "aws_s3_bucket" "mybucket" {
  bucket = "my-unique-bucket-67890"
  acl    = "public-read"
}
Question 11easymultiple choice
Full question →

Refer to the exhibit. What does the output indicate?

Exhibit

$ terraform state list
aws_vpc.main
aws_subnet.public
aws_instance.web
Question 12easymultiple choice
Full question →

Refer to the exhibit. What will happen when terraform plan is run?

Exhibit

resource "aws_s3_bucket" "example" {}
Question 13hardmultiple choice
Full question →

Refer to the exhibit. A developer runs terraform plan and sees "No changes". However, the developer knows that manual changes were made to the infrastructure outside Terraform. What is the most likely reason terraform plan does not detect the drift?

Exhibit

$ terraform init
Initializing the backend...

Successfully configured the backend "s3"! Terraform will automatically
use this backend for state storage.

Initializing provider plugins...
- Finding latest version of hashicorp/aws...
- Installing hashicorp/aws v4.0.0...
- Installed hashicorp/aws v4.0.0 (signed by HashiCorp)

Terraform has been successfully initialized!

$ terraform plan

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration
and found no differences, so no changes are needed.
Question 14easymultiple choice
Full question →

Refer to the exhibit. A developer runs `terraform apply` and the operation succeeds. Later, they manually terminate the EC2 instance through the AWS console. What will happen when the developer runs `terraform apply` again?

Exhibit

Refer to the exhibit.
```hcl
resource "aws_instance" "web" {
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "t2.micro"

  tags = {
    Name = "WebServer"
  }
}

resource "aws_eip" "ip" {
  instance = aws_instance.web.id
}
```
Question 15mediummultiple choice
Full question →

Refer to the exhibit. The user runs 'terraform plan' and sees that Terraform wants to create the instance. However, the instance already exists in the AWS account with the same configuration. What is the most likely reason?

Exhibit

resource "aws_instance" "example" {
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "t2.micro"
}

These TF-004 practice questions are part of Courseiva's free HashiCorp certification practice question bank. Courseiva provides original exam-style TF-004 questions with detailed explanations, topic-based practice, mock exams, readiness tracking, and study analytics.