HCP Packer Support
Note: HCP Packer is under active development, and we suggest plugin maintainers to keep up with the SDK changes for more on HCP Packer support.
Note: If you're looking to develop a new plugin, please refer first to the developing plugins page.
HCP Packer support allows for the management of image metadata that can be stored in a HCP Packer registry.
Before pushing metadata to the HCP Packer registry, Packer will use the par.artifact.metadata
key
to query a builder artifact for the Image metadata that a particular component would like to have stored in the registry.
For details and usage examples on management of image metadata, see the Documentation.
Builder Artifact
To support HCP Packer, changes must be made to the plugin's build artifact. The artifact should keep the appropriate
Image metadata in state under the key par.artifact.metadata
. The expected key is provided by the image.ArtifactStateURI constant.
To make HCP Packer support easier, we ship an Image package with the packer-plugin-sdk.
We provide the FromArtifact
function
to easily create an Image with the basic information contained in the Artifact. If customization is necessary, the FromArtifact
accepts
override functions as the second argument, and that can be used to set different values for the metadata.
The Image metadata must contain every metadata HCP Packer should store about this component. The structure is:
Where ImageID
, ProviderName
, and SourceImageID
are mandatory fields.
Examples using the FromArtifact
method:
- Simple form:
- Using overrides:
See packer-plugin-sdk/packer/registry/image for additional examples.
SDK Version
- The HCP Packer support is available from packer-plugin-sdk >= v0.2.7
Plugins Example
The following plugins currently support HCP Packer and are great references for development:
- packer-plugin-amazon
- packer-plugin-azure
- packer-plugin-vsphere
- packer-plugin-docker
- packer-plugin-googlecompute
HCP Packer
To get to know HCP Packer, visit the HCP Packer documentation or try the Get Started with HCP Packer collection on HashiCorp Learn.