2020-05-26 15:29:47 +02:00
|
|
|
---
|
|
|
|
description: >
|
2020-06-02 11:51:33 +02:00
|
|
|
The variable block, also called the input-variable block, defines variables
|
2020-05-28 17:04:34 +02:00
|
|
|
within your Packer configuration.
|
2020-05-26 15:29:47 +02:00
|
|
|
page_title: variable - Blocks
|
|
|
|
sidebar_title: <tt>variable</tt>
|
|
|
|
---
|
|
|
|
|
|
|
|
# The `variable` block
|
|
|
|
|
|
|
|
`@include 'from-1.5/beta-hcl2-note.mdx'`
|
|
|
|
|
2020-06-02 11:58:01 +02:00
|
|
|
The `variable` block, also called the `input-variable` block, defines variables
|
2020-05-26 15:29:47 +02:00
|
|
|
within your Packer configuration. An input-variable cannot be used in another
|
2021-01-15 09:18:39 -08:00
|
|
|
input variable: we recommend using [locals](/docs/templates/hcl_templates/blocks/locals) for that instead.
|
2020-05-26 15:29:47 +02:00
|
|
|
|
|
|
|
`@include 'from-1.5/variables/foo-block.mdx'`
|
|
|
|
|
|
|
|
## Default value
|
|
|
|
|
|
|
|
If a default value is set, the variable is optional. Otherwise, the variable
|
|
|
|
**must** be set.
|
|
|
|
|
|
|
|
`@include 'from-1.5/variables/assignment.mdx'`
|
|
|
|
|
2020-11-02 17:20:46 +01:00
|
|
|
`@include 'from-1.5/variables/custom-validation.mdx'`
|
|
|
|
|
2020-05-26 15:29:47 +02:00
|
|
|
Example of a variable assignment from a file:
|
|
|
|
|
|
|
|
`@include 'from-1.5/variables/foo-pkrvar.mdx'`
|
|
|
|
|
|
|
|
`@include 'from-1.5/variables/must-be-set.mdx'`
|
|
|
|
|
2020-10-05 15:27:12 +02:00
|
|
|
`@include 'from-1.5/variables/sensitive.mdx'`
|
|
|
|
|
2020-05-26 15:29:47 +02:00
|
|
|
# More on variables
|
|
|
|
|
2021-01-14 11:23:39 -08:00
|
|
|
- Read the [full variables](/docs/templates/hcl_templates/variables) description for a more
|
2020-05-26 15:29:47 +02:00
|
|
|
thorough read.
|
2020-06-02 11:51:33 +02:00
|
|
|
- Read the [variables guide](/guides/hcl/variables) for more examples.
|