Class: Fog::AWS::RDS::SecurityGroup

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

Instance Method Summary collapse

Instance Method Details

#authorize_cidrip(cidrip) ⇒ Object



41
42
43
# File 'lib/fog/aws/models/rds/security_group.rb', line 41

def authorize_cidrip(cidrip)
  authorize_ingress({'CIDRIP' => cidrip})
end

#authorize_ec2_security_group(group_name, group_owner_id = owner_id) ⇒ Object

group_owner_id defaults to the current owner_id



34
35
36
37
38
39
# File 'lib/fog/aws/models/rds/security_group.rb', line 34

def authorize_ec2_security_group(group_name, group_owner_id=owner_id)
  authorize_ingress({
    'EC2SecurityGroupName' => group_name,
    'EC2SecurityGroupOwnerId' => group_owner_id
  })
end

#authorize_ingress(opts) ⇒ Object



55
56
57
58
# File 'lib/fog/aws/models/rds/security_group.rb', line 55

def authorize_ingress(opts)
  data = service.authorize_db_security_group_ingress(id, opts).body['AuthorizeDBSecurityGroupIngressResult']['DBSecurityGroup']
  merge_attributes(data)
end

#authorize_ip_address(ip) ⇒ Object

Add the ip address to the RDS security group.



51
52
53
# File 'lib/fog/aws/models/rds/security_group.rb', line 51

def authorize_ip_address(ip)
  authorize_cidrip("#{ip}/32")
end

#authorize_meObject

Add the current machine to the RDS security group.



46
47
48
# File 'lib/fog/aws/models/rds/security_group.rb', line 46

def authorize_me
  authorize_ip_address(Fog::CurrentMachine.ip_address)
end

#destroyObject



18
19
20
21
22
# File 'lib/fog/aws/models/rds/security_group.rb', line 18

def destroy
  requires :id
  service.delete_db_security_group(id)
  true
end

#ready?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/fog/aws/models/rds/security_group.rb', line 14

def ready?
  (ec2_security_groups + ip_ranges).all?{|ingress| ingress['Status'] == 'authorized'}
end

#revoke_cidrip(cidrip) ⇒ Object



68
69
70
# File 'lib/fog/aws/models/rds/security_group.rb', line 68

def revoke_cidrip(cidrip)
  revoke_ingress({'CIDRIP' => cidrip})
end

#revoke_ec2_security_group(group_name, group_owner_id = owner_id) ⇒ Object

group_owner_id defaults to the current owner_id



61
62
63
64
65
66
# File 'lib/fog/aws/models/rds/security_group.rb', line 61

def revoke_ec2_security_group(group_name, group_owner_id=owner_id)
  revoke_ingress({
    'EC2SecurityGroupName' => group_name,
    'EC2SecurityGroupOwnerId' => group_owner_id
  })
end

#revoke_ingress(opts) ⇒ Object



72
73
74
75
# File 'lib/fog/aws/models/rds/security_group.rb', line 72

def revoke_ingress(opts)
  data = service.revoke_db_security_group_ingress(id, opts).body['RevokeDBSecurityGroupIngressResult']['DBSecurityGroup']
  merge_attributes(data)
end

#saveObject



24
25
26
27
28
29
30
31
# File 'lib/fog/aws/models/rds/security_group.rb', line 24

def save
  requires :id
  requires :description

  data = service.create_db_security_group(id, description).body['CreateDBSecurityGroupResult']['DBSecurityGroup']
  merge_attributes(data)
  true
end