I thought I’d try another example that should work according to the docs, by specifying a new var name when the source is defined at the top of the build block.
build {
source "amazon-ebs.rocky8-ami" {
connection_user = "rocky"
}
source "amazon-ebs.rocky8-rendernode-ami" {
connection_user = "rocky"
}
source "amazon-ebs.amznlnx2023-ami" {
connection_user = "ec2-user"
}
source "amazon-ebs.amznlnx2023-rendernode-ami" {
connection_user = "ec2-user"
}
source "amazon-ebs.ubuntu18-ami" {
connection_user = "ubuntu"
}
source "amazon-ebs.deadline-db-ubuntu18-ami" {
connection_user = "ubuntu"
}
The intention then would be for me to use that, but I get:
Installed plugin github.com/hashicorp/amazon v1.3.3 in "/root/.config/packer/plugins/github.com/hashicorp/amazon/packer-plugin-amazon_v1.3.3_x5.0_linux_amd64"
Installed plugin github.com/hashicorp/ansible v1.1.2 in "/root/.config/packer/plugins/github.com/hashicorp/ansible/packer-plugin-ansible_v1.1.2_x5.0_linux_amd64"
Error: Unsupported argument
on /tmp/firehawk-infra/modules/packer-firehawk-amis/modules/firehawk-ami/firehawk-ami.pkr.hcl line 529:
(source code not available)
An argument named "connection_user" is not expected here.
So is it not possible to create reusable code blocks or have variables per source block in packer? The documentation led me to beleive this should be possible.