Certifications / Terraform Associate 004 · Domain 5: Terraform modules · 12% of the exam
Where module code comes from: local paths, the public and private registries, Git and other VCS addresses, HTTP archives and cloud storage, and what terraform init does with each.
Try each one before opening the answer. Every option is explained, with the HashiCorp documentation page that proves it.
Question 1 · choose 1
A team finds a module named "vpc" for the aws provider, published by the "terraform-aws-modules" namespace in the public Terraform Registry. Which source argument installs it? A source = "aws/vpc/terraform-aws-modules"B source = "terraform-aws-modules/vpc/aws"C source = "registry::terraform-aws-modules/vpc"D source = "https://registry.terraform.io/modules/terraform-aws-modules/vpc/aws"Show the answer and why A source = "aws/vpc/terraform-aws-modules"
Incorrect
The order is namespace, name, provider.
B source = "terraform-aws-modules/vpc/aws"
Correct
Public registry modules use the <NAMESPACE>/<NAME>/<PROVIDER> source format.
C source = "registry::terraform-aws-modules/vpc"
Incorrect
There is no registry:: prefix, and the provider part is missing.
D source = "https://registry.terraform.io/modules/terraform-aws-modules/vpc/aws"
Incorrect
Registry modules are addressed by namespace, name and provider, not by their web page URL.
Public registry addresses have three parts: namespace, module name and provider.
Question 2 · choose 1
Where does Terraform put the code of remote modules that a configuration calls? A In the state file, next to the resourcesB In a hidden subdirectory, during terraform initC In the settings of the HCP Terraform workspaceD Nowhere; Terraform reads remote modules over the network on every planShow the answer and why A In the state file, next to the resources
Incorrect
State stores bindings, not module code.
B In a hidden subdirectory, during terraform init
Correct
Initializing installs the module by cloning its source into a hidden subdirectory of the working directory.
C In the settings of the HCP Terraform workspace
Incorrect
Workspace settings hold run options and variables, not module code.
D Nowhere; Terraform reads remote modules over the network on every plan
Incorrect
Modules are downloaded once and reused.
init downloads modules once into .terraform; plans use the local copy.
HashiCorp documentation
State overview (terraform.tfstate, JSON format, do not edit by hand) (opens in a new tab) Module sources (local paths, registry, GitHub, Git, HTTP, S3, GCS; ref and subdirectories) (opens in a new tab) terraform get command (download modules only) (opens in a new tab) Workspace settings (execution mode, apply method, Terraform version, remote state sharing) (opens in a new tab) Question 3 · choose 1
A public module lives at github.com/example-org/terraform-network. Which source form does Terraform recognize for GitHub without a git:: prefix? A gh:example-org/terraform-network?type=gitB example-org/terraform-network/githubC github.com/example-org/terraform-networkD github::terraform-networkShow the answer and why A gh:example-org/terraform-network?type=git
Incorrect
There is no gh: prefix.
B example-org/terraform-network/github
Incorrect
That looks like a registry address, not a GitHub URL.
C github.com/example-org/terraform-network
Correct
Terraform recognizes unprefixed github.com URLs and clones them with Git.
D github::terraform-network
Incorrect
There is no github:: prefix.
GitHub addresses are a shortcut for Git sources.
Question 4 · choose 1
A private Git repository is reachable over SSH with the agent's key. Which form does the documentation recommend for the source URL? A git::ssh://git@git.example.com/infra/network.gitB ssh://git.example.com:infra/networkC git::https://git.example.com/infra/network.git?ssh=trueD scp://git.example.com/infra/network.gitShow the answer and why A git::ssh://git@git.example.com/infra/network.git
Correct
The docs recommend the ssh://-prefixed URL for consistency, although an scp-like form also works.
B ssh://git.example.com:infra/network
Incorrect
Without git:: and a valid URL, Terraform cannot tell it is a Git source.
C git::https://git.example.com/infra/network.git?ssh=true
Incorrect
There is no ssh query parameter.
D scp://git.example.com/infra/network.git
Incorrect
scp:// is not a module source scheme.
git:: plus an ssh:// URL is the clearest way to reach private Git modules.
Question 5 · choose 1
A module source is git::https://git.example.com/infra/dns.git with no query parameters. What does Terraform install? A The newest tag in the repositoryB Nothing; a revision must always be givenC Every branch in the repository, letting the plan choose one per resourceD The default branch referenced by HEADShow the answer and why A The newest tag in the repository
Incorrect
Tags are not searched; the default branch is used.
B Nothing; a revision must always be given
Incorrect
The default branch is used when no revision is given.
C Every branch in the repository, letting the plan choose one per resource
Incorrect
One revision is checked out.
D The default branch referenced by HEAD
Correct
For a Git source without extra parameters, Terraform clones and uses the default branch referenced by HEAD.
Without a pinned revision, the module changes whenever HEAD moves.
Question 6 · choose 1
A vendor distributes a module as https://downloads.example.com/net.zip. Can Terraform use this URL as a module source? A Yes; recognized archive URLs are downloaded and extractedB No; HTTPS sources must be Git repositoriesC Yes, but only through the private registryD No; archives must be extracted into the root module's directory by hand firstShow the answer and why A Yes; recognized archive URLs are downloaded and extracted
Correct
When an HTTPS URL has a common archive extension, Terraform uses the archive's contents as the module source.
B No; HTTPS sources must be Git repositories
Incorrect
Archives over HTTPS are supported.
C Yes, but only through the private registry
Incorrect
The URL works directly as a source.
D No; archives must be extracted into the root module's directory by hand first
Incorrect
Terraform extracts supported archives itself.
HTTP(S) archives are one of the many module source types.
Practice domain 5 → Practice all domains →
← Task 4.8 Task 5.2 →