Class: Opsicle::Client
- Inherits:
-
Object
- Object
- Opsicle::Client
- Defined in:
- lib/opsicle/client.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#ec2 ⇒ Object
readonly
Returns the value of attribute ec2.
-
#opsworks ⇒ Object
readonly
Returns the value of attribute opsworks.
-
#s3 ⇒ Object
readonly
Returns the value of attribute s3.
Instance Method Summary collapse
- #api_call(command, options = {}) ⇒ Object
-
#initialize(environment) ⇒ Client
constructor
A new instance of Client.
- #opsworks_url ⇒ Object
- #run_command(command, command_args = {}, options = {}) ⇒ Object
- #stack_config ⇒ Object
Constructor Details
#initialize(environment) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 15 16 17 18 19 20 |
# 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 |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/opsicle/client.rb', line 8 def config @config end |
#ec2 ⇒ Object (readonly)
Returns the value of attribute ec2.
6 7 8 |
# File 'lib/opsicle/client.rb', line 6 def ec2 @ec2 end |
#opsworks ⇒ Object (readonly)
Returns the value of attribute opsworks.
5 6 7 |
# File 'lib/opsicle/client.rb', line 5 def opsworks @opsworks end |
#s3 ⇒ Object (readonly)
Returns the value of attribute s3.
7 8 9 |
# File 'lib/opsicle/client.rb', line 7 def s3 @s3 end |
Instance Method Details
#api_call(command, options = {}) ⇒ Object
28 29 30 |
# File 'lib/opsicle/client.rb', line 28 def api_call(command, ={}) opsworks.public_send(command, ).to_h end |
#opsworks_url ⇒ Object
32 33 34 |
# 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 = {}) ⇒ Object
22 23 24 25 26 |
# File 'lib/opsicle/client.rb', line 22 def run_command(command, command_args={}, ={}) opts = (command, command_args, ) Output.say_verbose "OpsWorks call: create_deployment(#{opts})" opsworks.create_deployment(opts) end |
#stack_config ⇒ Object
36 37 38 39 40 41 |
# 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 |