Class: Opsicle::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(environment) ⇒ Client

Returns a new instance of Client.



9
10
11
12
13
14
15
# File 'lib/opsicle/client.rb', line 9

def initialize(environment)
  @config = Config.instance
  @config.configure_aws_environment!(environment)
  credentials = @config.aws_credentials
  @opsworks = Aws::OpsWorks::Client.new(region: 'us-east-1', credentials: credentials)
  @s3 = Aws::S3::Client.new(region: 'us-east-1', credentials: credentials)
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



7
8
9
# File 'lib/opsicle/client.rb', line 7

def config
  @config
end

#opsworksObject (readonly)

Returns the value of attribute opsworks.



5
6
7
# File 'lib/opsicle/client.rb', line 5

def opsworks
  @opsworks
end

#s3Object (readonly)

Returns the value of attribute s3.



6
7
8
# File 'lib/opsicle/client.rb', line 6

def s3
  @s3
end

Instance Method Details

#api_call(command, options = {}) ⇒ Object



23
24
25
# File 'lib/opsicle/client.rb', line 23

def api_call(command, options={})
  opsworks.public_send(command, options).to_h
end

#opsworks_urlObject



27
28
29
# File 'lib/opsicle/client.rb', line 27

def opsworks_url
  "https://console.aws.amazon.com/opsworks/home?#/stack/#{@config.opsworks_config[:stack_id]}"
end

#run_command(command, command_args = {}, options = {}) ⇒ Object



17
18
19
20
21
# File 'lib/opsicle/client.rb', line 17

def run_command(command, command_args={}, options={})
  opts = command_options(command, command_args, options)
  Output.say_verbose "OpsWorks call: create_deployment(#{opts})"
  opsworks.create_deployment(opts)
end

#stack_configObject



31
32
33
34
35
36
# File 'lib/opsicle/client.rb', line 31

def stack_config
  {
    stack_id: config.opsworks_config[:stack_id],
    app_id: config.opsworks_config[:app_id]
  }
end