»The hcp_packer_registry block

The hcp_packer_registry block allows operators the ability to customize the metadata sent to HCP Packer Registry. It configures the details of an image that is created or updated within the HCP Packer registry.

The presence of a hcp_packer_registry block will enable the HCP Packer registry mode and all the builds within that build block will be pushed to the remote registry if the appropriate HCP credentials are set (HCP_CLIENT_ID and HCP_CLIENT_SECRET). If no HCP credentials are set Packer will fail the build and exit immediately to avoid any potential artifact drift between the build providers and the HCP Packer registry.

# file: builds.pkr.hcl
source "file" "basic-example" {
  content = "Lorem ipsum dolor sit amet"
  target = "sample_artifact"
}

build {
   hcp_packer_registry {
    slug = "sample-artifact"

    description = <<EOT
Some nice description about the image which artifact is being published to HCP Packer Registry. =D
    EOT

    labels = {
      "foo-version" = "3.4.0",
      "foo" = "bar",
    }
  }

  sources = ["sources.file.basic-example"]
}
# file: builds.pkr.hclsource "file" "basic-example" {  content = "Lorem ipsum dolor sit amet"  target = "sample_artifact"}
build {   hcp_packer_registry {    slug = "sample-artifact"
    description = <<EOTSome nice description about the image which artifact is being published to HCP Packer Registry. =D    EOT
    labels = {      "foo-version" = "3.4.0",      "foo" = "bar",    }  }
  sources = ["sources.file.basic-example"]}
  • slug (string) - The image name when published to the HCP Packer registry. Should always be the same, otherwise a new image will be created. Defaults to build.name if not set. Will be overwritten if HCP_PACKER_BUCKET_NAME is set.

  • description (string) - The image description. Useful to provide a summary about the image. The description will appear at the image's main page and will be updated whenever it is changed and a new build is pushed to the HCP Packer registry. Should contain a maximum of 255 characters. Defaults to build.description if not set.

  • labels (map[string]string) - Map of labels. Can provide any information, such as tools versions (e.g. go 1.16, python 3.5, etc...). The labels will appear at the image's main page and will be updated whenever it is changed and a new build is pushed to the HCP Packer registry.