Class: Ec2Provider

Inherits:
Object
  • Object
show all
Defined in:
lib/provider/ec2.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Ec2Provider

Returns a new instance of Ec2Provider.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/provider/ec2.rb', line 5

def initialize(options)
  @options = options
  conn_opts = {
    region: options[:region],
    access_key_id: options[:access_key],
    secret_access_key: options[:secret_key],
    session_token: options[:session_token]
  }.delete_if {|k,v| v.nil?}

  @client = Aws::EC2::Client.new(conn_opts)
end

Instance Method Details

#security_groupsObject



17
18
19
20
21
22
23
# File 'lib/provider/ec2.rb', line 17

def security_groups
  @client.describe_security_groups.security_groups.reject { |sg|
    @options[:vpc_id] && sg.vpc_id != @options[:vpc_id]
  }.collect { |sg|
    Ec2::SecurityGroup.new(sg)
  }
end