Courseiva

TF-004 · topic practice

Interact with Terraform modules practice questions

Practise HashiCorp Terraform Associate TF-004 Interact with Terraform modules practice questions — original exam-style scenarios with answer choices, explanations, and analysis of common mistakes.

Courseiva uses original exam-style practice questions designed for learning and revision. The goal is to understand the concepts, recognise exam patterns, and improve through explanations — not memorise copied exam dumps.

Reviewed byJohnson Ajibi· MSc IT Security
20 questionsDomain: Interact with Terraform modules

What the exam tests

What to know about Interact with Terraform modules

Interact with Terraform modules questions test whether you can apply the concept in context, not just recognise a definition.

How the topic appears in realistic exam-style scenarios.

Which detail in the question changes the correct answer.

How to eliminate plausible but wrong options.

How to connect the question back to the wider exam objective.

Watch out for

Common Interact with Terraform modules exam traps

  • Answering from memory before reading the full scenario.
  • Missing a constraint such as cost, availability, security, scope or command context.
  • Choosing a broad answer when the question asks for the most specific fix.
  • Ignoring why the wrong options are tempting.

Practice set

Interact with Terraform modules questions

20 questions · select your answer, then reveal the explanation

A team is using a module from the public Terraform Registry. They want to ensure that the module is pinned to a specific version to avoid unexpected changes. Which approach should they use?

Which TWO statements about Terraform module sources are correct? (Select TWO.)

Which THREE practices are recommended when using Terraform modules? (Select THREE.)

The above configuration references a module from the Terraform Registry. After running 'terraform init', the user runs 'terraform plan' and gets an error: 'Error: Unsupported argument' for 'version'. What is the most likely cause?

Exhibit

Refer to the exhibit.

```hcl
module "vpc" {
  source = "terraform-aws-modules/vpc/aws"
  version = "3.19.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"]
}

output "vpc_id" {
  value = module.vpc.vpc_id
}
```

Which TWO statements about Terraform module structure and best practices are correct? (Choose two.)

Your company manages infrastructure for multiple environments (dev, staging, prod) using Terraform. You have a shared networking module stored in a private Git repository. The module is used by several root configurations. The current workflow requires developers to manually update the module version in each root module's source attribute when a new version is tagged. This has led to configuration drift and occasional use of incompatible module versions. You want to implement a more reliable approach that ensures all environments use the same consistent version of the module, while still allowing controlled upgrades. Which approach best addresses this concern?

Which three of the following describe correct practices or behaviors when interacting with Terraform modules? (Choose three.)

Which TWO module source types are supported by Terraform natively?

Given the plan output, how is the module 'instances' configured in the root module?

Exhibit

Refer to the exhibit.

```
Terraform will perform the following actions:

  # module.instances["web"].aws_instance.this will be created
  + resource "aws_instance" "this" {
      + ami                          = "ami-123456"
      + instance_type                = "t2.micro"
      + subnet_id                    = (known after apply)
      ...
    }

  # module.instances["app"].aws_instance.this will be created
  + resource "aws_instance" "this" {
      + ami                          = "ami-789012"
      + instance_type                = "t2.small"
      + subnet_id                    = (known after apply)
      ...
    }

Plan: 2 to add, 0 to change, 0 to destroy.
```

Which of the following files is NOT required in a Terraform module?

You have a list of VPC configurations and want to create multiple VPCs using a single module block with for_each. Which statement is true?

Which module source type does NOT support version constraints?

Which TWO of the following are valid ways to reference a module from the Terraform Registry?

You are developing a module. Which TWO actions are recommended best practices?

A company uses a Terraform module from the registry for AWS VPC (source = "terraform-aws-modules/vpc/aws", version = "3.0.0"). They updated the module version to "3.1.0" and ran terraform plan. To their surprise, the plan shows that all VPC resources will be replaced (destroyed and recreated) instead of updated in place. They did not change any input variables. The module's release notes mention only bug fixes and minor improvements. What is most likely causing the full resource replacement?

A team has a root module that calls a local module using count to conditionally create an AWS RDS instance based on a boolean variable `rds_enabled`. The root module sets `rds_enabled` to the value of a data source that checks if a tag exists on an S3 bucket. The relevant code is: `count = var.rds_enabled ? 1 : 0`. When they run terraform plan, they receive the error: "Error: Invalid count argument: The count value is not yet known". The S3 bucket already exists. What is the underlying issue?

Question 17mediummultiple choice
Review the full subnetting walkthrough →

An engineer is refactoring a monolithic Terraform configuration into reusable modules. One module outputs a list of subnet IDs. Another module needs to use these subnet IDs to create resources. What is the best way to pass this data between modules?

A developer creates a module that provisions an AWS EC2 instance and an S3 bucket. The module outputs the instance ID and bucket ARN. When using this module, the root configuration references module.my_module.instance_id and module.my_module.bucket_arn. After running terraform apply, they notice that the bucket ARN is empty. What is the most likely cause?

After running 'terraform apply', the user sees that the 'aws_s3_bucket_object' is created successfully, but the bucket name is not as expected. What is the most likely reason?

Exhibit

Refer to the exhibit.

```hcl
module "bucket" {
  source = "./modules/s3-bucket"
  bucket_name = "my-app-data"
}

resource "aws_s3_bucket_object" "config" {
  bucket = module.bucket.bucket_name
  key    = "config.json"
  source = "config.json"
}
```

The module at './modules/s3-bucket' contains:

```hcl
variable "bucket_name" {}
resource "aws_s3_bucket" "this" {
  bucket = var.bucket_name
}
output "bucket_name" {
  value = aws_s3_bucket.this.id
}
```

You are a DevOps engineer at a company that manages infrastructure for multiple environments (dev, staging, prod) using Terraform. The team has created a reusable module for deploying an AWS ECS Fargate service. The module accepts variables for environment name, container image tag, and desired count. The module is stored in a private Git repository. The root configurations for each environment are stored in separate directories, each with its own backend configuration. Recently, a developer added a new feature to the module that requires a new variable 'enable_xray' (boolean, default false). After updating the module source to point to the new commit, the developer runs 'terraform init' and 'terraform plan' in the dev environment. The plan shows that the ECS service will be updated, but the output does not show any changes related to X-Ray. The developer expected that setting 'enable_xray = true' in the dev root module would enable X-Ray tracing. However, the plan shows no changes to the task definition. What is the most likely cause?

Free account

Track your progress over time

Create a free account to save your results and see which topics improve across sessions.

Focused Interact with Terraform modules sessions

Start a Interact with Terraform modules only practice session

Every question in these sessions is drawn from the Interact with Terraform modules domain — nothing else.

Related practice questions

Related TF-004 topic practice pages

Move into related areas when this topic feels solid.

Frequently asked questions

What does the TF-004 exam test about Interact with Terraform modules?
Interact with Terraform modules questions test whether you can apply the concept in context, not just recognise a definition.
How should I use these practice questions?
Select your answer before revealing the explanation. Then read why each option is right or wrong — this active recall approach builds retention far faster than re-reading notes.
Can I practise just Interact with Terraform modules questions in a focused session?
Yes — the session launcher on this page draws every question from the Interact with Terraform modules domain. Use a 10-question session first to gauge your baseline, then move to 20 or 30 once the weak spots are clear.
Where can I practise other TF-004 topics?
Use the topic links above to move to related areas, or go back to the TF-004 question bank to see all topics.
Are these real exam questions or dumps?
These are original practice questions written to test the same concepts the TF-004 exam covers. They are not copied from any real exam or dump site.