2020-05-26 09:29:47 -04:00
|
|
|
---
|
|
|
|
description: >
|
2020-06-02 05:51:33 -04:00
|
|
|
The variable block, also called the input-variable block, defines variables
|
2020-05-28 11:04:34 -04:00
|
|
|
within your Packer configuration.
|
2020-05-26 09:29:47 -04:00
|
|
|
layout: docs
|
|
|
|
page_title: variable - Blocks
|
|
|
|
sidebar_title: <tt>variable</tt>
|
|
|
|
---
|
|
|
|
|
|
|
|
# The `variable` block
|
|
|
|
|
|
|
|
`@include 'from-1.5/beta-hcl2-note.mdx'`
|
|
|
|
|
2020-06-02 05:58:01 -04:00
|
|
|
The `variable` block, also called the `input-variable` block, defines variables
|
2020-05-26 09:29:47 -04:00
|
|
|
within your Packer configuration. An input-variable cannot be used in another
|
2020-06-02 06:13:50 -04:00
|
|
|
input variable: we recommend using [locals](/docs/from-1.5/blocks/locals) for that instead.
|
2020-05-26 09:29:47 -04: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'`
|
|
|
|
|
|
|
|
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 09:27:12 -04:00
|
|
|
`@include 'from-1.5/variables/sensitive.mdx'`
|
|
|
|
|
2020-05-26 09:29:47 -04:00
|
|
|
# More on variables
|
|
|
|
|
|
|
|
- Read the [full variables](/docs/from-1.5/variables) description for a more
|
|
|
|
thorough read.
|
2020-06-02 05:51:33 -04:00
|
|
|
- Read the [variables guide](/guides/hcl/variables) for more examples.
|