Error: Unknown source type (Packer HCL source block)
Fixes Packer's 'Unknown source type' error when a source block label doesn't match the builder name. For engineers writing HCL templates whose source block fails validation, explaining the label rules.
Error: Unknown source type (Packer HCL source block)
TL;DR
The label on your source block does not match a known builder. Use exactly one label and make it the builder type (e.g. source "amazon-ebs" "my-image"), not a custom name.
The error
Error: Unknown source type
on myimage/build.pkr.hcl line 5:
(source code not available)
known builders: [null vsphere-iso qemu proxmox-iso linode tencentcloud-cvm
amazon-ebs vagrant proxmox-clone amazon-ebssurrogate profitbricks virtualbox-vm
vmware-iso azure-chroot oneandone proxmox amazon-instance amazon-ebsvolume ...]Fix it
- Check your source block: it must read
source "[builder-type]" "[name]"with exactly two labels, the first being a value from theknown builderslist.
- Success check:
packer validatepasses the source block.
- If you wrote
source "my-custom-name" {, change it tosource "amazon-ebs" "my-custom-name" {(builder type first, your name second).
- Success check: the
Unknown source typeerror disappears.
- If you tried
labels = [...], remove it. Source blocks take labels positionally, not via alabelsargument.
- Success check: no more
Blocks of type "source" require 1 label(s).
- Reference it in the build block as
sources = ["source.amazon-ebs.my-custom-name"].
- Success check:
packer validatesucceeds end to end.
When to use this
You hit this on packer validate or packer build with HCL templates where the source block label is wrong.
When NOT to use this
Do not use this for Failed to initialize build (missing plugin) or JSON template errors. This is specifically the HCL source label mismatch.
Compatibility
Packer 1.7+ with HCL templates. JSON templates use "type": "amazon-ebs" instead of labels.
Variants
Blocks of type "source" require 1 label(s)(tried to use alabelsargument)Error: Unknown source typenaming other builders
Root cause
HCL source blocks are typed by their first label, which must be a registered builder. A custom name in the type position matches nothing, so Packer reports it as unknown and prints the full builder list.
Edge cases
- Dynamic source blocks (generating sources programmatically) were not supported at the time of the issue; check current Packer docs if you need them.
- Parallel builds label output by source name; duplicate names across builds confuse the log stream.
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.