0
0
Terraformcloud~20 mins

Module structure and conventions in Terraform - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Terraform Module Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Terraform Module Inputs

Which of the following correctly describes how to define an input variable in a Terraform module?

Aparameter "region" { default = "us-west-1" }
Binput "region" { type = string default = "us-west-1" }
Cvar region = "us-west-1"
Dvariable "region" { type = string default = "us-west-1" }
Attempts:
2 left
💡 Hint

Terraform uses a specific block keyword to declare variables.

Configuration
intermediate
2:00remaining
Correct Output Declaration in Terraform Module

Which option correctly defines an output named instance_ip in a Terraform module?

Aoutput instance_ip = aws_instance.web.private_ip
Boutput "instance_ip" { value = aws_instance.web.private_ip }
Coutput "instance_ip" = aws_instance.web.private_ip
Doutput { name = "instance_ip" value = aws_instance.web.private_ip }
Attempts:
2 left
💡 Hint

Outputs use a block with a name and a value attribute.

Architecture
advanced
2:30remaining
Best Practice for Module Directory Structure

Which directory structure follows Terraform best practices for a reusable module named network?

A
network/
  main.tf
  variables.tf
  outputs.tf
  README.md
B
network/
  network.tf
  inputs.tf
  results.tf
  docs.md
C
network/
  main.tf
  vars.tf
  outs.tf
  README.md
D
network/
  terraform.tf
  variables.tf
  outputs.tf
  README.md
Attempts:
2 left
💡 Hint

Look for standard file names used in Terraform modules.

security
advanced
2:00remaining
Handling Sensitive Variables in Terraform Modules

Which option correctly marks a variable as sensitive in a Terraform module to avoid showing its value in logs?

Avariable "db_password" { type = string private = true }
Bvariable "db_password" { type = string hidden = true }
Cvariable "db_password" { type = string sensitive = true }
Dvariable "db_password" { type = string secret = true }
Attempts:
2 left
💡 Hint

Terraform uses a specific attribute to mark variables as sensitive.

service_behavior
expert
3:00remaining
Effect of Module Source Changes on Terraform State

You update the source attribute of a Terraform module to point to a new version. What happens to the existing resources managed by the old module version when you run terraform apply?

ATerraform treats the new module as a separate resource set and plans to create new resources while keeping old ones unless explicitly destroyed.
BTerraform ignores the source change and continues using the old module version until manually refreshed.
CTerraform deletes all old resources immediately before applying the new module changes.
DTerraform automatically updates existing resources in place to match the new module source without recreating them.
Attempts:
2 left
💡 Hint

Think about how Terraform tracks resources and modules in state files.