I am trying to tag a sets of snapshots based on some check. I am putting all snapshot_ids in an Array. Now I want to tag them with a tag based on another condition.

Like I am using below:

client=Aws::EC2::Client.new(region: 'ap-southeast-2', retry_limit: 15))
resp=client.describe_snapshots({owner_ids['*****']})

resp.snapshots.each do |varEach|
            counter+=1
if (SOME CHECKS)

< HERE I WANT TO TAG THEM>

end

end

Could you kindly help me in achieving this?

1 Answers

0
jarmod On

Use the general purpose create_tags method to tag them all at the same time, for example:

resp = client.create_tags({
  resources: [
    "snap-03a123b99e88a123f",
    "snap-03a444b55e66a777f",
  ], 
  tags: [
    {
      key: "Stack", 
      value: "production", 
    }, 
    {
      key: "Owner", 
      value: "abhiks", 
    }, 
  ], 
})