Skip to content

Instantly share code, notes, and snippets.

@thedoc31
Last active August 28, 2017 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thedoc31/8d043cdd23b4e21171c600e82bc6b2f3 to your computer and use it in GitHub Desktop.
Save thedoc31/8d043cdd23b4e21171c600e82bc6b2f3 to your computer and use it in GitHub Desktop.
Fix a batch of AWS Tags
aws --region us-west-2 ec2 describe-tags --filters "Name=tag:internalHostname,Values=*corp.adobe.com.corp.adobe.com" | sed 's/corp.adobe.com.corp.adobe.com/corp.adobe.com/g' > tagfix.json
resource=""
value=""
jq -rc '.Tags[]' tagfix.json | while IFS='' read tag; do
resource=$(echo $tag | jq -r .ResourceId)
value=$(echo $tag | jq -r .Value)
echo "Fixing $resource ($value)"
aws --region us-west-2 ec2 create-tags --resource $resource --tags Key=internalHostname,Value=$value
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment