<commit_before>---
layout: "guides"
page_title: "Input and Local Variables guide"
sidebar_current: hcl-configuration-variables
description: |-
  This page introduces input variables and local variables as a way to
  parameterize a configuration.
---

# Input Variables and local variables

This page introduces input variables and local variables as a way to
parameterize a configuration. Once defined, input variables are settable from a
default value, environment, special var files, and command line arguments.
Local variables can be a compound of input variables and local variables.

## Defining Variables and locals

Let's create a file `variables.pkr.hcl` with the following contents.

-> **Note**: that the file can be named anything, since Packer loads all
files ending in `.pkr.hcl` in a directory.

```hcl<commit_msg>Add prompt to use a specific directory for *.pkr.hcl (#8757)<commit_after>---
layout: "guides"
page_title: "Input and Local Variables guide"
sidebar_current: hcl-configuration-variables
description: |-
  This page introduces input variables and local variables as a way to
  parameterize a configuration.
---

# Input Variables and local variables

This page introduces input variables and local variables as a way to
parameterize a configuration. Once defined, input variables are settable from a
default value, environment, special var files, and command line arguments.
Local variables can be a compound of input variables and local variables.

## Defining Variables and locals

Let's create a file `variables.pkr.hcl` with the following contents.

-> **Note**: that the file can be named anything, since Packer loads all
files ending in `.pkr.hcl` in a directory. If you split your configuration 
across multiple files, use `packer build <source directory>` to initiate
a build.

```hcl
{'fraction_non_alphanumeric': 0.066006600660066, 'fraction_numerical': 0.0022002200220022, 'mean_word_length': 4.702194357366771, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2009406', 'n_tokens_mistral': 471, 'n_tokens_neox': 449, 'n_words': 245}