Class: OpsPreflight::OpsWorks::FetchEnvironment

Inherits:
Base
  • Object
show all
Defined in:
lib/ops_preflight/ops_works/fetch_environment.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#stack_name

Instance Method Summary collapse

Constructor Details

#initialize(environment, stack_name, app_name) ⇒ FetchEnvironment

Returns a new instance of FetchEnvironment.



11
12
13
14
15
16
# File 'lib/ops_preflight/ops_works/fetch_environment.rb', line 11

def initialize(environment, stack_name, app_name)
  super stack_name

  @environment = environment
  @app_name = app_name
end

Instance Attribute Details

#app_nameObject

Returns the value of attribute app_name.



8
9
10
# File 'lib/ops_preflight/ops_works/fetch_environment.rb', line 8

def app_name
  @app_name
end

#environmentObject

Returns the value of attribute environment.



9
10
11
# File 'lib/ops_preflight/ops_works/fetch_environment.rb', line 9

def environment
  @environment
end

Instance Method Details

#callObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ops_preflight/ops_works/fetch_environment.rb', line 18

def call
  resp = opsworks.client.describe_stacks(:stack_ids => [stack_id])

  require 'multi_json'

  json = MultiJson.load(resp[:stacks].first[:custom_json])

  File.open("config/application.yml", 'wb') do |f|
    f.write json['env_vars'][app_name].to_yaml
  end
end