fix: CopyImage carries Distro and DistroFamily from the source AMI

The copy was built field by field and dropped both, so cloud-init family detection was lost on copied images.
This commit is contained in:
Julian Sommer
2026-10-06 08:44:41 +10:00
parent 8fec37c313
commit 9d7407a1f5
2 changed files with 6 additions and 0 deletions
@@ -897,6 +897,8 @@ func (s *ImageServiceImpl) CopyImage(ctx context.Context, input *ec2.CopyImageIn
ImageOwnerAlias: accountID,
CreationDate: time.Now().UTC(),
BootMode: srcMeta.BootMode,
Distro: srcMeta.Distro,
DistroFamily: srcMeta.DistroFamily,
Tags: tags,
SourceDigest: srcMeta.SourceDigest,
// Zero-copy: the new config shares the source's already-durable
@@ -1781,6 +1781,8 @@ func TestCopyImage_InheritsSourceFields(t *testing.T) {
RootDeviceType: "ebs",
Description: "arm source",
BootMode: "uefi",
Distro: "debian-12",
DistroFamily: "debian",
SourceDigest: digest,
})
@@ -1796,6 +1798,8 @@ func TestCopyImage_InheritsSourceFields(t *testing.T) {
assert.Equal(t, uint64(32), newMeta.VolumeSizeGiB)
assert.Equal(t, "ebs", newMeta.RootDeviceType)
assert.Equal(t, "uefi", newMeta.BootMode, "CopyImage must propagate BootMode from source")
assert.Equal(t, "debian-12", newMeta.Distro, "CopyImage must propagate Distro from source")
assert.Equal(t, "debian", newMeta.DistroFamily, "cloud-init family detection reads DistroFamily")
assert.Equal(t, digest, newMeta.SourceDigest, "a zero-copy share still holds the source artifact")
assert.False(t, newMeta.CreationDate.Before(before), "CreationDate must be refreshed on copy, not inherited")
}