logstash-mixin-aws 0.1.10 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -0
- data/README.md +1 -1
- data/lib/logstash/plugin_mixins/aws_config.rb +10 -83
- data/lib/logstash/plugin_mixins/aws_config/generic.rb +38 -0
- data/lib/logstash/plugin_mixins/aws_config/v1.rb +56 -0
- data/lib/logstash/plugin_mixins/aws_config/v2.rb +61 -0
- data/logstash-mixin-aws.gemspec +3 -2
- data/spec/plugin_mixin/aws_config_spec.rb +109 -15
- metadata +22 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f00cc7ea12d56fa9b3c604ee68cef128f7c9718b
|
4
|
+
data.tar.gz: 9b84affbeb7ded1589cb9fd42b3aebf94c188d5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2994e1df54cfb124c2fad4b4f27b61a7180c516ad7f602ef415968879104540e407dd16d5a74854462706ebb3c6cf1145ba790a16b16930f35c92bf5fdd71f12
|
7
|
+
data.tar.gz: bf8695dac26cd81bb4efc6f8b93b959de2ecac3634689e32f73166b4986e40ab51a89303e7e8d986ce717c3f5a2e061b144271ff0e7f6ed019a24aa74abd7bcc
|
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -13,7 +13,7 @@ Logstash provides infrastructure to automatically generate documentation for thi
|
|
13
13
|
|
14
14
|
## Need Help?
|
15
15
|
|
16
|
-
Need help? Try #logstash on freenode IRC or the logstash
|
16
|
+
Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
|
17
17
|
|
18
18
|
## Developing
|
19
19
|
|
@@ -1,93 +1,20 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require "logstash/config/mixin"
|
3
3
|
|
4
|
+
# This module provides helper for the `AWS-SDK` v1,
|
5
|
+
# and it will be deprecated in the near future, please use the V2 module
|
6
|
+
# for any new development.
|
4
7
|
module LogStash::PluginMixins::AwsConfig
|
8
|
+
require "logstash/plugin_mixins/aws_config/v1"
|
9
|
+
require "logstash/plugin_mixins/aws_config/v2"
|
5
10
|
|
6
|
-
|
11
|
+
US_EAST_1 = "us-east-1"
|
12
|
+
REGIONS_ENDPOINT = [US_EAST_1, "us-west-1", "us-west-2", "eu-central-1",
|
13
|
+
"eu-west-1", "ap-southeast-1", "ap-southeast-2",
|
14
|
+
"ap-northeast-1", "sa-east-1", "us-gov-west-1", "cn-north-1"]
|
7
15
|
|
8
|
-
# This method is called when someone includes this module
|
9
16
|
def self.included(base)
|
10
17
|
# Add these methods to the 'base' given.
|
11
|
-
base.
|
12
|
-
base.setup_aws_config
|
18
|
+
base.send(:include, V1)
|
13
19
|
end
|
14
|
-
|
15
|
-
US_EAST_1 = "us-east-1"
|
16
|
-
|
17
|
-
public
|
18
|
-
def setup_aws_config
|
19
|
-
# The AWS Region
|
20
|
-
config :region, :validate => [US_EAST_1, "us-west-1", "us-west-2", "eu-central-1",
|
21
|
-
"eu-west-1", "ap-southeast-1", "ap-southeast-2",
|
22
|
-
"ap-northeast-1", "sa-east-1", "us-gov-west-1",
|
23
|
-
"cn-north-1"], :default => US_EAST_1
|
24
|
-
|
25
|
-
# This plugin uses the AWS SDK and supports several ways to get credentials, which will be tried in this order...
|
26
|
-
# 1. Static configuration, using `access_key_id` and `secret_access_key` params in logstash plugin config
|
27
|
-
# 2. External credentials file specified by `aws_credentials_file`
|
28
|
-
# 3. Environment variables `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`
|
29
|
-
# 4. Environment variables `AMAZON_ACCESS_KEY_ID` and `AMAZON_SECRET_ACCESS_KEY`
|
30
|
-
# 5. IAM Instance Profile (available when running inside EC2)
|
31
|
-
config :access_key_id, :validate => :string
|
32
|
-
|
33
|
-
# The AWS Secret Access Key
|
34
|
-
config :secret_access_key, :validate => :string
|
35
|
-
|
36
|
-
# The AWS Session token for temprory credential
|
37
|
-
config :session_token, :validate => :string
|
38
|
-
|
39
|
-
# Should we require (true) or disable (false) using SSL for communicating with the AWS API
|
40
|
-
# The AWS SDK for Ruby defaults to SSL so we preserve that
|
41
|
-
config :use_ssl, :validate => :boolean, :default => true
|
42
|
-
|
43
|
-
# URI to proxy server if required
|
44
|
-
config :proxy_uri, :validate => :string
|
45
|
-
|
46
|
-
# Path to YAML file containing a hash of AWS credentials.
|
47
|
-
# This file will only be loaded if `access_key_id` and
|
48
|
-
# `secret_access_key` aren't set. The contents of the
|
49
|
-
# file should look like this:
|
50
|
-
#
|
51
|
-
# :access_key_id: "12345"
|
52
|
-
# :secret_access_key: "54321"
|
53
|
-
#
|
54
|
-
config :aws_credentials_file, :validate => :string
|
55
|
-
end
|
56
|
-
|
57
|
-
public
|
58
|
-
def aws_options_hash
|
59
|
-
opts = {}
|
60
|
-
|
61
|
-
if @access_key_id.is_a?(NilClass) ^ @secret_access_key.is_a?(NilClass)
|
62
|
-
@logger.warn("Likely config error: Only one of access_key_id or secret_access_key was provided but not both.")
|
63
|
-
end
|
64
|
-
|
65
|
-
if @access_key_id && @secret_access_key
|
66
|
-
opts = {
|
67
|
-
:access_key_id => @access_key_id,
|
68
|
-
:secret_access_key => @secret_access_key
|
69
|
-
}
|
70
|
-
opts[:session_token] = @session_token if @session_token
|
71
|
-
elsif @aws_credentials_file
|
72
|
-
opts = YAML.load_file(@aws_credentials_file)
|
73
|
-
end
|
74
|
-
|
75
|
-
opts[:proxy_uri] = @proxy_uri if @proxy_uri
|
76
|
-
opts[:use_ssl] = @use_ssl
|
77
|
-
|
78
|
-
|
79
|
-
# The AWS SDK for Ruby doesn't know how to make an endpoint hostname from a region
|
80
|
-
# for example us-west-1 -> foosvc.us-west-1.amazonaws.com
|
81
|
-
# So our plugins need to know how to generate their endpoints from a region
|
82
|
-
# Furthermore, they need to know the symbol required to set that value in the AWS SDK
|
83
|
-
# Classes using this module must implement aws_service_endpoint(region:string)
|
84
|
-
# which must return a hash with one key, the aws sdk for ruby config symbol of the service
|
85
|
-
# endpoint, which has a string value of the service endpoint hostname
|
86
|
-
# for example, CloudWatch, { :cloud_watch_endpoint => "monitoring.#{region}.amazonaws.com" }
|
87
|
-
# For a list, see https://github.com/aws/aws-sdk-ruby/blob/master/lib/aws/core/configuration.rb
|
88
|
-
opts.merge!(self.aws_service_endpoint(@region))
|
89
|
-
|
90
|
-
return opts
|
91
|
-
end # def aws_options_hash
|
92
|
-
|
93
20
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module LogStash::PluginMixins::AwsConfig::Generic
|
2
|
+
def self.included(base)
|
3
|
+
base.extend(self)
|
4
|
+
base.generic_aws_config
|
5
|
+
end
|
6
|
+
|
7
|
+
def generic_aws_config
|
8
|
+
# The AWS Region
|
9
|
+
config :region, :validate => LogStash::PluginMixins::AwsConfig::REGIONS_ENDPOINT, :default => LogStash::PluginMixins::AwsConfig::US_EAST_1
|
10
|
+
|
11
|
+
# This plugin uses the AWS SDK and supports several ways to get credentials, which will be tried in this order...
|
12
|
+
# 1. Static configuration, using `access_key_id` and `secret_access_key` params in logstash plugin config
|
13
|
+
# 2. External credentials file specified by `aws_credentials_file`
|
14
|
+
# 3. Environment variables `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`
|
15
|
+
# 4. Environment variables `AMAZON_ACCESS_KEY_ID` and `AMAZON_SECRET_ACCESS_KEY`
|
16
|
+
# 5. IAM Instance Profile (available when running inside EC2)
|
17
|
+
config :access_key_id, :validate => :string
|
18
|
+
|
19
|
+
# The AWS Secret Access Key
|
20
|
+
config :secret_access_key, :validate => :string
|
21
|
+
|
22
|
+
# The AWS Session token for temprory credential
|
23
|
+
config :session_token, :validate => :string
|
24
|
+
|
25
|
+
# URI to proxy server if required
|
26
|
+
config :proxy_uri, :validate => :string
|
27
|
+
|
28
|
+
# Path to YAML file containing a hash of AWS credentials.
|
29
|
+
# This file will only be loaded if `access_key_id` and
|
30
|
+
# `secret_access_key` aren't set. The contents of the
|
31
|
+
# file should look like this:
|
32
|
+
#
|
33
|
+
# :access_key_id: "12345"
|
34
|
+
# :secret_access_key: "54321"
|
35
|
+
#
|
36
|
+
config :aws_credentials_file, :validate => :string
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "logstash/plugin_mixins/aws_config/generic"
|
3
|
+
|
4
|
+
module LogStash::PluginMixins::AwsConfig::V1
|
5
|
+
def self.included(base)
|
6
|
+
# Make sure we require the V1 classes when including this module.
|
7
|
+
# require 'aws-sdk' will load v2 classes.
|
8
|
+
require "aws-sdk-v1"
|
9
|
+
base.extend(self)
|
10
|
+
base.send(:include, LogStash::PluginMixins::AwsConfig::Generic)
|
11
|
+
base.setup_aws_config
|
12
|
+
end
|
13
|
+
|
14
|
+
public
|
15
|
+
def setup_aws_config
|
16
|
+
# Should we require (true) or disable (false) using SSL for communicating with the AWS API
|
17
|
+
# The AWS SDK for Ruby defaults to SSL so we preserve that
|
18
|
+
config :use_ssl, :validate => :boolean, :default => true
|
19
|
+
end
|
20
|
+
|
21
|
+
public
|
22
|
+
def aws_options_hash
|
23
|
+
opts = {}
|
24
|
+
|
25
|
+
if @access_key_id.is_a?(NilClass) ^ @secret_access_key.is_a?(NilClass)
|
26
|
+
@logger.warn("Likely config error: Only one of access_key_id or secret_access_key was provided but not both.")
|
27
|
+
end
|
28
|
+
|
29
|
+
if @access_key_id && @secret_access_key
|
30
|
+
opts = {
|
31
|
+
:access_key_id => @access_key_id,
|
32
|
+
:secret_access_key => @secret_access_key
|
33
|
+
}
|
34
|
+
opts[:session_token] = @session_token if @session_token
|
35
|
+
elsif @aws_credentials_file
|
36
|
+
opts = YAML.load_file(@aws_credentials_file)
|
37
|
+
end
|
38
|
+
|
39
|
+
opts[:proxy_uri] = @proxy_uri if @proxy_uri
|
40
|
+
opts[:use_ssl] = @use_ssl
|
41
|
+
|
42
|
+
|
43
|
+
# The AWS SDK for Ruby doesn't know how to make an endpoint hostname from a region
|
44
|
+
# for example us-west-1 -> foosvc.us-west-1.amazonaws.com
|
45
|
+
# So our plugins need to know how to generate their endpoints from a region
|
46
|
+
# Furthermore, they need to know the symbol required to set that value in the AWS SDK
|
47
|
+
# Classes using this module must implement aws_service_endpoint(region:string)
|
48
|
+
# which must return a hash with one key, the aws sdk for ruby config symbol of the service
|
49
|
+
# endpoint, which has a string value of the service endpoint hostname
|
50
|
+
# for example, CloudWatch, { :cloud_watch_endpoint => "monitoring.#{region}.amazonaws.com" }
|
51
|
+
# For a list, see https://github.com/aws/aws-sdk-ruby/blob/master/lib/aws/core/configuration.rb
|
52
|
+
opts.merge!(self.aws_service_endpoint(@region))
|
53
|
+
|
54
|
+
return opts
|
55
|
+
end # def aws_options_hash
|
56
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "logstash/plugin_mixins/aws_config/generic"
|
3
|
+
|
4
|
+
module LogStash::PluginMixins::AwsConfig::V2
|
5
|
+
def self.included(base)
|
6
|
+
base.extend(self)
|
7
|
+
base.send(:include, LogStash::PluginMixins::AwsConfig::Generic)
|
8
|
+
end
|
9
|
+
|
10
|
+
public
|
11
|
+
def aws_options_hash
|
12
|
+
opts = {}
|
13
|
+
|
14
|
+
if @access_key_id.is_a?(NilClass) ^ @secret_access_key.is_a?(NilClass)
|
15
|
+
@logger.warn("Likely config error: Only one of access_key_id or secret_access_key was provided but not both.")
|
16
|
+
end
|
17
|
+
|
18
|
+
opts[:credentials] = credentials if credentials
|
19
|
+
|
20
|
+
opts[:proxy_uri] = @proxy_uri if @proxy_uri
|
21
|
+
|
22
|
+
# The AWS SDK for Ruby doesn't know how to make an endpoint hostname from a region
|
23
|
+
# for example us-west-1 -> foosvc.us-west-1.amazonaws.com
|
24
|
+
# So our plugins need to know how to generate their endpoints from a region
|
25
|
+
# Furthermore, they need to know the symbol required to set that value in the AWS SDK
|
26
|
+
# Classes using this module must implement aws_service_endpoint(region:string)
|
27
|
+
# which must return a hash with one key, the aws sdk for ruby config symbol of the service
|
28
|
+
# endpoint, which has a string value of the service endpoint hostname
|
29
|
+
# for example, CloudWatch, { :cloud_watch_endpoint => "monitoring.#{region}.amazonaws.com" }
|
30
|
+
# For a list, see https://github.com/aws/aws-sdk-ruby/blob/master/lib/aws/core/configuration.rb
|
31
|
+
if self.respond_to?(:aws_service_endpoint)
|
32
|
+
opts.merge!(self.aws_service_endpoint(@region))
|
33
|
+
else
|
34
|
+
opts.merge!({ :region => @region })
|
35
|
+
end
|
36
|
+
|
37
|
+
return opts
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
def credentials
|
42
|
+
@creds ||= begin
|
43
|
+
if @access_key_id && @secret_access_key
|
44
|
+
credentials_opts = {
|
45
|
+
:access_key_id => @access_key_id,
|
46
|
+
:secret_access_key => @secret_access_key
|
47
|
+
}
|
48
|
+
|
49
|
+
credentials_opts[:session_token] = @session_token if @session_token
|
50
|
+
elsif @aws_credentials_file
|
51
|
+
credentials_opts = YAML.load_file(@aws_credentials_file)
|
52
|
+
end
|
53
|
+
|
54
|
+
if credentials_opts
|
55
|
+
Aws::Credentials.new(credentials_opts[:access_key_id],
|
56
|
+
credentials_opts[:secret_access_key],
|
57
|
+
credentials_opts[:session_token])
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/logstash-mixin-aws.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-mixin-aws'
|
3
|
-
s.version = '0.
|
3
|
+
s.version = '1.0.0'
|
4
4
|
s.licenses = ['Apache License (2.0)']
|
5
5
|
s.summary = "AWS mixins to provide a unified interface for Amazon Webservice"
|
6
6
|
s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
|
@@ -18,7 +18,8 @@ Gem::Specification.new do |s|
|
|
18
18
|
# Gem dependencies
|
19
19
|
s.add_runtime_dependency "logstash-core", '>= 1.4.0', '< 2.0.0'
|
20
20
|
s.add_runtime_dependency 'logstash-codec-plain'
|
21
|
-
s.add_runtime_dependency 'aws-sdk', '
|
21
|
+
s.add_runtime_dependency 'aws-sdk-v1', '>= 1.61.0'
|
22
|
+
s.add_runtime_dependency 'aws-sdk', '~> 2.1.0'
|
22
23
|
s.add_development_dependency 'logstash-devutils'
|
23
24
|
end
|
24
25
|
|
@@ -3,9 +3,20 @@ require "logstash/devutils/rspec/spec_helper"
|
|
3
3
|
require "logstash/plugin_mixins/aws_config"
|
4
4
|
require 'aws-sdk'
|
5
5
|
|
6
|
-
class
|
7
|
-
include LogStash::PluginMixins::AwsConfig
|
6
|
+
class DummyInputAwsConfigV2 < LogStash::Inputs::Base
|
7
|
+
include LogStash::PluginMixins::AwsConfig::V2
|
8
8
|
|
9
|
+
def aws_service_endpoint(region)
|
10
|
+
{ :dummy_input_aws_config_region => "#{region}.awswebservice.local" }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class DummyInputAwsConfigV2NoRegionMethod < LogStash::Inputs::Base
|
15
|
+
include LogStash::PluginMixins::AwsConfig::V2
|
16
|
+
end
|
17
|
+
|
18
|
+
class DummyInputAwsConfigV1 < LogStash::Inputs::Base
|
19
|
+
include LogStash::PluginMixins::AwsConfig
|
9
20
|
|
10
21
|
def aws_service_endpoint(region)
|
11
22
|
{ :dummy_input_aws_config_region => "#{region}.awswebservice.local" }
|
@@ -13,10 +24,9 @@ class DummyInputAwsConfig < LogStash::Inputs::Base
|
|
13
24
|
end
|
14
25
|
|
15
26
|
describe LogStash::PluginMixins::AwsConfig do
|
16
|
-
|
17
27
|
let(:settings) { {} }
|
18
28
|
|
19
|
-
subject {
|
29
|
+
subject { DummyInputAwsConfigV1.new(settings).aws_options_hash }
|
20
30
|
|
21
31
|
describe 'config credential' do
|
22
32
|
|
@@ -24,8 +34,7 @@ describe LogStash::PluginMixins::AwsConfig do
|
|
24
34
|
let(:settings) { { 'aws_credentials_file' => File.join(File.dirname(__FILE__), '..', 'fixtures/aws_credentials_file_sample_test.yml') } }
|
25
35
|
|
26
36
|
it 'should support reading configuration from a yaml file' do
|
27
|
-
subject
|
28
|
-
subject[:secret_access_key].should == 'secret'
|
37
|
+
expect(subject).to include(:access_key_id => "1234", :secret_access_key => "secret")
|
29
38
|
end
|
30
39
|
end
|
31
40
|
|
@@ -34,9 +43,9 @@ describe LogStash::PluginMixins::AwsConfig do
|
|
34
43
|
let(:settings) { { 'access_key_id' => '1234', 'secret_access_key' => 'secret', 'session_token' => 'session_token' } }
|
35
44
|
|
36
45
|
it "should support passing as key, value, and session_token" do
|
37
|
-
subject[:access_key_id].
|
38
|
-
subject[:secret_access_key].
|
39
|
-
subject[:session_token].
|
46
|
+
expect(subject[:access_key_id]).to eq(settings["access_key_id"])
|
47
|
+
expect(subject[:secret_access_key]).to eq(settings["secret_access_key"])
|
48
|
+
expect(subject[:session_token]).to eq(settings["session_token"])
|
40
49
|
end
|
41
50
|
end
|
42
51
|
|
@@ -44,21 +53,19 @@ describe LogStash::PluginMixins::AwsConfig do
|
|
44
53
|
let(:settings) { { 'access_key_id' => '1234', 'secret_access_key' => 'secret' } }
|
45
54
|
|
46
55
|
it 'should support passing credentials as key, value' do
|
47
|
-
subject[:access_key_id].
|
48
|
-
subject[:secret_access_key].
|
56
|
+
expect(subject[:access_key_id]).to eq(settings['access_key_id'])
|
57
|
+
expect(subject[:secret_access_key]).to eq(settings['secret_access_key'])
|
49
58
|
end
|
50
59
|
end
|
51
60
|
end
|
52
|
-
|
53
61
|
end
|
54
62
|
|
55
63
|
describe 'config region' do
|
56
|
-
|
57
64
|
context 'region provided' do
|
58
65
|
let(:settings) { { 'access_key_id' => '1234', 'secret_access_key' => 'secret', 'region' => 'us-west-2' } }
|
59
66
|
|
60
67
|
it 'should use provided region to generate the endpoint configuration' do
|
61
|
-
subject[:dummy_input_aws_config_region].
|
68
|
+
expect(subject[:dummy_input_aws_config_region]).to eq("us-west-2.awswebservice.local")
|
62
69
|
end
|
63
70
|
end
|
64
71
|
|
@@ -66,7 +73,7 @@ describe LogStash::PluginMixins::AwsConfig do
|
|
66
73
|
let(:settings) { { 'access_key_id' => '1234', 'secret_access_key' => 'secret'} }
|
67
74
|
|
68
75
|
it 'should use default region to generate the endpoint configuration' do
|
69
|
-
subject[:dummy_input_aws_config_region].
|
76
|
+
expect(subject[:dummy_input_aws_config_region]).to eq("us-east-1.awswebservice.local")
|
70
77
|
end
|
71
78
|
end
|
72
79
|
end
|
@@ -78,3 +85,90 @@ describe LogStash::PluginMixins::AwsConfig do
|
|
78
85
|
end
|
79
86
|
end
|
80
87
|
end
|
88
|
+
|
89
|
+
describe LogStash::PluginMixins::AwsConfig::V2 do
|
90
|
+
let(:settings) { {} }
|
91
|
+
|
92
|
+
subject { DummyInputAwsConfigV2.new(settings).aws_options_hash }
|
93
|
+
|
94
|
+
describe 'config credential' do
|
95
|
+
subject { DummyInputAwsConfigV2.new(settings).aws_options_hash[:credentials] }
|
96
|
+
|
97
|
+
context 'in credential file' do
|
98
|
+
let(:settings) { { 'aws_credentials_file' => File.join(File.dirname(__FILE__), '..', 'fixtures/aws_credentials_file_sample_test.yml') } }
|
99
|
+
|
100
|
+
it 'should support reading configuration from a yaml file' do
|
101
|
+
expect(subject.access_key_id).to eq("1234")
|
102
|
+
expect(subject.secret_access_key).to eq("secret")
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
context 'inline' do
|
107
|
+
context 'temporary credential' do
|
108
|
+
let(:settings) { { 'access_key_id' => '1234', 'secret_access_key' => 'secret', 'session_token' => 'session_token' } }
|
109
|
+
|
110
|
+
it "should support passing as key, value, and session_token" do
|
111
|
+
expect(subject.access_key_id).to eq(settings['access_key_id'])
|
112
|
+
expect(subject.secret_access_key).to eq(settings['secret_access_key'])
|
113
|
+
expect(subject.session_token).to eq(settings['session_token'])
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
context 'normal credential' do
|
118
|
+
let(:settings) { { 'access_key_id' => '1234', 'secret_access_key' => 'secret' } }
|
119
|
+
|
120
|
+
it 'should support passing credentials as key, value' do
|
121
|
+
expect(subject.access_key_id).to eq(settings['access_key_id'])
|
122
|
+
expect(subject.secret_access_key).to eq(settings['secret_access_key'])
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
describe 'config region' do
|
129
|
+
context "when the class implement `#aws_service_endpoint`" do
|
130
|
+
context 'region provided' do
|
131
|
+
let(:settings) { { 'access_key_id' => '1234', 'secret_access_key' => 'secret', 'region' => 'us-west-2' } }
|
132
|
+
|
133
|
+
it 'should use provided region to generate the endpoint configuration' do
|
134
|
+
expect(subject).to include(:dummy_input_aws_config_region => "us-west-2.awswebservice.local")
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
context "region not provided" do
|
139
|
+
let(:settings) { { 'access_key_id' => '1234', 'secret_access_key' => 'secret'} }
|
140
|
+
|
141
|
+
it 'should use default region to generate the endpoint configuration' do
|
142
|
+
expect(subject).to include(:dummy_input_aws_config_region => "us-east-1.awswebservice.local")
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
context "when the classe doesn't implement `#aws_service_endpoint`" do
|
148
|
+
subject { DummyInputAwsConfigV2NoRegionMethod.new(settings).aws_options_hash }
|
149
|
+
|
150
|
+
context 'region provided' do
|
151
|
+
let(:settings) { { 'access_key_id' => '1234', 'secret_access_key' => 'secret', 'region' => 'us-west-2' } }
|
152
|
+
|
153
|
+
it 'should use provided region to generate the endpoint configuration' do
|
154
|
+
expect(subject[:region]).to eq("us-west-2")
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
context "region not provided" do
|
159
|
+
let(:settings) { { 'access_key_id' => '1234', 'secret_access_key' => 'secret'} }
|
160
|
+
|
161
|
+
it 'should use default region to generate the endpoint configuration' do
|
162
|
+
expect(subject[:region]).to eq("us-east-1")
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
context 'when we arent providing credentials' do
|
169
|
+
let(:settings) { {} }
|
170
|
+
it 'should always return a hash' do
|
171
|
+
expect(subject).to eq({ :dummy_input_aws_config_region => "us-east-1.awswebservice.local" })
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-mixin-aws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logstash-core
|
@@ -44,18 +44,32 @@ dependencies:
|
|
44
44
|
version: '0'
|
45
45
|
prerelease: false
|
46
46
|
type: :runtime
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: aws-sdk-v1
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.61.0
|
54
|
+
requirement: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: 1.61.0
|
59
|
+
prerelease: false
|
60
|
+
type: :runtime
|
47
61
|
- !ruby/object:Gem::Dependency
|
48
62
|
name: aws-sdk
|
49
63
|
version_requirements: !ruby/object:Gem::Requirement
|
50
64
|
requirements:
|
51
65
|
- - ~>
|
52
66
|
- !ruby/object:Gem::Version
|
53
|
-
version: 1.
|
67
|
+
version: 2.1.0
|
54
68
|
requirement: !ruby/object:Gem::Requirement
|
55
69
|
requirements:
|
56
70
|
- - ~>
|
57
71
|
- !ruby/object:Gem::Version
|
58
|
-
version: 1.
|
72
|
+
version: 2.1.0
|
59
73
|
prerelease: false
|
60
74
|
type: :runtime
|
61
75
|
- !ruby/object:Gem::Dependency
|
@@ -79,12 +93,16 @@ extensions: []
|
|
79
93
|
extra_rdoc_files: []
|
80
94
|
files:
|
81
95
|
- .gitignore
|
96
|
+
- CHANGELOG.md
|
82
97
|
- CONTRIBUTORS
|
83
98
|
- Gemfile
|
84
99
|
- LICENSE
|
85
100
|
- README.md
|
86
101
|
- Rakefile
|
87
102
|
- lib/logstash/plugin_mixins/aws_config.rb
|
103
|
+
- lib/logstash/plugin_mixins/aws_config/generic.rb
|
104
|
+
- lib/logstash/plugin_mixins/aws_config/v1.rb
|
105
|
+
- lib/logstash/plugin_mixins/aws_config/v2.rb
|
88
106
|
- logstash-mixin-aws.gemspec
|
89
107
|
- spec/fixtures/aws_credentials_file_sample_test.yml
|
90
108
|
- spec/fixtures/aws_temporary_credentials_file_sample_test.yml
|