chore: tag aws snapshots created via ci with the image name

This is to make them more easily identifiable for clean up if required.

Signed-off-by: Andrew Longwill <andrew.longwill@siderolabs.com>
This commit is contained in:
Andrew Longwill 2025-07-25 13:28:17 +01:00
parent 06ef7108a6
commit bfc57fb863
No known key found for this signature in database
GPG Key ID: 5444881046F92733

View File

@ -259,6 +259,24 @@ func (au *AWSUploader) registerAMI(ctx context.Context, region string, svc *ec2.
return g.Wait()
}
//nolint:gocyclo
func (au *AWSUploader) tagSnapshot(ctx context.Context, svc *ec2.Client, snapshotID, imageName string) {
if snapshotID == "" {
return
}
_, tagErr := svc.CreateTags(ctx, &ec2.CreateTagsInput{
Resources: []string{snapshotID},
Tags: []types.Tag{{
Key: pointer.To("Name"),
Value: pointer.To(imageName),
}},
})
if tagErr != nil {
log.Printf("WARNING: failed to tag snapshot %s: %v", snapshotID, tagErr)
}
}
//nolint:gocyclo
func (au *AWSUploader) registerAMIArch(ctx context.Context, region string, svc *ec2.Client, arch, bucketName string, uploader *manager.Uploader) error {
err := retry.Constant(30*time.Minute, retry.WithUnits(time.Second), retry.WithErrorLogging(true)).RetryWithContext(ctx, func(ctx context.Context) error {
@ -359,6 +377,8 @@ func (au *AWSUploader) registerAMIArch(ctx context.Context, region string, svc *
imageName = fmt.Sprintf("%s-%s-%s-%s", au.Options.NamePrefix, au.Options.Tag, region, arch)
}
au.tagSnapshot(ctx, svc, snapshotID, imageName)
imageResp, err := svc.DescribeImages(ctx, &ec2.DescribeImagesInput{
Filters: []types.Filter{
{