Challenge - 5 Problems
Terraform Formatting Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ service_behavior
intermediate2:00remaining
What is the effect of running
terraform fmt on a Terraform project?You have a Terraform project with inconsistent indentation and spacing. What does running
terraform fmt do to the project files?Attempts:
2 left
💡 Hint
Think about a tool that cleans up code style without changing its meaning.
✗ Incorrect
terraform fmt automatically rewrites Terraform files to follow a standard style, making code easier to read and maintain. It does not validate syntax or apply changes.
❓ Configuration
intermediate2:00remaining
Which command formats Terraform files recursively in all subdirectories?
You want to format all Terraform files in the current directory and all nested folders. Which
terraform fmt command option achieves this?Attempts:
2 left
💡 Hint
Look for the official flag that means 'go into all folders'.
✗ Incorrect
The -recursive flag tells terraform fmt to format files in the current directory and all subdirectories.
🧠 Conceptual
advanced2:00remaining
What happens if
terraform fmt is run on a file with syntax errors?Consider a Terraform file with a missing closing brace. What will
terraform fmt do when run on this file?Attempts:
2 left
💡 Hint
Think about whether formatting tools fix code logic or just style.
✗ Incorrect
terraform fmt requires valid syntax to parse the file. If syntax errors exist, it reports an error and does not format.
✅ Best Practice
advanced2:00remaining
Why is it recommended to run
terraform fmt before committing code to version control?What is the main benefit of running
terraform fmt on your Terraform files before pushing changes to a shared repository?Attempts:
2 left
💡 Hint
Think about how consistent formatting helps teams work together.
✗ Incorrect
Consistent formatting reduces noise in version control diffs and helps team members read and review code more easily.
❓ Architecture
expert2:00remaining
In a CI/CD pipeline, where should
terraform fmt be integrated for best practice?You are designing a CI/CD pipeline for Terraform infrastructure code. At which stage should
terraform fmt be run to ensure code quality and prevent style issues from merging?Attempts:
2 left
💡 Hint
Consider automation that prevents bad code from entering the main branch.
✗ Incorrect
Running terraform fmt as an automated check in the CI pipeline before merging ensures all code meets style standards without relying on manual steps.