---
description: |
  The top-level source block defines reusable builder configuration blocks
page_title: source - Blocks
---

# The `source` block

`@include 'from-1.5/beta-hcl2-note.mdx'`

The top-level `source` block defines reusable builder configuration blocks:

`@include 'from-1.5/sources/example-block.mdx'`

The first label — `happycloud` here — is the builder type. The second label is
the unique name or identifier you want to give to the source. There can be only one
`source.happycloud.foo` top-level source block; but it can be used more than
once. Builders are usually found in plugins, except for the `file` and the
`null` builders that will remain in Packer core.

You can start builders by referring to those source blocks from a [`build`
block](/packer/docs/templates/hcl_templates/blocks/build) :

```hcl
build {
  sources = [
    # Here Packer will use a default ami_name when saving the image.
    "source.happycloud.example",
    "source.happycloud.foo",
  ]
}
```

The build-level [`source`
block](/packer/docs/templates/hcl_templates/blocks/build/source) allows to set specific
source fields. Each field must be defined only once and it is currently not
allowed to override a value.

```hcl
build {
  source "source.happycloud.example" {
    # Here Packer will use the provided image_name instead of defaulting it.
    # Note that fields cannot be overwritten, in other words, you cannot
    # set the 'image_name' field in the top-level source block and here at the
    # same time
    image_name = "build_specific_field"
  }
}
```

`@include 'from-1.5/contextual-source-variables.mdx'`

## Related

- The list of available builders can be found in the [builders](/packer/docs/builders)
  section.

- A list of [community
  builders](https://packer.io/community-tools#community-builders) is available.

- Create your own [custom builder](/packer/docs/plugins/creation/custom-builders) !
