Packer Registry iteration initialization failed

I’m trying to build a GCP Image with Packer registry.

Below is the windows.pkr.hcl file content which I’m using.

source "googlecompute" "windows-example" {
  project_id = "MY_PROJECT"
  source_image = "windows-server-2019-dc-v20200813"
  zone = "us-central1-a"
  disk_size = 50
  machine_type = "n1-standard-2"
  communicator = "winrm"
  winrm_username = "packer_user"
  winrm_insecure = true
  winrm_use_ssl = true
  metadata = {
    windows-startup-script-cmd = "winrm quickconfig -quiet & net user /add packer_user & net localgroup administrators packer_user /add & winrm set winrm/config/service/auth @{Basic=\"true\"}"
  }
}

build {
  hcp_packer_registry {
    bucket_name = "Images"
    description = <<EOT
Packer Windows Images
    EOT
    labels = {
      version = "0.0.2"
    }
  }
  name = "Packer-Images"
  sources = [
    "sources.googlecompute.windows-example"
  ]
}

But I get the below error when I run packer build .\windows.pkr.hcl (this file is under git repo for version controlling as well) as

Error: HCP Packer Registry iteration initialization failed

Failed to initialize iteration for "Images"
 This iteration associated to the fingerprint 9CF21B162351427FCAD566F9C1C45 is  
complete. If you wish to add a new build to this image a new iteration must be
created by changing the build fingerprint.

Please help me on over coming the issue.

Hi @krishna1! Have you already built and published to HCP Packer an image with this same version of the template? If yes, try creating a new commit with any changes you have made or an empty one, to get a new fingerprint. You can also set the fingerprint manually by exporting HCP_PACKER_BUILD_FINGERPRINT with the fingerprint you want.

Thanks for the reply @sylviamoss I’m using Windows machine and tried below steps which resolved the issue.

("$(git hash-object D:\file\windows.pkr.hcl)".Substring(0,25)).ToUpper() - get hash value
[Environment]::SetEnvironmentVariable("HCP_PACKER_BUILD_FINGERPRINT","hash_value")
1 Like

Nice! Great to hear that you figured it out :smiley: