diff --git a/lib/fog/aws.rb b/lib/fog/aws.rb index 95f641263..ae53e4350 100644 --- a/lib/fog/aws.rb +++ b/lib/fog/aws.rb @@ -22,6 +22,7 @@ module Fog service(:sqs, 'aws/sqs', 'SQS') service(:sts, 'aws/sts', 'STS') service(:storage, 'aws/storage', 'Storage') + service(:vpc, 'aws/vpc', 'VPC') def self.indexed_param(key, values) params = {} diff --git a/lib/fog/aws/models/compute/security_group.rb b/lib/fog/aws/models/compute/security_group.rb index 23d746d61..f7fbc31b3 100644 --- a/lib/fog/aws/models/compute/security_group.rb +++ b/lib/fog/aws/models/compute/security_group.rb @@ -11,6 +11,7 @@ module Fog attribute :group_id, :aliases => 'groupId' attribute :ip_permissions, :aliases => 'ipPermissions' attribute :owner_id, :aliases => 'ownerId' + attribute :vpc_id, :aliases => 'vpcId' # Authorize access by another security group # @@ -193,8 +194,11 @@ module Fog def save requires :description, :name - - data = connection.create_security_group(name, description).body + if (vpc_id.length) + data = connection.create_security_group(name, description, vpc_id).body + else + data = connection.create_security_group(name, description).body + end true end diff --git a/lib/fog/aws/models/compute/security_groups.rb b/lib/fog/aws/models/compute/security_groups.rb index 50a0fe0ff..1b1b2674d 100644 --- a/lib/fog/aws/models/compute/security_groups.rb +++ b/lib/fog/aws/models/compute/security_groups.rb @@ -25,6 +25,7 @@ module Fog # description=nil, # ip_permissions=nil, # owner_id=nil + # vpc_id=nil # > # @@ -50,6 +51,7 @@ module Fog # description="default group", # ip_permissions=[{"groups"=>[{"groupName"=>"default", "userId"=>"312571045469"}], "fromPort"=>-1, "toPort"=>-1, "ipRanges"=>[], "ipProtocol"=>"icmp"}, {"groups"=>[{"groupName"=>"default", "userId"=>"312571045469"}], "fromPort"=>0, "toPort"=>65535, "ipRanges"=>[], "ipProtocol"=>"tcp"}, {"groups"=>[{"groupName"=>"default", "userId"=>"312571045469"}], "fromPort"=>0, "toPort"=>65535, "ipRanges"=>[], "ipProtocol"=>"udp"}], # owner_id="312571045469" + # vpc_id=nill # > # ] # > @@ -79,6 +81,7 @@ module Fog # description="default group", # ip_permissions=[{"groups"=>[{"groupName"=>"default", "userId"=>"312571045469"}], "fromPort"=>-1, "toPort"=>-1, "ipRanges"=>[], "ipProtocol"=>"icmp"}, {"groups"=>[{"groupName"=>"default", "userId"=>"312571045469"}], "fromPort"=>0, "toPort"=>65535, "ipRanges"=>[], "ipProtocol"=>"tcp"}, {"groups"=>[{"groupName"=>"default", "userId"=>"312571045469"}], "fromPort"=>0, "toPort"=>65535, "ipRanges"=>[], "ipProtocol"=>"udp"}], # owner_id="312571045469" + # vpc_id=nil # > # diff --git a/lib/fog/aws/parsers/compute/describe_security_groups.rb b/lib/fog/aws/parsers/compute/describe_security_groups.rb index 876889918..f157f36b0 100644 --- a/lib/fog/aws/parsers/compute/describe_security_groups.rb +++ b/lib/fog/aws/parsers/compute/describe_security_groups.rb @@ -40,7 +40,7 @@ module Fog end when 'groups' @in_groups = false - when 'groupDescription', 'ownerId', 'groupId' + when 'groupDescription', 'ownerId', 'groupId', 'vpcId' @security_group[name] = value when 'groupName' if @in_groups diff --git a/lib/fog/aws/requests/compute/create_security_group.rb b/lib/fog/aws/requests/compute/create_security_group.rb index 998ebd629..c0de995ed 100644 --- a/lib/fog/aws/requests/compute/create_security_group.rb +++ b/lib/fog/aws/requests/compute/create_security_group.rb @@ -18,12 +18,13 @@ module Fog # * 'return'<~Boolean> - success? # # {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateSecurityGroup.html] - def create_security_group(name, description) + def create_security_group(name, description, vpc_id='') request( 'Action' => 'CreateSecurityGroup', 'GroupName' => name, 'GroupDescription' => description, - :parser => Fog::Parsers::Compute::AWS::Basic.new + :parser => Fog::Parsers::Compute::AWS::Basic.new, + 'VpcId' => vpc_id ) end @@ -31,7 +32,7 @@ module Fog class Mock - def create_security_group(name, description) + def create_security_group(name, description, vpc_id='') response = Excon::Response.new unless self.data[:security_groups][name] data = { @@ -39,7 +40,8 @@ module Fog 'groupName' => name, 'ipPermissionsEgress' => [], 'ipPermissions' => [], - 'ownerId' => self.data[:owner_id] + 'ownerId' => self.data[:owner_id], + 'vpcId' => vpc_id } self.data[:security_groups][name] = data response.body = {