Skip to content

Instantly share code, notes, and snippets.

@pbogunovich
Last active August 29, 2015 13:57
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 pbogunovich/9792087 to your computer and use it in GitHub Desktop.
Save pbogunovich/9792087 to your computer and use it in GitHub Desktop.
# Current implementation (Broken).
# Doesn't ensure that the tag value of 'aws:autoscaling:groupName'
# is actually the name of the autoscaling group
def ec2_instances
instances = EC2::InstanceCollection.new(:config => config)
instances.tagged('aws:autoscaling:groupName').tagged_values(name)
end
# Proposed fix. Works but is really slow.
def fixed_but_inefficient_ec2_instances
instances = EC2::InstanceCollection.new(:config => config)
instances.tagged('aws:autoscaling:groupName').find_all do |i|
name == i.tags['aws:autoscaling:groupName']
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment