Bitzu

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

Single choice

How must a relative local path module source begin?

  1. With ./ or ../
  2. With file::
  3. With local::
  4. 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.

Select all that apply

Which of these are supported module source types?

  1. A local directory such as ./modules/vpc
  2. The public Terraform Registry
  3. An S3 bucket object using the s3:: prefix
  4. A Docker image registry
  5. 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

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.

Download on the App StoreGet it on Google Play

More Terraform Associate 004 topics in this module