Class: ThisIp::AWS::RDS

Inherits:
Object
  • Object
show all
Defined in:
lib/this_ip/services/aws/rds.rb

Class Method Summary collapse

Class Method Details

.auth(ip_address, config) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/this_ip/services/aws/rds.rb', line 12

def self.auth(ip_address, config)
  puts "AWS::RDS\n"

  begin
    result = ::AWS::RDS::Client.new.authorize_db_security_group_ingress(
      ::ThisIp::AWS::RDS.defaults.merge(config).merge(cidrip: ::ThisIp::Main.masked_ip_address(ip_address))
    )
    puts "  Authorized \"#{ip_address}\""
  rescue Exception => e
    puts "  Failed to authorize \"#{ip_address}\""
    puts "  Reason: \"#{e.message}\""
  end
end

.deauth(ip_address, config) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/this_ip/services/aws/rds.rb', line 26

def self.deauth(ip_address, config)
  puts "AWS::RDS\n"

  begin
    result = ::AWS::RDS::Client.new.revoke_db_security_group_ingress(
      ::ThisIp::AWS::RDS.defaults.merge(config).merge(cidrip: ::ThisIp::Main.masked_ip_address(ip_address))
    )
    puts "  Deauthorized \"#{ip_address}\""
  rescue Exception => e
    puts "  Failed to deauthorize \"#{ip_address}\""
    puts "  Reason: \"#{e.message}\""
  end
end

.defaultsObject



6
7
8
9
10
# File 'lib/this_ip/services/aws/rds.rb', line 6

def self.defaults
  {
    db_security_group_name: 'default',
  }
end