github.com/hashicorp/packer@v1.14.3/website/content/docs/templates/hcl_templates/blocks/index.mdx (about)

     1  ---
     2  page_title: Built-in blocks overview
     3  description: A block is a container for configuration in a Packer template. Learn about the types of configration blocks built into HCL for Packer. 
     4  ---
     5  
     6  # Built-in blocks overview
     7  
     8  This topic provides an overview of the configuration blocks built into the Packer language that you can use to write Packer templates in HCL2.
     9  
    10  ## Introduction
    11  
    12  A block is a container for configuration. You can use the following types of blocks in your Packer templates:
    13  
    14  - `build` blocks contain configuration for a specific combination of builders,
    15    provisioners, and post-processors used to create a specific image artifact.
    16  - `source` blocks contain configuration for builder plugins. Once defined,
    17    sources can be used and further configured by the "build" block.
    18  - `provisioner` blocks contain configuration for provisioner plugins. These
    19    blocks are nested inside of a build block.
    20  - `post-processor` and `post-processors` blocks contain configuration for
    21    post-processor plugins and post-processor plugin sequences. They are also
    22    nested within `build` blocks.
    23  - `variable` blocks contain configuration for variables that can either be
    24    defaulted in configuration or set by the user at runtime.
    25  - `locals` blocks contain configuration for variables that can be created using
    26    HCL functions or data sources, or composited from variables created in the
    27    variables blocks.
    28  
    29  The documentation contains information for each block type.
    30  
    31  Other blocks, such as the `packer` block, provide information to the Packer core
    32  about what version it is allowed to run. The `required_plugins` block helps the
    33  Packer core
    34  
    35  Blocks can be defined in multiple files and `packer build folder` will build
    36  using solely the files from a directory named `folder`.
    37  
    38  Packer does not support user-defined blocks and so only the blocks built in to
    39  the language are available for use. The documentation includes all of the available built-in HCL2 blocks.
    40  
    41  ## Configuration examples
    42  
    43  `@include 'from-1.5/variables/foo-block.mdx'`
    44  
    45  - [Variable block documentation](/packer/docs/templates/hcl_templates/blocks/variable).
    46  
    47  `@include 'from-1.5/locals/example-block.mdx'`
    48  
    49  - [Locals block documentation](/packer/docs/templates/hcl_templates/blocks/locals).
    50  
    51  `@include 'from-1.5/sources/example-block.mdx'`
    52  
    53  - [source block documentation](/packer/docs/templates/hcl_templates/blocks/source).
    54  
    55  `@include 'from-1.5/builds/example-block.mdx'`
    56  
    57  - [build block documentation](/packer/docs/templates/hcl_templates/blocks/build).
    58  
    59  `@include 'from-1.5/datasources/example-block.mdx'`
    60  
    61  - [data block documentation](/packer/docs/templates/hcl_templates/blocks/data).