A repo to demo the use of Terraform variables using the Domino's Pizza provider.
- Defining and Assigning Variables
- Variable Types
- Input Variables
- Local Variables
- Output Variables
- Variable Validation
- Sensitive Variables and Security
- Variable Precedence
- Environment variables (TF_VAR_variable_name)
- The
terraform.tfvars
file - The
terraform.tfvars.json
file - Any
*.auto.tfvars
or*.auto.tfvars.json
files, processed in lexical order of their filenames. - Any
-var
and-var-file
options on the command line, in the order they are provided. - Variable defaults
- Tips and Best Practices
- Use a consistent naming convention for variables and provide descriptive variable descriptions to improve code readability.
- Store variable declarations in a separate variables.tf file.
- Use reasonable default values for optional variables.
- Consider using local variables and built-in functions to simplify your configurations and perform complex operations.
- Use validation rules to enforce constraints on variable values.
- Mark sensitive variables as such to prevent accidental exposure.
- Consider using a Terraform Automation & Collaboration Software (TACOS) such as env0 where you can securely store your sensitive variables.