awsupload: Apply tags to imported snapshot
Applying a `Name` tag to the snapshot makes the name of the image appear in the snapshot listing in EC2's console. It also makes it easier to remove a snapshot after deregistering the AMI. Signed-off-by: Major Hayden <major@redhat.com>
This commit is contained in:
parent
fc7f6349eb
commit
6659ab58ad
1 changed files with 18 additions and 0 deletions
|
|
@ -167,6 +167,24 @@ func (a *AWS) Register(name, bucket, key string) (*string, error) {
|
|||
}
|
||||
|
||||
snapshotID := importOutput.ImportSnapshotTasks[0].SnapshotTaskDetail.SnapshotId
|
||||
|
||||
// Tag the snapshot with the image name.
|
||||
req, _ := a.importer.CreateTagsRequest(
|
||||
&ec2.CreateTagsInput{
|
||||
Resources: []*string{snapshotID},
|
||||
Tags: []*ec2.Tag{
|
||||
{
|
||||
Key: aws.String("Name"),
|
||||
Value: aws.String(name),
|
||||
},
|
||||
},
|
||||
},
|
||||
)
|
||||
err = req.Send()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Printf("[AWS] 📋 Registering AMI from imported snapshot: %s", *snapshotID)
|
||||
registerOutput, err := a.importer.RegisterImage(
|
||||
&ec2.RegisterImageInput{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue