mirror of
https://github.com/hashicorp/packer.git
synced 2026-04-24 23:57:21 -04:00
Clarify what the labels of a source block do. (#11236)
Co-authored-by: Sylvia Moss <moss@hashicorp.com>
This commit is contained in:
parent
c083b53c4f
commit
9bdeb84cda
2 changed files with 19 additions and 10 deletions
|
|
@ -12,29 +12,38 @@ 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 refering to those source blocks from a [`build`
|
||||
block](/docs/templates/hcl_templates/blocks/build), for example :
|
||||
block](/docs/templates/hcl_templates/blocks/build) :
|
||||
|
||||
```hcl
|
||||
build {
|
||||
sources = [
|
||||
# Here Packer will use a default ami_name when saving the image.
|
||||
"source.amazon-ebs.example",
|
||||
"source.amazon-ebs.foo",
|
||||
"source.happycloud.example",
|
||||
"source.happycloud.foo",
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
The build-level [`source` block](/docs/templates/hcl_templates/blocks/build/source) allows to
|
||||
set specific source fields.
|
||||
The build-level [`source`
|
||||
block](/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.amazon-ebs.example" {
|
||||
# Here Packer will use the provided ami_name instead of defaulting it.
|
||||
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 'ami_name' field in the top-level source block.
|
||||
ami_name = "specific"
|
||||
# set the 'image_name' field in the top-level source block and here at the
|
||||
# same time
|
||||
image_name = "build_specific_field"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
```hcl
|
||||
# sources.pkr.hcl
|
||||
source "amazon-ebs" "example-1" {
|
||||
source "happycloud" "foo" {
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
|
|
|||
Loading…
Reference in a new issue