---
description: |
  The `source` block defines reusable builder configuration blocks. Learn how to define reusable builders using the `source` block.
page_title: source block reference
---

⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️
> [!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.
⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️

# `source` block

This topic providers reference information about the `source` block.

## Description

The `source` block defines reusable builder configuration blocks. Builders are commonly used in custom plugins.

## Example 

The following example defines a source for a builder type called `happycloud` with the name `foo`:

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

There is only one `source.happycloud.foo` top-level source block, but it can be used more than once. 

You can start builders by referring to `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

- Refer to the [builders reference overview](/packer/docs/builders) for information about Packer builders.

- Refer to the [community builders reference](/packer/docs/community-tools#community-builders) for information about builders maintained by the community.

- Refer to [Create Custom Builders](/packer/docs/plugins/creation/custom-builders) for instructions on how to create your own builders.
