Question 111 of 519
Understand Terraform's purposehardMultiple ChoiceObjective-mapped

Quick Answer

The answer is that the local-exec provisioner outputs an empty public IP because the aws_instance resource was launched in a default VPC without auto-assign public IP enabled and no Elastic IP is attached. This occurs because the local-exec provisioner runs on the machine executing Terraform, not on the instance itself, so it simply reads the `self.public_ip` attribute directly from the resource state—and when no public IP is assigned, that attribute is an empty string. On the HashiCorp Terraform Associate TF-003 exam, this question tests your understanding that provisioners execute locally and reflect whatever value Terraform has stored, not what the instance might dynamically obtain. A common trap is assuming the provisioner runs inside the instance or that AWS always assigns a public IP in a VPC. Memory tip: provisioners are local mirrors, not remote executors—if the state says empty, the output says empty.

TF-003 Understand Terraform's purpose Practice Question

This TF-003 practice question tests your understanding of understand terraform's purpose. This is a configuration task: choose the command set that satisfies every stated requirement. Small differences — like 'secret' vs 'password' or 'transport input ssh' vs 'all' — change whether the answer is correct. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.

Exhibit

Refer to the exhibit.

```hcl
resource "aws_instance" "web" {
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "t2.micro"
}

resource "null_resource" "provisioner" {
  provisioner "local-exec" {
    command = "echo ${aws_instance.web.public_ip}"
  }
}
```

A team member runs terraform apply with the configuration shown in the exhibit. The apply succeeds, but the output of the local-exec provisioner shows an empty string for the public IP address. What is the most likely cause?

Clue words in this question

Noticing these words before you look at the options changes how you read each choice.

  • Clue: "most likely"

    Why it matters: Probability qualifier — the question wants the most probable cause or outcome, not a guaranteed one. Eliminate low-probability options.

Question 1hardmultiple choice
Full question →

Exhibit

Refer to the exhibit.

```hcl
resource "aws_instance" "web" {
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "t2.micro"
}

resource "null_resource" "provisioner" {
  provisioner "local-exec" {
    command = "echo ${aws_instance.web.public_ip}"
  }
}
```

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

The aws_instance resource does not have a public IP assigned because it is launched in a default VPC without auto-assign public IP, and no Elastic IP is attached.

Option C is correct because the `local-exec` provisioner runs on the machine executing Terraform, not on the AWS instance itself. If the instance is launched in a default VPC without `auto-assign public IP` enabled and no Elastic IP is attached, the `self.public_ip` attribute will be an empty string. The provisioner then outputs that empty string, as it simply reads the attribute value from the resource state.

Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • There is a dependency cycle between the aws_instance and null_resource causing Terraform to skip the provisioner.

    Why it's wrong here

    No cycle exists; the provisioner depends on the instance, which is valid.

  • The local-exec provisioner only runs during terraform destroy, not during apply.

    Why it's wrong here

    Provisioners run during create and destroy unless specified otherwise.

  • The aws_instance resource does not have a public IP assigned because it is launched in a default VPC without auto-assign public IP, and no Elastic IP is attached.

    Why this is correct

    Without explicit configuration, the instance may not get a public IP, leaving the attribute empty.

    Clue confirmation

    The clue word "most likely" in the question point toward this answer.

    Related concept

    Read the scenario before looking for a memorised answer.

  • The provisioner cannot access the aws_instance resource's attributes because it is defined in a separate resource block.

    Why it's wrong here

    Provisioners can reference other resources using interpolation.

Common exam traps

Common exam trap: answer the scenario, not the keyword

HashiCorp often tests the misconception that `local-exec` runs on the remote instance or that `self.public_ip` is always populated, when in reality it depends on the network configuration and the provisioner's execution context.

Detailed technical explanation

How to think about this question

Under the hood, `self.public_ip` is derived from the AWS EC2 API response; if the instance has no public IP, the attribute is an empty string. In a default VPC, instances launched without `associate_public_ip_address = true` or an Elastic IP will only receive a private IP. This is a common pitfall when testing locally without a public subnet configuration, leading to empty outputs from provisioners that expect a public IP.

KKey Concepts to Remember

  • Read the scenario before looking for a memorised answer.
  • Find the constraint that changes the correct option.
  • Eliminate answers that are true in general but not in this case.

TExam Day Tips

  • Watch for words such as best, first, most likely and least administrative effort.
  • Review why wrong options are wrong, not only why the correct option is correct.

Key takeaway

Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Real-world example

How this comes up in practice

A practitioner preparing for the TF-003 exam encounters this exact type of scenario on the job. The correct answer here is not the most general option — it is the best answer for the specific constraint described. Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option. Real exam questions reward reading the full scenario before eliminating options, because the constraint defines which answer fits.

What to study next

Got this wrong? Here's your next step.

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Related practice questions

Related TF-003 practice-question pages

Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.

Practice this exam

Start a free TF-003 practice session

Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.

FAQ

Questions learners often ask

What does this TF-003 question test?

Understand Terraform's purpose — This question tests Understand Terraform's purpose — Read the scenario before looking for a memorised answer..

What is the correct answer to this question?

The correct answer is: The aws_instance resource does not have a public IP assigned because it is launched in a default VPC without auto-assign public IP, and no Elastic IP is attached. — Option C is correct because the `local-exec` provisioner runs on the machine executing Terraform, not on the AWS instance itself. If the instance is launched in a default VPC without `auto-assign public IP` enabled and no Elastic IP is attached, the `self.public_ip` attribute will be an empty string. The provisioner then outputs that empty string, as it simply reads the attribute value from the resource state.

What should I do if I get this TF-003 question wrong?

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Are there clue words in this question I should notice?

Yes — watch for: "most likely". Probability qualifier — the question wants the most probable cause or outcome, not a guaranteed one. Eliminate low-probability options.

What is the key concept behind this question?

Read the scenario before looking for a memorised answer.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Last reviewed: Jun 30, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

This TF-003 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-003 exam.