Created
October 31, 2014 08:11
-
-
Save lantrix/c01d9235500072eaff9d to your computer and use it in GitHub Desktop.
Add new tags to AWS EC2 instances found by tag filter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #get instances with specific tag | |
| $tagFilter1 = New-Object Amazon.EC2.Model.Filter | |
| $tagFilter1.Name = "tag:Environment Name" | |
| $tagFilter1.Value.Add("MyEnv") | |
| $instances = Get-EC2Instance -Filter @($tagFilter1) | |
| #New or update tag on instances | |
| foreach ($i in $instances.Instances) { | |
| New-EC2Tag -ResourceId $i.InstanceId -Tags @(@{ Key="YourTagName"; Value="YourTagValue" }) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment