Skip to content

Packer build custom managed image to shared gallery, requires managed image to be set. #13504

@peter-mogaka

Description

@peter-mogaka

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

When filing a bug, please include the following headings if possible. Any
example text in this template can be deleted.

Overview of the Issue

I have a Windows custom managed image that I’m using to build a new golden image and publish it to a Shared Image Gallery. All the necessary Azure resources are already deployed, configured, and functioning correctly.

However, when I run packer validate, I receive an error indicating that I must provide values for the managed image name and resource group.

This suggests that Packer expects to create two artifacts:

A managed image, and

A Shared Image Gallery (SIG) image version.

Based on the documentation, though, it should be possible to publish directly to the Shared Image Gallery without creating a managed image.

Image

Reproduction Steps

  • Builds a custom image for Azure (starting from a Marketplace or base image).
  • Sets only the custom_managed_image_name and custom_managed_image_resource_group_name (not the older managed_image_* fields).
  • Publishes the result to a Shared Image Gallery (SIG).
  • Passes packer validate and packer build cleanly

Packer version

From packer version
v1.12.0

Simplified Packer Template

packer {
required_plugins {
azure = {
source = "github.com/hashicorp/azure"
version = "~> 2"
}
}
}
source "azure-arm" "customimage" {
virtual_network_name = var.virtual_network_name
virtual_network_resource_group_name = var.virtual_network_resource_group_name
virtual_network_subnet_name = var.virtual_network_subnet_name
subscription_id = var.subscription_id
client_id = var.client_id
client_secret = var.client_secret
location = var.location
vm_size = var.vm_size
os_type = var.os_type

communicator = ""
winrm_username = ""
winrm_password = ""
winrm_timeout = ""
winrm_insecure = true
winrm_use_ssl = true

custom_managed_image_name = var.custom_managed_image_name
custom_managed_image_resource_group_name = var.custom_managed_image_resource_group_name

shared_image_gallery_destination {
subscription = var.subscription_id
resource_group = var.gallery_resource_group
gallery_name = var.gallery_name
image_name = var.shared_image_name
image_version = var.shared_image_version
}
spot {
eviction_policy = "Delete"
max_price = "-1"
}

}

Operating system and Environment details

windows 2022 azure edition

Log Fragments and crash.log files

Include appropriate log fragments. If the log is longer than a few dozen lines,
please include the URL to the gist of the log or
use the Github detailed format instead of posting it directly in the issue.

Set the env var PACKER_LOG=1 for maximum log detail.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions