Sha256: 292a817285099f606880ea1d4a8f0692ad351164dbadb1744a5a822650471d93

Contents?: true

Size: 697 Bytes

Versions: 4

Compression:

Stored size: 697 Bytes

Contents

require 'yaml'

module OpsPreflight
  module OpsWorks
    require 'ops_preflight/ops_works/base'

    class FetchEnvironment < Base
      attr_accessor :app_name
      attr_accessor :environment

      def initialize(environment, region, stack_name, app_name)
        super region, stack_name

        @environment = environment
        @app_name = app_name
      end

      def call
        resp = opsworks.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
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ops_preflight-1.3.1 lib/ops_preflight/ops_works/fetch_environment.rb
ops_preflight-1.3.0 lib/ops_preflight/ops_works/fetch_environment.rb
ops_preflight-1.2.1 lib/ops_preflight/ops_works/fetch_environment.rb
ops_preflight-1.2.0 lib/ops_preflight/ops_works/fetch_environment.rb