diff --git a/hack/cloud-image-uploader/aws.go b/hack/cloud-image-uploader/aws.go index fe3417102..ca7fb16f9 100644 --- a/hack/cloud-image-uploader/aws.go +++ b/hack/cloud-image-uploader/aws.go @@ -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{ {