logstash-mixin-aws 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 25a7589cd0a440855b84089ebd593f1313f14b50
4
- data.tar.gz: 971fd6a774425844aaebb50e10a1142558531546
3
+ metadata.gz: bde334ed24960529b1f8abafbc95324516aaf338
4
+ data.tar.gz: d08c1fc0692a0bca830172112915fa75d949d2f1
5
5
  SHA512:
6
- metadata.gz: f31976bcb6beaf283b6fe8043fb3b6560dfa881f2357464d3f1c6449d232fccf95b512953dfcfd6b42bf83a3c380221ae254b273932e6a74f953871b6af45996
7
- data.tar.gz: 7f69de4174db11ac870b381700c4192daca1a5d289a8a289dee11edd548f8f42ed8ceaf9c5e01feb3733c19569562bcdddf2b377f7d4538f4876a5ad6be1c032
6
+ metadata.gz: 1acae776591222fdf759c19cdabad18ddfa9efe1470d7c6e82f2b01590f336f9262787f03efbe9758e8ae9e9fec5a640015cede2d6f28280c47275b93e54e1b0
7
+ data.tar.gz: 02292f1b153ab00661018f61880d01b0508a48f69564d1566a2aa985299247368fe413f16703cfae2f2ca3e0a871b921d71ed179cd59822a6058695d4bebac81
@@ -0,0 +1,12 @@
1
+ The following is a list of people who have contributed ideas, code, bug
2
+ reports, or in general have helped logstash along its way.
3
+
4
+ Contributors:
5
+ * Jordan Sissel (jordansissel)
6
+ * Malthe Borch (malthe)
7
+ * Pier-Hugues Pellerin (ph)
8
+
9
+ Note: If you've sent us patches, bug reports, or otherwise contributed to
10
+ Logstash, and you aren't on the list above and want to be, please let us know
11
+ and we'll make sure you're here. Contributions from folks like you are what make
12
+ open source awesome.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012-2014 Elasticsearch <http://www.elasticsearch.org>
1
+ Copyright (c) 2012-2015 Elasticsearch <http://www.elasticsearch.org>
2
2
 
3
3
  Licensed under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License.
@@ -0,0 +1,95 @@
1
+ # Logstash Plugin
2
+
3
+ This is a plugin for [Logstash](https://github.com/elasticsearch/logstash).
4
+
5
+ It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
6
+
7
+ ## Documentation
8
+
9
+ Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elasticsearch.org/guide/en/logstash/current/).
10
+
11
+ - For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
12
+ - For more asciidoc formatting tips, see the excellent reference here https://github.com/elasticsearch/docs#asciidoc-guide
13
+
14
+ ## Need Help?
15
+
16
+ Need help? Try #logstash on freenode IRC or the logstash-users@googlegroups.com mailing list.
17
+
18
+ ## Developing
19
+
20
+ ### 1. Plugin Developement and Testing
21
+
22
+ #### Code
23
+ - To get started, you'll need JRuby with the Bundler gem installed.
24
+
25
+ - Create a new plugin or clone and existing from the GitHub [logstash-plugins](https://github.com/logstash-plugins) organization.
26
+
27
+ - Install dependencies
28
+ ```sh
29
+ bundle install
30
+ ```
31
+
32
+ #### Test
33
+
34
+ ```sh
35
+ bundle exec rspec
36
+ ```
37
+
38
+ The Logstash code required to run the tests/specs is specified in the `Gemfile` by the line similar to:
39
+ ```ruby
40
+ gem "logstash", :github => "elasticsearch/logstash", :branch => "1.5"
41
+ ```
42
+ To test against another version or a local Logstash, edit the `Gemfile` to specify an alternative location, for example:
43
+ ```ruby
44
+ gem "logstash", :github => "elasticsearch/logstash", :ref => "master"
45
+ ```
46
+ ```ruby
47
+ gem "logstash", :path => "/your/local/logstash"
48
+ ```
49
+
50
+ Then update your dependencies and run your tests:
51
+
52
+ ```sh
53
+ bundle install
54
+ bundle exec rspec
55
+ ```
56
+
57
+ ### 2. Running your unpublished Plugin in Logstash
58
+
59
+ #### 2.1 Run in a local Logstash clone
60
+
61
+ - Edit Logstash `tools/Gemfile` and add the local plugin path, for example:
62
+ ```ruby
63
+ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
64
+ ```
65
+ - Update Logstash dependencies
66
+ ```sh
67
+ rake vendor:gems
68
+ ```
69
+ - Run Logstash with your plugin
70
+ ```sh
71
+ bin/logstash -e 'filter {awesome {}}'
72
+ ```
73
+ At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
74
+
75
+ #### 2.2 Run in an installed Logstash
76
+
77
+ - Build your plugin gem
78
+ ```sh
79
+ gem build logstash-filter-awesome.gemspec
80
+ ```
81
+ - Install the plugin from the Logstash home
82
+ ```sh
83
+ bin/plugin install /your/local/plugin/logstash-filter-awesome.gem
84
+ ```
85
+ - Start Logstash and proceed to test the plugin
86
+
87
+ ## Contributing
88
+
89
+ All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
90
+
91
+ Programming is not a required skill. Whatever you've seen about open source and maintainers or community members saying "send patches or die" - you will not see that here.
92
+
93
+ It is more important to me that you are able to contribute.
94
+
95
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elasticsearch/logstash/blob/master/CONTRIBUTING.md) file.
@@ -13,7 +13,7 @@ module LogStash::PluginMixins::AwsConfig
13
13
  end
14
14
 
15
15
  US_EAST_1 = "us-east-1"
16
-
16
+
17
17
  public
18
18
  def setup_aws_config
19
19
  # The AWS Region
@@ -21,25 +21,28 @@ module LogStash::PluginMixins::AwsConfig
21
21
  "eu-west-1", "ap-southeast-1", "ap-southeast-2",
22
22
  "ap-northeast-1", "sa-east-1", "us-gov-west-1"], :default => US_EAST_1
23
23
 
24
- # This plugin uses the AWS SDK and supports several ways to get credentials, which will be tried in this order...
25
- # 1. Static configuration, using `access_key_id` and `secret_access_key` params in logstash plugin config
26
- # 2. External credentials file specified by `aws_credentials_file`
27
- # 3. Environment variables `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`
28
- # 4. Environment variables `AMAZON_ACCESS_KEY_ID` and `AMAZON_SECRET_ACCESS_KEY`
29
- # 5. IAM Instance Profile (available when running inside EC2)
24
+ # This plugin uses the AWS SDK and supports several ways to get credentials, which will be tried in this order...
25
+ # 1. Static configuration, using `access_key_id` and `secret_access_key` params in logstash plugin config
26
+ # 2. External credentials file specified by `aws_credentials_file`
27
+ # 3. Environment variables `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`
28
+ # 4. Environment variables `AMAZON_ACCESS_KEY_ID` and `AMAZON_SECRET_ACCESS_KEY`
29
+ # 5. IAM Instance Profile (available when running inside EC2)
30
30
  config :access_key_id, :validate => :string
31
31
 
32
32
  # The AWS Secret Access Key
33
33
  config :secret_access_key, :validate => :string
34
34
 
35
- # Should we require (true) or disable (false) using SSL for communicating with the AWS API
35
+ # The AWS Session token for temprory credential
36
+ config :session_token, :validate => :string
37
+
38
+ # Should we require (true) or disable (false) using SSL for communicating with the AWS API
36
39
  # The AWS SDK for Ruby defaults to SSL so we preserve that
37
40
  config :use_ssl, :validate => :boolean, :default => true
38
41
 
39
42
  # URI to proxy server if required
40
43
  config :proxy_uri, :validate => :string
41
44
 
42
- # Path to YAML file containing a hash of AWS credentials.
45
+ # Path to YAML file containing a hash of AWS credentials.
43
46
  # This file will only be loaded if `access_key_id` and
44
47
  # `secret_access_key` aren't set. The contents of the
45
48
  # file should look like this:
@@ -56,25 +59,19 @@ module LogStash::PluginMixins::AwsConfig
56
59
  @logger.warn("Likely config error: Only one of access_key_id or secret_access_key was provided but not both.")
57
60
  end
58
61
 
59
- if ((!@access_key_id || !@secret_access_key)) && @aws_credentials_file
60
- access_creds = YAML.load_file(@aws_credentials_file)
61
-
62
- @access_key_id = access_creds[:access_key_id]
63
- @secret_access_key = access_creds[:secret_access_key]
64
- end
65
-
66
- opts = {}
67
-
68
- if (@access_key_id && @secret_access_key)
69
- opts[:access_key_id] = @access_key_id
70
- opts[:secret_access_key] = @secret_access_key
62
+ if @access_key_id && @secret_access_key
63
+ opts = {
64
+ :access_key_id => @access_key_id,
65
+ :secret_access_key => @secret_access_key
66
+ }
67
+ opts[:session_token] = @session_token if @session_token
68
+ elsif @aws_credentials_file
69
+ opts = YAML.load_file(@aws_credentials_file)
71
70
  end
72
71
 
72
+ opts[:proxy_uri] = @proxy_uri if @proxy_uri
73
73
  opts[:use_ssl] = @use_ssl
74
74
 
75
- if (@proxy_uri)
76
- opts[:proxy_uri] = @proxy_uri
77
- end
78
75
 
79
76
  # The AWS SDK for Ruby doesn't know how to make an endpoint hostname from a region
80
77
  # for example us-west-1 -> foosvc.us-west-1.amazonaws.com
@@ -86,7 +83,7 @@ module LogStash::PluginMixins::AwsConfig
86
83
  # for example, CloudWatch, { :cloud_watch_endpoint => "monitoring.#{region}.amazonaws.com" }
87
84
  # For a list, see https://github.com/aws/aws-sdk-ruby/blob/master/lib/aws/core/configuration.rb
88
85
  opts.merge!(self.aws_service_endpoint(@region))
89
-
86
+
90
87
  return opts
91
88
  end # def aws_options_hash
92
89
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-mixin-aws'
3
- s.version = '0.1.3'
3
+ s.version = '0.1.4'
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"
@@ -0,0 +1,3 @@
1
+ :access_key_id: '1234'
2
+ :secret_access_key: secret
3
+ :session_token: session_token
@@ -6,7 +6,6 @@ require 'aws-sdk'
6
6
  class DummyInputAwsConfig < LogStash::Inputs::Base
7
7
  include LogStash::PluginMixins::AwsConfig
8
8
 
9
- milestone 1
10
9
 
11
10
  def aws_service_endpoint(region)
12
11
  { :dummy_input_aws_config_region => "#{region}.awswebservice.local" }
@@ -14,25 +13,62 @@ class DummyInputAwsConfig < LogStash::Inputs::Base
14
13
  end
15
14
 
16
15
  describe LogStash::PluginMixins::AwsConfig do
17
- it 'should support passing credentials as key, value' do
18
- settings = { 'access_key_id' => '1234', 'secret_access_key' => 'secret' }
19
16
 
20
- config = DummyInputAwsConfig.new(settings)
21
- config.aws_options_hash[:access_key_id].should == settings['access_key_id']
22
- config.aws_options_hash[:secret_access_key].should == settings['secret_access_key']
23
- end
17
+ let(:settings) { {} }
18
+
19
+ subject { DummyInputAwsConfig.new(settings).aws_options_hash }
20
+
21
+ describe 'config credential' do
22
+
23
+ context 'in credential file' do
24
+ let(:settings) { { 'aws_credentials_file' => File.join(File.dirname(__FILE__), '..', 'fixtures/aws_credentials_file_sample_test.yml') } }
25
+
26
+ it 'should support reading configuration from a yaml file' do
27
+ subject[:access_key_id].should == '1234'
28
+ subject[:secret_access_key].should == 'secret'
29
+ end
30
+ end
31
+
32
+ context 'inline' do
33
+ context 'temporary credential' do
34
+ let(:settings) { { 'access_key_id' => '1234', 'secret_access_key' => 'secret', 'session_token' => 'session_token' } }
35
+
36
+ it "should support passing as key, value, and session_token" do
37
+ subject[:access_key_id].should == settings['access_key_id']
38
+ subject[:secret_access_key].should == settings['secret_access_key']
39
+ subject[:session_token].should == settings['session_token']
40
+ end
41
+ end
42
+
43
+ context 'normal credential' do
44
+ let(:settings) { { 'access_key_id' => '1234', 'secret_access_key' => 'secret' } }
45
+
46
+ it 'should support passing credentials as key, value' do
47
+ subject[:access_key_id].should == settings['access_key_id']
48
+ subject[:secret_access_key].should == settings['secret_access_key']
49
+ end
50
+ end
51
+ end
24
52
 
25
- it 'should support reading configuration from a yaml file' do
26
- settings = { 'aws_credentials_file' => File.join(File.dirname(__FILE__), '..', 'fixtures/aws_credentials_file_sample_test.yml') }
27
- config = DummyInputAwsConfig.new(settings)
28
- config.aws_options_hash[:access_key_id].should == '1234'
29
- config.aws_options_hash[:secret_access_key].should == 'secret'
30
53
  end
31
54
 
32
- it 'should call the class to generate the endpoint configuration' do
33
- settings = { 'access_key_id' => '1234', 'secret_access_key' => 'secret', 'region' => 'us-west-2' }
55
+ describe 'config region' do
56
+
57
+ context 'region provided' do
58
+ let(:settings) { { 'access_key_id' => '1234', 'secret_access_key' => 'secret', 'region' => 'us-west-2' } }
59
+
60
+ it 'should use provided region to generate the endpoint configuration' do
61
+ subject[:dummy_input_aws_config_region].should == "us-west-2.awswebservice.local"
62
+ end
63
+ end
64
+
65
+ context "region not provided" do
66
+ let(:settings) { { 'access_key_id' => '1234', 'secret_access_key' => 'secret'} }
67
+
68
+ it 'should use default region to generate the endpoint configuration' do
69
+ subject[:dummy_input_aws_config_region].should == "us-east-1.awswebservice.local"
70
+ end
71
+ end
34
72
 
35
- config = DummyInputAwsConfig.new(settings)
36
- config.aws_options_hash[:dummy_input_aws_config_region].should == "us-west-2.awswebservice.local"
37
73
  end
38
74
  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.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elasticsearch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-21 00:00:00.000000000 Z
11
+ date: 2015-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -79,12 +79,15 @@ extensions: []
79
79
  extra_rdoc_files: []
80
80
  files:
81
81
  - .gitignore
82
+ - CONTRIBUTORS
82
83
  - Gemfile
83
84
  - LICENSE
85
+ - README.md
84
86
  - Rakefile
85
87
  - lib/logstash/plugin_mixins/aws_config.rb
86
88
  - logstash-mixin-aws.gemspec
87
89
  - spec/fixtures/aws_credentials_file_sample_test.yml
90
+ - spec/fixtures/aws_temporary_credentials_file_sample_test.yml
88
91
  - spec/plugin_mixin/aws_config_spec.rb
89
92
  homepage: http://www.elasticsearch.org/guide/en/logstash/current/index.html
90
93
  licenses:
@@ -114,4 +117,5 @@ specification_version: 4
114
117
  summary: AWS mixins to provide a unified interface for Amazon Webservice
115
118
  test_files:
116
119
  - spec/fixtures/aws_credentials_file_sample_test.yml
120
+ - spec/fixtures/aws_temporary_credentials_file_sample_test.yml
117
121
  - spec/plugin_mixin/aws_config_spec.rb