Terraform Associate 004 ยท Terraform modules
Where can a Terraform module come from?
Local paths, public and private registry, Git, HTTP, S3 and GCS sources, source address formats, terraform get/init downloading (5a).
Key points
- The source argument accepts a local path (./ or ../), the public registry (NAMESPACE/NAME/PROVIDER), a private registry (hostname prefix), GitHub shorthand, Git (git:: prefix, optional ?ref=), HTTP/HTTPS URLs, and s3:: or gcs:: buckets.
- Use // to pick a subdirectory.
- Modules are downloaded by terraform init (or terraform get).
Source: https://developer.hashicorp.com/terraform/language/block/module
Practice questions
How must a relative local path module source begin?
- With ./ or ../
- With file::
- With local::
- With path::
Show answer
Answer: A. With ./ or ../
Local paths start with ./ or ../ so Terraform does not mistake them for registry addresses. The other prefixes do not exist.
Which of these are supported module source types?
- A local directory such as ./modules/vpc
- The public Terraform Registry
- An S3 bucket object using the s3:: prefix
- A Docker image registry
- An Ansible Galaxy role
Show answer
Answer: A. A local directory such as ./modules/vpc, B. The public Terraform Registry, C. An S3 bucket object using the s3:: prefix
Local paths, registries and s3:: buckets are supported. Container image registries and Ansible Galaxy are not module sources.
True or false: Terraform downloads remote modules for the first time during terraform apply.
Show answer
Answer: False
False. Modules are installed during terraform init (or terraform get), before plan and apply.
Practice 8 questions on this topic in Bitzu
Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.
