Courseiva
Free · No account needed · No credit card

HashiCorp Terraform Associate TF-004 Practice Test

434 questions with instant explanations, domain breakdown, and wrong-answer analysis. Built for the real exam.

Instant feedback after each answer
Full explanations included
Domain score breakdown
Real exam: 60 min
Pass mark: 700/1000

Sample questions with explanations

This is exactly what you see during practice — question, options, and a full explanation after you answer.

Q1Read, generate and modify configurationmedium
Full explanation →

A team is using Terraform to manage a multi-tier application on AWS. The configuration includes resources for VPC, subnets, security groups, and EC2 instances. Recently, a developer manually created an additional security group in the AWS console for testing, and now the team wants to manage it via Terraform. They have updated the configuration to include this security group with the same name and rules. When they run `terraform plan`, it shows that the security group will be created, but the existing one is not detected. They want to bring the existing security group under Terraform management without recreating it. The team is using a remote backend with state locking. What should they do?

ARun `terraform apply` and then modify the state to remove the duplicate.
BManually edit the Terraform state file to add the security group.
CRun `terraform refresh` to update the state with the existing resource.
Use `terraform import` to import the existing security group into state.Correct

`terraform import` is the purpose-built command for adopting resources that already exist outside of Terraform into the state file without destroying and recreating them. Running `terraform import aws_security_group.example sg-xxxxxxxx` maps the real AWS security group to the res…Read full explanation

Q2Interact with Terraform moduleseasy
Full explanation →

A team is using a module from the Terraform Registry and wants to ensure they always get the latest patch version of the 3.2.x series. Which version constraint should they use?

A~> 3.2
B3.2.*
~> 3.2.0Correct
D>= 3.2, < 4.0

The `~>` (pessimistic constraint) operator in Terraform allows only the rightmost version component to increment. For `~> 3.2.0`, this means any version >= 3.2.0 and < 3.3.0, which precisely matches the requirement for the latest patch within the 3.2.x series. Option C is correct…Read full explanation

Q3Implement and maintain statemedium
Full explanation →

A DevOps engineer manages infrastructure with Terraform using an S3 backend with DynamoDB locking. During a `terraform apply`, the engineer's network connection drops. After reconnecting, they run `terraform plan` and get an error: "Error acquiring the state lock." The lock is from the previous session. The engineer has verified that no other operations are running. What is the appropriate next step to proceed?

ADelete the DynamoDB table and recreate it
BWait 15 minutes for the lock to expire automatically
Use `terraform force-unlock <lock_id>` to remove the stale lockCorrect
DRun `terraform init` to reset the backend connection

`terraform force-unlock` is the intended mechanism to manually remove a stale lock from the DynamoDB table when the process that held the lock has terminated abnormally. The engineer has confirmed no other operations are running, so the lock is orphaned and safe to remove. This c…Read full explanation

Untimed Practice

Answer at your own pace. Explanation and domain tag shown immediately after each answer.

Timed Practice

Countdown timer starts immediately. Results and domain scores shown at the end — just like the real exam.

Why practice here?

Full explanations on every question

Not just the right answer — you get exactly why each wrong option is wrong, so you learn the concept, not the answer.

Domain score breakdown

After each session see your score by exam domain so you know exactly where to focus study time.

100% free, forever

No subscription, no trial, no email wall. Start a session in under 10 seconds.

Exam-style questions

Scenario-based, precise wording, realistic distractors — written to match what you actually see on exam day.

← All TF-004 questionsTF-004 exam guideStudy guidePractice by domain