Terraform supports both HCL and JSON for writing infrastructure code. Which reason best explains why HCL is preferred?
Think about how easy it is for a person to read and write the code.
HCL (HashiCorp Configuration Language) is designed to be simple and readable for humans, making it easier to write and maintain Terraform configurations. JSON is more verbose and less friendly for manual editing.
Terraform modules help organize infrastructure code. How does HCL support modularity better than other formats?
Consider how HCL structures code blocks and variables.
HCL's syntax supports clear declaration of variables, outputs, and nested blocks, which makes writing reusable and composable modules easier. This modularity helps organize infrastructure code effectively.
When managing sensitive data in Terraform, what feature of HCL helps reduce accidental exposure?
Think about how Terraform handles sensitive inputs in HCL.
HCL supports marking variables as sensitive, which prevents their values from being displayed in logs or CLI output, reducing the risk of accidental exposure of secrets.
Terraform uses the configuration language to create execution plans. How does HCL's structure help Terraform generate accurate plans?
Think about how Terraform understands resource connections.
HCL's clear syntax and nested block structure enable Terraform to parse resource dependencies and relationships accurately, which is essential for generating correct execution plans.
Among configuration languages, why is HCL recommended as a best practice for managing Terraform infrastructure code?
Consider readability, tooling, and safety features.
HCL is declarative and human-readable, supports comments for clarity, and integrates tightly with Terraform's validation and tooling. These features make it a best practice for managing infrastructure code safely and clearly.