Class: AWS::EC2::SecurityGroupCollection
- Inherits:
-
Collection
- Object
- Collection
- AWS::EC2::SecurityGroupCollection
- Defined in:
- lib/aws/ec2/security_group_collection.rb
Overview
Represents all EC2 security groups in an AWS account.
Instance Method Summary collapse
-
#[](group_id) ⇒ SecurityGroup
The group with the given id.
-
#create(name, options = {}) ⇒ SecurityGroup
Creates a new.
-
#each {|group| ... } ⇒ nil
Yields once for each security group in this account.
Instance Method Details
#[](group_id) ⇒ SecurityGroup
Returns The group with the given id.
55 56 57 |
# File 'lib/aws/ec2/security_group_collection.rb', line 55 def [] group_id super end |
#create(name, options = {}) ⇒ SecurityGroup
Creates a new
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/aws/ec2/security_group_collection.rb', line 34 def create name, = {} description = [:description] || name create_opts = {} create_opts[:group_name] = name create_opts[:description] = description create_opts[:vpc_id] = [:vpc_id] if [:vpc_id] response = client.create_security_group(create_opts) SecurityGroup.new(response.group_id, { :name => name, :description => description, :vpc_id => [:vpc_id], :config => config }) end |
#each {|group| ... } ⇒ nil
Yields once for each security group in this account.
111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/aws/ec2/security_group_collection.rb', line 111 def each &block response = filtered_request(:describe_security_groups) response.security_group_info.each do |info| group = SecurityGroup.new_from(:describe_security_groups, info, info.group_id, :config => config) yield(group) end nil end |