Clarify what the labels of a source block do. (#11236)

Co-authored-by: Sylvia Moss <moss@hashicorp.com>
testing_hcp_rewrite_two
Adrien Delorme 5 years ago committed by GitHub
parent c083b53c4f
commit 9bdeb84cda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -12,29 +12,38 @@ The top-level `source` block defines reusable builder configuration blocks:
`@include 'from-1.5/sources/example-block.mdx'` `@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` 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 ```hcl
build { build {
sources = [ sources = [
# Here Packer will use a default ami_name when saving the image. # Here Packer will use a default ami_name when saving the image.
"source.amazon-ebs.example", "source.happycloud.example",
"source.amazon-ebs.foo", "source.happycloud.foo",
] ]
} }
``` ```
The build-level [`source` block](/docs/templates/hcl_templates/blocks/build/source) allows to The build-level [`source`
set specific source fields. 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 ```hcl
build { build {
source "source.amazon-ebs.example" { source "source.happycloud.example" {
# Here Packer will use the provided ami_name instead of defaulting it. # Here Packer will use the provided image_name instead of defaulting it.
# Note that fields cannot be overwritten, in other words, you cannot # Note that fields cannot be overwritten, in other words, you cannot
# set the 'ami_name' field in the top-level source block. # set the 'image_name' field in the top-level source block and here at the
ami_name = "specific" # same time
image_name = "build_specific_field"
} }
} }
``` ```

@ -1,6 +1,6 @@
```hcl ```hcl
# sources.pkr.hcl # sources.pkr.hcl
source "amazon-ebs" "example-1" { source "happycloud" "foo" {
// ... // ...
} }
``` ```

Loading…
Cancel
Save