Last active
August 29, 2015 14:02
-
-
Save johnschult/0059b9826e1f752ad001 to your computer and use it in GitHub Desktop.
EC2 show instance tags
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
require 'rubygems' | |
require 'aws-sdk' | |
LAYER = 'boxcast_origin' | |
STACK = 'dev.boxcast.com' | |
TAG_PREFIX = 'boxcast:origin' | |
ec2 = AWS::EC2.new() | |
boxcast_origin_instances = [] | |
ec2.instances.with_tag('opsworks:stack', STACK).tagged("opsworks:layer:#{LAYER}").each do |instance| | |
tags = {} | |
instance.tags.to_h.each do |k,v| | |
tags[k] = v if k[/^#{TAG_PREFIX}/] | |
end | |
tags['id'] = instance.id | |
tags['availability_zone'] = instance.availability_zone | |
boxcast_origin_instances << tags | |
end | |
p boxcast_origin_instances |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment