53 lines
1.3 KiB
Plaintext
Raw Permalink Normal View History

2020-05-26 15:29:47 +02:00
---
2020-12-04 16:02:29 -05:00
description: |
The top-level source block defines reusable builder configuration blocks
2020-05-26 15:29:47 +02:00
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:
2020-05-26 15:29:47 +02:00
`@include 'from-1.5/sources/example-block.mdx'`
2020-06-02 12:11:55 +02:00
You can start builders by refering to those source blocks form a [`build`
block](/docs/templates/hcl_templates/blocks/build), for example :
2020-06-02 12:11:55 +02:00
```hcl
build {
sources = [
2020-06-02 12:11:55 +02:00
# Here Packer will use a default ami_name when saving the image.
"source.amazon-ebs.example",
"source.amazon-ebs.foo",
2020-06-02 12:11:55 +02:00
]
}
```
The build-level [`source` block](/docs/templates/hcl_templates/blocks/build/source) allows to
2020-06-02 12:11:55 +02:00
set specific source fields.
```hcl
build {
source "source.amazon-ebs.example" {
2020-06-02 12:11:55 +02:00
# Here Packer will use the provided ami_name instead of defaulting it.
# Note that fields cannot be overwritten, in other words, you cannot
# set the 'ami_name' field in the top-level source block.
2020-06-02 12:11:55 +02:00
ami_name = "specific"
}
}
```
2020-05-26 15:29:47 +02:00
`@include 'from-1.5/contextual-source-variables.mdx'`
2020-05-28 16:49:54 +02:00
## Related
2020-05-26 15:29:47 +02:00
- The list of available builders can be found in the [builders](/docs/builders)
2020-05-28 16:49:54 +02:00
section.
- A list of [community
2020-06-02 12:01:21 +02:00
builders](/community-tools#community-builders) is available.
2020-05-28 16:49:54 +02:00
- Create your own [custom builder](/docs/extending/custom-builders) !