diff --git a/internal/upload/awsupload/awsupload.go b/internal/upload/awsupload/awsupload.go index 78f9910e9..cd8c60df9 100644 --- a/internal/upload/awsupload/awsupload.go +++ b/internal/upload/awsupload/awsupload.go @@ -243,6 +243,23 @@ func (a *AWS) Register(name, bucket, key string, shareWith []string, rpmArch str log.Printf("[AWS] ๐ŸŽ‰ AMI registered: %s", *registerOutput.ImageId) + // Tag the image with the image name. + req, _ = a.ec2.CreateTagsRequest( + &ec2.CreateTagsInput{ + Resources: []*string{registerOutput.ImageId}, + Tags: []*ec2.Tag{ + { + Key: aws.String("Name"), + Value: aws.String(name), + }, + }, + }, + ) + err = req.Send() + if err != nil { + return nil, err + } + if len(shareWith) > 0 { log.Println("[AWS] ๐Ÿ’ฟ Sharing ec2 AMI") var launchPerms []*ec2.LaunchPermission diff --git a/test/cases/aws.sh b/test/cases/aws.sh index b99265fcb..72d4d742b 100755 --- a/test/cases/aws.sh +++ b/test/cases/aws.sh @@ -263,6 +263,12 @@ for LOOP_COUNTER in {0..10}; do sleep 5 done +# Ensure the image was properly tagged. +IMAGE_TAG=$($AWS_CMD ec2 describe-images --image-ids "${AMI_IMAGE_ID}" | jq -r '.Images[0].Tags[] | select(.Key=="Name") | .Value') +if [[ ! $IMAGE_TAG == "${IMAGE_KEY}" ]]; then + RESULTS=0 +fi + # Clean up our mess. greenprint "๐Ÿงผ Cleaning up" SNAPSHOT_ID=$(jq -r '.Images[].BlockDeviceMappings[].Ebs.SnapshotId' "$AMI_DATA")