hashicorp / hashicorp/packer

[HCL2] Allow to override top-level source-block params in build

Open
#12,231 0 comments 1 reaction 0 assignees View on GitHub
enhancement hcl2
Dominant language
Go
Stars
15.8k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

#### Description

I want to reuse Packer HCL source-blocks as templates. In such source-blocks I want to define default values in parameters and have the ability override this parameters in the build blocks.

Example:

```hcl
source "qemu" "my-image" {
disk_size = "10G"
...
}

build build {
source "qemu.my-image" {
disk_size = "30G"
name = "build1"
}

source "qemu.my-image" {
disk_size = "25G"
name = "build2"
}
...
```

But Packer currently does not allow duplicate and override such params (`disk_size` in example above). See Packer [docs](https://developer.hashicorp.com/packer/docs/templates/hcl_templates/blocks/build/source).

#### Use Case(s)

Reusing Packer source-blocks and creation "library" of HCL-templates.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.