Class: Fog::AWS::EC2::SecurityGroup

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/aws/models/ec2/security_group.rb

Instance Attribute Summary

Attributes inherited from Model

#connection

Instance Method Summary collapse

Methods inherited from Model

#_dump, _load, aliases, attribute, attributes, #attributes, #collection, identity, #identity, #initialize, #inspect, #merge_attributes, #new_record?, #reload, #requires, #to_json, #wait_for

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#authorize_group_and_owner(group, owner) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/fog/aws/models/ec2/security_group.rb', line 15

def authorize_group_and_owner(group, owner)
  requires :name

  connection.authorize_security_group_ingress(
    'GroupName'                   => @name,
    'SourceSecurityGroupName'     => group,
    'SourceSecurityGroupOwnerId'  => owner
  )
end

#authorize_port_range(range, options = {}) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/aws/models/ec2/security_group.rb', line 25

def authorize_port_range(range, options = {})
  requires :name

  connection.authorize_security_group_ingress(
    'CidrIp'      => options[:cidr_ip] || '0.0.0.0/0',
    'FromPort'    => range.min,
    'GroupName'   => @name,
    'ToPort'      => range.max,
    'IpProtocol'  => options[:ip_protocol] || 'tcp' 
  )
end

#destroyObject



37
38
39
40
41
42
# File 'lib/fog/aws/models/ec2/security_group.rb', line 37

def destroy
  requires :name

  connection.delete_security_group(@name)
  true
end

#saveObject



44
45
46
47
48
49
# File 'lib/fog/aws/models/ec2/security_group.rb', line 44

def save
  requires :description, :name

  data = connection.create_security_group(@name, @description).body
  true
end