class Opsicle::Client

Attributes

config[R]
ec2[R]
opsworks[R]
s3[R]

Public Class Methods

new(environment) click to toggle source
# File lib/opsicle/client.rb, line 10
def initialize(environment)
  @config = Config.instance
  @config.configure_aws_environment!(environment)
  credentials = @config.aws_credentials
  region = @config.opsworks_region
  aws_opts = {region: region}
  aws_opts[:credentials] = credentials unless credentials.nil?
  @opsworks = Aws::OpsWorks::Client.new aws_opts
  @ec2 = Aws::EC2::Client.new aws_opts
  @s3 = Aws::S3::Client.new aws_opts
end

Public Instance Methods

api_call(command, options={}) click to toggle source
# File lib/opsicle/client.rb, line 28
def api_call(command, options={})
  opsworks.public_send(command, options).to_h
end
opsworks_url() click to toggle source
# File lib/opsicle/client.rb, line 32
def opsworks_url
  "https://console.aws.amazon.com/opsworks/home?#/stack/#{@config.opsworks_config[:stack_id]}"
end
run_command(command, command_args={}, options={}) click to toggle source
# File lib/opsicle/client.rb, line 22
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_config() click to toggle source
# File lib/opsicle/client.rb, line 36
def stack_config
  {
    stack_id: config.opsworks_config[:stack_id],
    app_id: config.opsworks_config[:app_id]
  }
end

Private Instance Methods

command_options(command, command_args={}, options={}) click to toggle source
# File lib/opsicle/client.rb, line 43
def command_options(command, command_args={}, options={})
  stack_config.merge(options).merge({ command: { name: command, args: command_args } })
end