0
0
Terraformcloud~20 mins

Terragrunt for DRY configurations in Terraform - Practice Problems & Coding Challenges

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

What is the main benefit of using Terragrunt with Terraform?

AIt helps avoid repeating the same Terraform code by managing configurations centrally.
BIt automatically scales cloud resources based on traffic.
CIt replaces Terraform and runs cloud infrastructure without code.
DIt provides a graphical interface to design cloud infrastructure visually.
Attempts:
2 left
💡 Hint

Think about how Terragrunt helps when you have many similar infrastructure setups.

Configuration
intermediate
2:00remaining
Terragrunt Configuration Inheritance

Given a Terragrunt configuration file terragrunt.hcl that includes a remote_state block, which option correctly shows how to inherit this remote state configuration in a child module?

Terraform
remote_state {
  backend = "s3"
  config = {
    bucket = "my-terraform-state"
    key    = "global/terraform.tfstate"
    region = "us-east-1"
  }
}
A
include {
  path = find_in_parent_folders()
}

remote_state = include.get().remote_state
B
include {
  path = find_in_parent_folders()
}

remote_state {
  backend = "s3"
  config = {
    bucket = "my-terraform-state"
    key    = "global/terraform.tfstate"
    region = "us-east-1"
  }
}
C
include {
  path = find_in_parent_folders()
}

remote_state = local.remote_state
D
remote_state {
  backend = "s3"
  config = {
    bucket = "my-terraform-state"
    key    = "global/terraform.tfstate"
    region = "us-east-1"
  }
}
Attempts:
2 left
💡 Hint

Look for the syntax that references the parent's remote_state block after including it.

Architecture
advanced
2:00remaining
Terragrunt Folder Structure for Multiple Environments

You want to manage Terraform infrastructure for two environments: dev and prod. Using Terragrunt, which folder structure best supports DRY principles and environment isolation?

A
/terraform/
  /dev/
    main.tf
  /prod/
    main.tf
  terragrunt.hcl
B
/modules/
  /dev/
    main.tf
  /prod/
    main.tf
C
/live/
  /dev/
    terragrunt.hcl
  /prod/
    terragrunt.hcl
  terragrunt.hcl
D
/live/
  /dev/
    main.tf
  /prod/
    main.tf
Attempts:
2 left
💡 Hint

Think about where Terragrunt files should be placed to share common configs and separate environments.

security
advanced
2:00remaining
Securing Sensitive Variables in Terragrunt

Which approach best protects sensitive variables like passwords when using Terragrunt with Terraform?

AStore sensitive variables directly in <code>terragrunt.hcl</code> files in plain text.
BUse environment variables or encrypted secrets managers and reference them in Terragrunt configs.
CCommit sensitive variables in Terraform <code>.tf</code> files to version control for easy access.
DHardcode sensitive values in Terraform modules to avoid passing them through Terragrunt.
Attempts:
2 left
💡 Hint

Think about how to keep secrets safe and avoid exposing them in code repositories.

service_behavior
expert
2:00remaining
Terragrunt Behavior with Dependency Blocks

Consider this Terragrunt configuration snippet:

dependency "vpc" {
  config_path = "../vpc"
}

inputs = {
  vpc_id = dependency.vpc.outputs.vpc_id
}

What happens if the ../vpc module has not been applied yet when you run Terragrunt in this module?

ATerragrunt ignores the dependency and applies the current module without the <code>vpc_id</code> input.
BTerragrunt fails with an error because the dependency outputs are missing.
CTerragrunt prompts the user to manually apply the dependency module before continuing.
DTerragrunt automatically applies the <code>../vpc</code> module first, then uses its outputs.
Attempts:
2 left
💡 Hint

Think about how Terragrunt manages dependencies between modules automatically.