hashicorp / hashicorp/packer-plugin-azure

Add full managed image gallery ID to HCP Packer data for managed image backed SIG builds

Open
#389 1 comment 1 reaction 0 assignees View on GitHub
builder/arm enhancement
Dominant language
Go
Stars
63
Forks
103
PR merge metrics
No merged PRs in 30d

Description

#### Description

When a managed image is published to a Compute Gallery using the Azure ARM builder, the `ManagedImageId` output is sent to HCP Packer as the `external_id`, but the `ManagedImageSharedImageGalleryId` is not captured.

Various components of the Gallery ID are included in build tags (`sig_name`, `sig_image_name`, `sig_image_version`, and so on), but not the full ID so it's quite a lot of work to piece it together.

#### Use Case(s)

Users publishing shared images to a Compute Gallery expect to consume the images using the Gallery ID, not the underlying Managed Image ID.

#### Potential configuration
Given this configuration:
```
source "azure-arm" "base" {
os_type = "Linux"
build_resource_group_name = "packer-images"
vm_size = "Standard_B2s"

# Source image
image_publisher = "Canonical"
image_offer = "0001-com-ubuntu-server-jammy"
image_sku = "22_04-lts-gen2"
image_version = "latest"

# Destination image
managed_image_name = "ubuntu22-${local.timestamp}"
managed_image_resource_group_name = "packer-images"

# Compute gallery
shared_image_gallery_destination {
subscription = var.az_subscription_id
resource_group = "packer-images"
gallery_name = "packer_images"
image_name = "ubuntu22-base"
image_version = formatdate("YYYY.MMDD.hhmm", timestamp())
replication_regions = ["centralus"]
storage_account_type = "Standard_LRS"
}

...
}
```

And outputs:
```
==> Builds finished. The artifacts of successful builds are:
--> azure-arm.base: Azure.ResourceManagement.VMImage:

OSType: Linux
ManagedImageResourceGroupName: packer-images
ManagedImageName: ubuntu22-20240312145139
ManagedImageId: /subscriptions//resourceGroups/packer-images/providers/Microsoft.Compute/images/ubuntu22-20240312145139
ManagedImageLocation: centralus
ManagedImageSharedImageGalleryId: /subscriptions//resourceGroups/packer-images/providers/Microsoft.Compute/galleries/packer_images/images/ubuntu22-base/versions/2024.0312.1451
SharedImageGalleryResourceGroup: packer-images
SharedImageGalleryName: packer_images
SharedImageGalleryImageName: ubuntu22-base
SharedImageGalleryImageVersion: 2024.0312.1451
SharedImageGalleryReplicatedRegions: centralus
```
Only the `ManagedImageId` is available in HCP Packer, but the `ManagedImageSharedImageGalleryId` is desired.

#### Potential References

Contributor guide

Open the contributing guide

Research direction

Start by tracing the Azure ARM builder's managed image output into the HCP Packer data and compare the existing ManagedImageId handling with the ManagedImageSharedImageGalleryId value described here. Exercise the provided shared-image-gallery configuration and verify that the complete gallery ID is captured alongside the existing managed image ID.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, go
Domain
cloud, devtools
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.