Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is the JSON configuration alternative in Terraform?
Terraform supports using JSON syntax as an alternative to its native HCL (HashiCorp Configuration Language) for writing configuration files.
Click to reveal answer
beginner
How do you name a Terraform JSON configuration file?
Terraform JSON configuration files must have the extension .tf.json to be recognized and processed correctly.
Click to reveal answer
intermediate
What is a key difference between HCL and JSON configurations in Terraform?
HCL is designed to be human-friendly and easier to read and write, while JSON is more verbose but can be generated programmatically and is widely supported.
Click to reveal answer
intermediate
Can you use comments in Terraform JSON configuration files?
No, JSON does not support comments. This is a limitation compared to HCL, which allows comments in configuration files.
Click to reveal answer
intermediate
Why might someone choose JSON over HCL for Terraform configurations?
JSON configurations can be generated automatically by tools or scripts, making them useful for dynamic or automated infrastructure setups.
Click to reveal answer
What file extension must Terraform JSON configuration files use?
A.tf
B.tf.json
C.json
D.json.tf
✗ Incorrect
Terraform requires JSON configuration files to have the .tf.json extension to recognize them as valid configuration files.
Which of the following is NOT a feature of Terraform JSON configuration files?
ASupport for comments
BCan be generated programmatically
CUse JSON syntax
DRecognized by Terraform CLI
✗ Incorrect
JSON does not support comments, so Terraform JSON configuration files cannot include comments.
Why might JSON be preferred over HCL in some Terraform use cases?
ABecause JSON files can be generated by scripts
BBecause JSON is easier for humans to read
CBecause JSON supports comments
DBecause JSON files are smaller
✗ Incorrect
JSON files can be generated automatically by scripts or tools, which is useful for automation.
Which language is Terraform's native configuration language?
AYAML
BJSON
CHCL
DXML
✗ Incorrect
Terraform's native configuration language is HCL (HashiCorp Configuration Language).
If you want to add comments to your Terraform configuration, which format should you use?
AYAML
BJSON
CXML
DHCL
✗ Incorrect
HCL supports comments, while JSON does not.
Explain the advantages and limitations of using JSON as an alternative configuration format in Terraform.
Think about automation benefits and readability trade-offs.
You got /5 concepts.
Describe how Terraform processes JSON configuration files compared to HCL files.
Consider file recognition, syntax differences, and output.
You got /5 concepts.
Practice
(1/5)
1. What is the main reason to use JSON configuration files in Terraform instead of the usual HCL language?
easy
A. To enable automation and integration with other tools
B. Because JSON files are easier to read for humans
When running terraform apply, you get a syntax error. What is the most likely cause?
medium
A. The JSON keys are not properly quoted
B. The "tags" block should be an array, not an object
C. The JSON file is missing a root-level "terraform" key
D. The JSON file uses incorrect nesting for resource blocks
Solution
Step 1: Review Terraform JSON resource structure
Terraform expects resource blocks nested as: resource type -> resource name -> attributes.
Step 2: Check the nesting in the snippet
The snippet places attributes directly under the resource type "aws_instance" without the required instance name (e.g., "example") as an intermediate object key.
Final Answer:
The JSON file uses incorrect nesting for resource blocks -> Option D
Quick Check:
Resource nesting must follow Terraform JSON schema = B [OK]
Hint: Check resource nesting carefully in JSON configs [OK]
Common Mistakes:
Confusing JSON object vs array for tags
Expecting a "terraform" root key in JSON
Not quoting JSON keys properly
5. You want to convert this HCL Terraform config to JSON: