github.com/hashicorp/packer@v1.14.3/website/content/docs/templates/hcl_templates/blocks/variable.mdx (about) 1 --- 2 description: > 3 The `variable` and `input-variable` blocks define variables in your Packer configuration. Learn how to use these blocks to declare variables in your template. 4 page_title: variable block reference 5 --- 6 7 # `variable` block 8 9 This topic provides reference information about the `variable` block. 10 11 ## Description 12 13 The `variable` and `input-variable` blocks define variables 14 within your Packer configuration. You cannot use the `input-variable` block in another `input-variable` block. We recommend using the [`locals`](/packer/docs/templates/hcl_templates/blocks/locals) to nest variables instead. 15 16 `@include 'from-1.5/variables/foo-block.mdx'` 17 18 ## Default value 19 20 If a default value is set, the variable is optional. Otherwise, the variable 21 **must** be set. 22 23 `@include 'from-1.5/variables/assignment.mdx'` 24 25 `@include 'from-1.5/variables/custom-validation.mdx'` 26 27 Example of a variable assignment from a file: 28 29 `@include 'from-1.5/variables/foo-pkrvar.mdx'` 30 31 `@include 'from-1.5/variables/must-be-set.mdx'` 32 33 `@include 'from-1.5/variables/sensitive.mdx'` 34 35 # More on variables 36 37 - Read the [full variables](/packer/docs/templates/hcl_templates/variables) description for a more 38 thorough read. 39 - Read the [variables guide](/packer/guides/hcl/variables) for more examples.