Sha256: 9b7d619c405e46b2a1225feeb34a4cea6f4e05307fa5c3ae9696bac2b938ca6d

Contents?: true

Size: 833 Bytes

Versions: 21

Compression:

Stored size: 833 Bytes

Contents

# frozen_string_literal: true

module Common
  def initialize
    super()
    aws_config
  end

  def aws_config
    if config[:aws_access_key_id] && config[:aws_secret_access_key]
      Aws.config.update(
        credentials: Aws::Credentials.new(config[:aws_access_key_id], config[:aws_secret_access_key])
      )
    end

    Aws.config.update(
      region: config[:aws_region]
    )
  end

  def merge_s3_config
    return if config[:s3_config_bucket].nil? || config[:s3_config_key].nil?

    aws_config

    s3 = Aws::S3::Client.new
    begin
      resp = s3.get_object(bucket: config[:s3_config_bucket], key: config[:s3_config_key])
      s3_config = JSON.parse(resp.body.read, symbolize_names: true)
      config.merge!(s3_config)
    rescue StandardError
      critical 'Error getting config file from s3'
    end
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
sensu-plugins-http-boutetnico-1.2.0 lib/sensu-plugins-http/common.rb
sensu-plugins-http-boutetnico-1.1.0 lib/sensu-plugins-http/common.rb
sensu-plugins-http-boutetnico-1.0.1 lib/sensu-plugins-http/common.rb
sensu-plugins-http-boutetnico-1.0.0 lib/sensu-plugins-http/common.rb
sensu-plugins-http-6.1.0 lib/sensu-plugins-http/common.rb
sensu-plugins-http-6.0.1 lib/sensu-plugins-http/common.rb
sensu-plugins-http-6.0.0 lib/sensu-plugins-http/common.rb
sensu-plugins-http-5.1.1 lib/sensu-plugins-http/common.rb
sensu-plugins-http-5.1.0 lib/sensu-plugins-http/common.rb
sensu-plugins-http-5.0.0 lib/sensu-plugins-http/common.rb
sensu-plugins-http-4.1.0 lib/sensu-plugins-http/common.rb
sensu-plugins-http-4.0.0 lib/sensu-plugins-http/common.rb
sensu-plugins-http-3.0.1 lib/sensu-plugins-http/common.rb
sensu-plugins-http-3.0.0 lib/sensu-plugins-http/common.rb
sensu-plugins-http-2.11.0 lib/sensu-plugins-http/common.rb
sensu-plugins-http-2.10.0 lib/sensu-plugins-http/common.rb
sensu-plugins-http-2.9.0 lib/sensu-plugins-http/common.rb
sensu-plugins-http-2.8.4 lib/sensu-plugins-http/common.rb
sensu-plugins-http-2.8.3 lib/sensu-plugins-http/common.rb
sensu-plugins-http-2.8.2 lib/sensu-plugins-http/common.rb