Created
September 26, 2018 14:58
-
-
Save tylergohl/9c6159fcdf42be286cfc46a5eb39a8d1 to your computer and use it in GitHub Desktop.
Sometimes you gotta break all your AWS tags
This file contains 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
# Change up $role / $product as needed | |
$MajorEnv = 'int' | |
$EnvNumber = '01' | |
$Env = "$MajorEnv$EnvNumber" | |
$Role = 'es-master' | |
$values = "$Env-$Role*" | |
$Product = 'los' | |
# Get empty web server tags | |
$Instances = (get-ec2instance -Filter @( @{name='tag:aws:cloudformation:stack-name'; values=$values}) | Select-Object -ExpandProperty instances).instanceid | |
$tag = New-Object Amazon.EC2.Model.Tag | |
$tag.Key = "Name" | |
$tag.Value = "$MajorEnv$EnvNumber-$Role" | |
$instances | New-EC2Tag -Tag $tag -Force | |
$tag = New-Object Amazon.EC2.Model.Tag | |
$tag.Key = "Patch Group" | |
$tag.Value = "$MajorEnv-$Role" | |
$instances | New-EC2Tag -Tag $tag -Force | |
$tag = New-Object Amazon.EC2.Model.Tag | |
$tag.Key = "role" | |
$tag.Value = $Role | |
$instances | New-EC2Tag -Tag $tag -Force | |
$tag = New-Object Amazon.EC2.Model.Tag | |
$tag.Key = "product" | |
$tag.Value = $Product | |
$instances | New-EC2Tag -Tag $tag -Force | |
$tag = New-Object Amazon.EC2.Model.Tag | |
$tag.Key = "environment" | |
$tag.Value = $Env | |
$instances | New-EC2Tag -Tag $tag -Force | |
$tag = New-Object Amazon.EC2.Model.Tag | |
$tag.Key = "major environment" | |
$tag.Value = $MajorEnv | |
$instances | New-EC2Tag -Tag $tag -Force |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment