Sha256: 842af22087568fb0f4800aa1076bf3ee8bc4b8b8fa58f695b1abe72d3a5bcf28

Contents?: true

Size: 688 Bytes

Versions: 3

Compression:

Stored size: 688 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, stack_name, app_name)
        super stack_name

        @environment = environment
        @app_name = app_name
      end

      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
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ops_preflight-1.1.2 lib/ops_preflight/ops_works/fetch_environment.rb
ops_preflight-1.1.1 lib/ops_preflight/ops_works/fetch_environment.rb
ops_preflight-1.1.0 lib/ops_preflight/ops_works/fetch_environment.rb