diff --git a/lib/fog/aws/models/ec2/server.rb b/lib/fog/aws/models/ec2/server.rb index 6120293bf..e1e82829c 100644 --- a/lib/fog/aws/models/ec2/server.rb +++ b/lib/fog/aws/models/ec2/server.rb @@ -9,7 +9,7 @@ module Fog attribute :ami_launch_index, 'amiLaunchIndex' attribute :availability_zone, 'availabilityZone' attribute :dns_name, 'dnsName' - attribute :group_id, 'groupId' + attribute :groups attribute :image_id, 'imageId' attribute :state, 'instanceState' attribute :flavor_id, 'instanceType' @@ -23,6 +23,11 @@ module Fog attribute :reason attribute :user_data + def initialize(attributes) + @groups ||= [] + super + end + def addresses requires :id @@ -99,8 +104,8 @@ module Fog if @availability_zone options['Placement.AvailabilityZone'] = @availability_zone end - if @group_id - options['SecurityGroup'] = @group_id + unless @groups.empty? + options['SecurityGroup'] = @groups.first end if @kernel_id options['KernelId'] = @kernel_id diff --git a/lib/fog/aws/models/ec2/servers.rb b/lib/fog/aws/models/ec2/servers.rb index ebbdf9d31..25e3d4ce1 100644 --- a/lib/fog/aws/models/ec2/servers.rb +++ b/lib/fog/aws/models/ec2/servers.rb @@ -26,7 +26,7 @@ module Fog data = connection.describe_instances(server_id).body data['reservationSet'].each do |reservation| reservation['instancesSet'].each do |instance| - self << new(instance) + self << new(instance.merge(:groups => reservation['groupSet'])) end end self