What is the main benefit of using Terragrunt with Terraform?
Think about how Terragrunt helps when you have many similar infrastructure setups.
Terragrunt is a tool that helps keep Terraform configurations DRY (Don't Repeat Yourself) by allowing you to reuse and manage common settings in one place.
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?
remote_state {
backend = "s3"
config = {
bucket = "my-terraform-state"
key = "global/terraform.tfstate"
region = "us-east-1"
}
}Look for the syntax that references the parent's remote_state block after including it.
In Terragrunt, after including a parent configuration with include, you can access its blocks using include.get(). This allows child modules to inherit settings like remote_state without redefining them.
You want to manage Terraform infrastructure for two environments: dev and prod. Using Terragrunt, which folder structure best supports DRY principles and environment isolation?
Think about where Terragrunt files should be placed to share common configs and separate environments.
Terragrunt encourages a folder structure where a root terragrunt.hcl holds shared configs, and environment folders have their own terragrunt.hcl files to override or add environment-specific settings. This keeps code DRY and environments isolated.
Which approach best protects sensitive variables like passwords when using Terragrunt with Terraform?
Think about how to keep secrets safe and avoid exposing them in code repositories.
Best practice is to avoid storing sensitive data in code files. Instead, use environment variables or secret management tools and reference those securely in Terragrunt configurations.
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?
Think about how Terragrunt manages dependencies between modules automatically.
Terragrunt automatically applies dependency modules first to ensure their outputs are available for the current module. This helps manage complex infrastructure with dependencies smoothly.