---
description: >
  A source block nested in a build block allows you to use an already defined
  source and to set specific fields which aren't already set in the top-level 
  source block.
page_title: source - build - Blocks
sidebar_title: <tt>source</tt>
---

# The `source` block

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

A `source` block nested in a `build` block allows you to use an already defined
source and to "fill in" those fields _which aren't already set in the top-level 
source block_. 

Build-level source blocks are implemented by merging their contents with the 
corresponding top-level source block, and a packer build will fail when it 
encounters the ambiguity that arises when a source parameter is defined twice. 
For example, in the below example, if the top-level "lxd.arch" source block 
also defined an `output_image` field (or if one of the build-level source blocks 
redefined and image field), Packer would error.

```hcl
# builds.pkr.hcl
source "lxd" "arch" {
  image = "archlinux"
}

build {
  source "lxd.arch" {
    // setting the name field allows to rename the source only for this build
    // section.
    name = "nomad"
    output_image = "nomad"
  }

  provisioner "shell" {
    inline = [ "echo installing nomad" ]
  }
}

build {
  source "lxd.arch" {
    name = "consul"
    output_image = "consul"
  }

  provisioner "shell" {
    inline = [ "echo installing consul" ]
  }
}
```
