Class: Fawsade::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/fawsade/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(region:, access_key_id:, secret_access_key:) ⇒ Client

Returns a new instance of Client.



3
4
5
6
7
8
# File 'lib/fawsade/client.rb', line 3

def initialize(region:, access_key_id:, secret_access_key:)
  @client = Aws::EC2::Client.new(
    region: region,
    access_key_id: access_key_id,
    secret_access_key: secret_access_key)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *parameters, &block) ⇒ Object



18
19
20
# File 'lib/fawsade/client.rb', line 18

def method_missing(method_name, *parameters, &block)
  @client.send(method_name, *parameters, &block)
end

Instance Method Details

#instance_by_id(id) ⇒ Object



10
11
12
# File 'lib/fawsade/client.rb', line 10

def instance_by_id(id)
  instances.find { |instance| instance.id == id }
end

#instances_by_name(regex) ⇒ Object



14
15
16
# File 'lib/fawsade/client.rb', line 14

def instances_by_name(regex)
  instances.select { |instance| instance.name =~ /^#{regex}$/ }
end