From 9d386f291ff45c1f34c307ae4a4de3e00f904b8a Mon Sep 17 00:00:00 2001 From: Gaurish Sharma Date: Sun, 12 Jan 2014 02:16:02 +0530 Subject: [PATCH] Check if security group is nil, fixes #2507 --- lib/fog/aws/models/compute/servers.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/fog/aws/models/compute/servers.rb b/lib/fog/aws/models/compute/servers.rb index fe71ff555..0bdc14f14 100644 --- a/lib/fog/aws/models/compute/servers.rb +++ b/lib/fog/aws/models/compute/servers.rb @@ -84,9 +84,14 @@ module Fog ) end end - - # make sure port 22 is open in the first security group + security_group = service.security_groups.get(server.groups.first) + if security_group.nil? + raise Fog::Compute::AWS::Error, "The security group" \ + " #{server.groups.first} doesn't exist." + end + + # make sure port 22 is open in the first security group authorized = security_group.ip_permissions.detect do |ip_permission| ip_permission['ipRanges'].first && ip_permission['ipRanges'].first['cidrIp'] == '0.0.0.0/0' && ip_permission['fromPort'] == 22 &&