Sha256: e5030bed47c408549e45437285d5caf8ce837b7c41d8f92d8cc9376168ee57ca

Contents?: true

Size: 771 Bytes

Versions: 12

Compression:

Stored size: 771 Bytes

Contents

module Common
  def initialize
    super()
    aws_config
  end

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

    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
      critical 'Error getting config file from s3'
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
sensu-plugins-http-2.8.0 lib/sensu-plugins-http/common.rb
sensu-plugins-http-2.7.0 lib/sensu-plugins-http/common.rb
sensu-plugins-http-2.6.0 lib/sensu-plugins-http/common.rb
sensu-plugins-http-2.5.0 lib/sensu-plugins-http/common.rb
sensu-plugins-http-2.4.0 lib/sensu-plugins-http/common.rb
sensu-plugins-http-2.3.0 lib/sensu-plugins-http/common.rb
sensu-plugins-http-2.2.0 lib/sensu-plugins-http/common.rb
sensu-plugins-http-2.1.0 lib/sensu-plugins-http/common.rb
sensu-plugins-http-2.0.2 lib/sensu-plugins-http/common.rb
sensu-plugins-http-2.0.1 lib/sensu-plugins-http/common.rb
sensu-plugins-http-2.0.0 lib/sensu-plugins-http/common.rb
sensu-plugins-http-1.0.0 lib/sensu-plugins-http/common.rb