TF-004 Interact with Terraform modules Practice Question
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"
}
}
```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?
⚠ Common exam trap
HashiCorp often tests the concept that module arguments are version-dependent, and the trap here is that candidates may assume the argument name is misspelled or that the module lacks the feature entirely, rather than recognizing that the module version simply does not include that variable yet.
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 module version '3.18.0' does not include the 'enable_vpn_gateway' variable; it was added in a later version.
The error message indicates that the module does not support the 'enable_vpn_gateway' argument. In Terraform, module arguments are defined by the module's published variables. The module version '3.18.0' predates the introduction of the 'enable_vpn_gateway' variable, which was added in a later version. Upgrading the module version to one that includes this variable resolves the error.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
The argument name is misspelled; it should be 'enable_vpn' instead.
Why it's wrong here
The argument name 'enable_vpn_gateway' is not a misspelling; it is a distinct and valid variable name introduced in later versions of the `terraform-aws-vpc` module. The error arises not from a typographical mistake, but from the fact that this specific variable did not exist in the module's API at version '3.18.0'. Therefore, suggesting it should be 'enable_vpn' implies a different variable or a non-existent correction for the actual problem.
- ✓
The module version '3.18.0' does not include the 'enable_vpn_gateway' variable; it was added in a later version.
Why this is correct
This option correctly identifies the root cause. When a module is explicitly pinned to a specific version, such as '3.18.0', Terraform strictly adheres to the variables and outputs defined within that exact module release. The `enable_vpn_gateway` variable was introduced in a subsequent version of the `terraform-aws-vpc` module, meaning it is not recognized or available in version '3.18.0', leading to an 'Unsupported Argument' or 'Undefined Variable' error during plan or apply.
- ✗
The module does not support VPN gateways at all.
Why it's wrong here
This statement is incorrect because the `terraform-aws-vpc` module, particularly in its more recent iterations, does indeed provide comprehensive support for VPN gateways. While version '3.18.0' might lack the specific `enable_vpn_gateway` variable, the module has evolved to include robust functionality for configuring various VPN solutions, often through dedicated variables or sub-modules introduced in later releases to enhance network connectivity options.
- ✗
The module source is incorrectly specified; it should use a git URL instead of the registry path.
Why it's wrong here
The module source `hashicorp/aws/vpc` is correctly specified for referencing a public module hosted on the Terraform Registry. This standard syntax indicates the module's namespace (hashicorp), provider (aws), and name (vpc). While Terraform supports using Git URLs for private or custom modules, it is not required or inherently more correct for registry modules, and changing it would fundamentally alter the module's source location, not resolve a variable versioning issue.
Visual reference
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.