Module: LogStash::PluginMixins::AwsConfig::V1

Defined in:
lib/logstash/plugin_mixins/aws_config/v1.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/logstash/plugin_mixins/aws_config/v1.rb', line 5

def self.included(base)
  # Make sure we require the V1 classes when including this module.
  # require 'aws-sdk' will load v2 classes.
  require "aws-sdk-v1"
  base.extend(self)
  base.send(:include, LogStash::PluginMixins::AwsConfig::Generic)
  base.setup_aws_config
end

Instance Method Details

#aws_options_hashObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/logstash/plugin_mixins/aws_config/v1.rb', line 22

def aws_options_hash
  opts = {}

  if @access_key_id.is_a?(NilClass) ^ @secret_access_key.is_a?(NilClass)
    @logger.warn("Likely config error: Only one of access_key_id or secret_access_key was provided but not both.")
  end

  if @access_key_id && @secret_access_key
    opts = {
      :access_key_id => @access_key_id,
      :secret_access_key => @secret_access_key
    }
    opts[:session_token] = @session_token if @session_token
  elsif @aws_credentials_file
    opts = YAML.load_file(@aws_credentials_file)
  end

  opts[:proxy_uri] = @proxy_uri if @proxy_uri
  opts[:use_ssl] = @use_ssl


  # The AWS SDK for Ruby doesn't know how to make an endpoint hostname from a region
  # for example us-west-1 -> foosvc.us-west-1.amazonaws.com
  # So our plugins need to know how to generate their endpoints from a region
  # Furthermore, they need to know the symbol required to set that value in the AWS SDK
  # Classes using this module must implement aws_service_endpoint(region:string)
  # which must return a hash with one key, the aws sdk for ruby config symbol of the service
  # endpoint, which has a string value of the service endpoint hostname
  # for example, CloudWatch, { :cloud_watch_endpoint => "monitoring.#{region}.amazonaws.com" }
  # For a list, see https://github.com/aws/aws-sdk-ruby/blob/master/lib/aws/core/configuration.rb
  opts.merge!(self.aws_service_endpoint(@region))

  return opts
end

#setup_aws_configObject



15
16
17
18
19
# File 'lib/logstash/plugin_mixins/aws_config/v1.rb', line 15

def setup_aws_config
  # Should we require (true) or disable (false) using SSL for communicating with the AWS API
  # The AWS SDK for Ruby defaults to SSL so we preserve that
  config :use_ssl, :validate => :boolean, :default => true
end