packer-cn/website/pages/partials/from-1.5/builds/example-block.mdx

32 lines
950 B
Plaintext
Raw Normal View History

2020-05-26 09:29:47 -04:00
```hcl
# build.pkr.hcl
build {
2020-06-02 10:33:32 -04:00
# use the `name` field to name a build in the logs.
# For example this present config will display
2020-06-02 10:33:32 -04:00
# "buildname.amazon-ebs.example-1" and "buildname.amazon-ebs.example-2"
name = "buildname"
2020-05-26 09:29:47 -04:00
sources = [
2020-06-02 10:33:32 -04:00
# use the optional plural `sources` list to simply use a `source`
2020-05-26 09:29:47 -04:00
# without changing any field.
2020-06-02 10:33:32 -04:00
"source.amazon-ebs.example-1",
2020-05-26 09:29:47 -04:00
]
2020-06-02 10:33:32 -04:00
source "source.amazon-ebs.example-2" {
# Use the singular `source` block set specific fields.
# Note that fields cannot be overwritten, in other words, you cannot
2020-06-02 06:35:32 -04:00
# set the 'output' field from the top-level source block and here.
2020-05-26 09:29:47 -04:00
output = "different value"
name = var.foo
}
provisioner "shell" {
scripts = fileset(".", "scripts/{install,secure}.sh")
2020-05-26 09:29:47 -04:00
}
post-processor "shell-local" {
inline = ["echo Hello World from ${source.type}.${source.name}"]
2020-05-26 09:29:47 -04:00
}
}
```