Courseiva
Interact with Terraform moduleshardMultiple ChoiceObjective-mapped

TF-004 Interact with Terraform modules Practice Question

Exhibit

Refer to the exhibit.

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

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

A developer runs `terraform plan` and receives the error: "Error: Unsupported argument; An argument named 'enable_vpn_gateway' is not expected here." What is the most likely cause?

⚠ Common exam trap

HashiCorp often tests the distinction between errors caused by module version changes versus errors caused by source configuration issues, trapping candidates who confuse a missing variable error with a source path or registry problem.

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 5.0.0 does not support the 'enable_vpn_gateway' argument.

The error 'Unsupported argument' indicates that the module version currently in use does not define an input variable named 'enable_vpn_gateway'. In Terraform, each module version has a fixed set of input variables; if you attempt to pass an argument that is not declared in the module's variables.tf, Terraform will reject it. The most common reason for this is that the module version has been updated or changed, and the argument was removed or renamed in that version.

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 source address is misspelled 'vpc' instead of 'vpc/aws'.

    Why it's wrong here

    This option is incorrect because the error message indicates an issue with an argument within the module's configuration, not with the module's source address itself. If the module source 'vpc' were misspelled or unresolvable, Terraform would typically report an error during the `terraform init` phase, indicating it could not find or download the module. An 'unexpected argument' error, however, confirms that Terraform successfully located and initialized the module, but the provided input variable is not recognized by that specific module version.

  • The source module is not pinned to a specific version, so it may have changed.

    Why it's wrong here

    This option is incorrect because the problem statement implies the module is explicitly pinned to version 5.0.0. When a module source includes a specific `version` constraint (e.g., `version = "5.0.0"`), Terraform ensures that precisely that version is used, preventing any automatic updates or 'drift' to newer, potentially incompatible versions. Therefore, the issue cannot be attributed to an unpinned version causing unexpected changes, as the version is explicitly locked.

  • The module must be sourced from a different registry or repository.

    Why it's wrong here

    This option is incorrect because the nature of the error – an 'unexpected argument' – suggests that Terraform successfully located and initialized the module from its current source. If the module needed to be sourced from a different registry or repository, Terraform would typically fail during the `terraform init` phase with errors related to module discovery, authentication, or network accessibility. The error points to a mismatch between the provided configuration and the module's interface, not a failure to find the module itself.

  • The module version 5.0.0 does not support the 'enable_vpn_gateway' argument.

    Why this is correct

    This option is correct because an error stating an argument like 'enable_vpn_gateway' is 'unexpected' or 'not expected' for a specific module version (e.g., 5.0.0) is a direct indication of an API change. Module developers often introduce breaking changes, such as removing, renaming, or altering input variables, especially in major version increments. This means the argument was likely supported in a previous version but has since been deprecated or removed in version 5.0.0, requiring the user to update their configuration to align with the module's current interface.

About these practice questions

This TF-004 question is part of Courseiva's 428-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

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.