fog/fog — Issue #586: Auto Scaling Group object contains All instances and not just the member ones
Author: russellseymour
Created: 2011-11-04 12:03:39+00:00
State: open

Hello,

I have got an object of my AutoScaling group and all the attributes of it are correct, however the the instances property contains all instances from all groups and not just the one I have selected.

# Create a connection to the required cloud service
cf = Fog::AWS::CloudFormation.new(
:aws_access_key_id => "somekey",
:aws_secret_access_key => "secret",
:region => "eu-west-1"
)

resources = cf.describe_stack_resources("StackName" => "MyStack").body['StackResources']

# Now that we have some instance ids get information about each one
compute = Fog::Compute.new(:provider => config["cloud"]["service"],
:aws_access_key_id => "somekey",
:aws_secret_access_key => "secret",
:region => "eu-west-1")

# loop round the resources that are returned
instances = Array.new
resources.each do |resource|

# determine the type of resource
if (resource['ResourceType'] == "AWS::EC2::Instance")
# get the instance id
instances << resource['PhysicalResourceId']
elsif (resource['ResourceType'] == "AWS::AutoScaling::AutoScalingGroup")

# Create an AutoScaling object
as = Fog::AWS::AutoScaling.new(:aws_access_key_id => "somekey",
:aws_secret_access_key => "secret",
:region => "eu-west-1")

# use the Fog class to get the machines with the relevant tags
asgroup = as.groups.get(resource['PhysicalResourceId'])

puts asgroup.inspect
end
end

I can parse this list to extract only the instances relevant to the group, but I thought this is what the 'groups.get' function was meant to provide. If it is what this is meant to do, is this a bug and if so can it be looked at?

Thanks very much,

Russell