Class: ThisIp::AWS::EC2
- Inherits:
-
Object
- Object
- ThisIp::AWS::EC2
- Defined in:
- lib/this_ip/services/aws/ec2.rb
Class Method Summary collapse
Class Method Details
.auth(ip_address, config) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/this_ip/services/aws/ec2.rb', line 15 def self.auth(ip_address, config) puts "AWS::EC2\n" begin result = ::AWS::EC2::Client.new.( ::ThisIp::AWS::EC2.defaults.merge(config).merge(cidr_ip: ::ThisIp::Main.masked_ip_address(ip_address)) ) puts " Authorized \"#{ip_address}\"" rescue Exception => e puts " Failed to authorize \"#{ip_address}\"" puts " Reason: \"#{e.}\"" end end |
.deauth(ip_address, config) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/this_ip/services/aws/ec2.rb', line 29 def self.deauth(ip_address, config) puts "AWS::EC2\n" begin result = ::AWS::EC2::Client.new.revoke_security_group_ingress( ::ThisIp::AWS::EC2.defaults.merge(config).merge(cidr_ip: ::ThisIp::Main.masked_ip_address(ip_address)) ) puts " Deauthorized \"#{ip_address}\"" rescue Exception => e puts " Failed to deauthorize \"#{ip_address}\"" puts " Reason: \"#{e.}\"" end end |
.defaults ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/this_ip/services/aws/ec2.rb', line 6 def self.defaults { group_name: 'default', ip_protocol: 'tcp', from_port: 22, to_port: 22 } end |