Terraform Variables
Terraform variables act as placeholders to parameterize your infrastructure configurations, allowing you to use the same codebase across different environments (development, staging, production) without hardcoding values. They are essential for creating flexible, reusable, and maintainable Infrastructure as Code (IaC). Declaring Variables Variables are declared using a variable block in a .tf file (conventionally in a separate variables.tf file). type: Specifies the type of data (e.g., string, number, bool, list, map, object, set, tuple). default: Makes the variable optional; this value is used if no other value is provided. description: Documents the purpose of the variable for users of the module. validation: Enforces custom rules on the variable's value, returning a custom error message if the condition is not met. sensitive: Marks the value as sensitive, preventing it from being shown in CLI output (though it is still stored in the state file). nullable : Controls whether ...