Skip to content

Instantly share code, notes, and snippets.

@lantrix
Created September 23, 2014 07:57
Show Gist options
  • Select an option

  • Save lantrix/98dc0989481449918e87 to your computer and use it in GitHub Desktop.

Select an option

Save lantrix/98dc0989481449918e87 to your computer and use it in GitHub Desktop.
Tag a bunch of new volumes in AWS EC2
$newvols = ("vol-7f273b7b","vol-b5273bb1","vol-b6273bb2","vol-c6273bc2","vol-b1273bb5")
$tags = @()
$tag = New-Object Amazon.EC2.Model.Tag
$tag.Key = "Attached"
$tag.Value = "i-d7a706e9"
$tags += $tag
$tag = New-Object Amazon.EC2.Model.Tag
$tag.Key = "Environment Name"
$tag.Value = "My Env"
$tags += $tag
$tag = New-Object Amazon.EC2.Model.Tag
$tag.Key = "Owner"
$tag.Value = "My Owner"
$tags += $tag
$tag = New-Object Amazon.EC2.Model.Tag
$tag.Key = "Project"
$tag.Value = "My Project"
$tags += $tag
$tag = New-Object Amazon.EC2.Model.Tag
$tag.Key = "Name"
$tag.Value = "myServerName"
$tags += $tag
foreach ($this in $newvols) {
New-EC2Tag -ResourceId $this -Tags $tags
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment