You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
packer/website/content/docs/templates/hcl_templates/blocks/index.mdx

67 lines
3.1 KiB

---
page_title: Built-in blocks overview
description: A block is a container for configuration in a Packer template. Learn about the types of configration blocks built into HCL for Packer.
---
⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️
> [!IMPORTANT]
> **Documentation Update:** Product documentation previously located in `/website` has moved to the [`hashicorp/web-unified-docs`](https://github.com/hashicorp/web-unified-docs) repository, where all product documentation is now centralized. Please make contributions directly to `web-unified-docs`, since changes to `/website` in this repository will not appear on developer.hashicorp.com.
⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️
# Built-in blocks overview
This topic provides an overview of the configuration blocks built into the Packer language that you can use to write Packer templates in HCL2.
## Introduction
A block is a container for configuration. You can use the following types of blocks in your Packer templates:
- `build` blocks contain configuration for a specific combination of builders,
provisioners, and post-processors used to create a specific image artifact.
- `source` blocks contain configuration for builder plugins. Once defined,
sources can be used and further configured by the "build" block.
- `provisioner` blocks contain configuration for provisioner plugins. These
blocks are nested inside of a build block.
- `post-processor` and `post-processors` blocks contain configuration for
post-processor plugins and post-processor plugin sequences. They are also
nested within `build` blocks.
- `variable` blocks contain configuration for variables that can either be
defaulted in configuration or set by the user at runtime.
- `locals` blocks contain configuration for variables that can be created using
HCL functions or data sources, or composited from variables created in the
variables blocks.
The documentation contains information for each block type.
Other blocks, such as the `packer` block, provide information to the Packer core
about what version it is allowed to run. The `required_plugins` block helps the
Packer core
Blocks can be defined in multiple files and `packer build folder` will build
using solely the files from a directory named `folder`.
Packer does not support user-defined blocks and so only the blocks built in to
the language are available for use. The documentation includes all of the available built-in HCL2 blocks.
## Configuration examples
`@include 'from-1.5/variables/foo-block.mdx'`
- [Variable block documentation](/packer/docs/templates/hcl_templates/blocks/variable).
`@include 'from-1.5/locals/example-block.mdx'`
- [Locals block documentation](/packer/docs/templates/hcl_templates/blocks/locals).
`@include 'from-1.5/sources/example-block.mdx'`
- [source block documentation](/packer/docs/templates/hcl_templates/blocks/source).
`@include 'from-1.5/builds/example-block.mdx'`
- [build block documentation](/packer/docs/templates/hcl_templates/blocks/build).
`@include 'from-1.5/datasources/example-block.mdx'`
- [data block documentation](/packer/docs/templates/hcl_templates/blocks/data).