Skip to content

Commit

Permalink
Merge pull request #166 from janerikcarlsen/add-session-token
Browse files Browse the repository at this point in the history
Add aws session token as config parameter
  • Loading branch information
simukappu authored Sep 28, 2019
2 parents 524f16c + 9f806a9 commit 6fff686
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Note: Each value should be adjusted to your system by yourself.
## Configuration: Credentials
To put records into Amazon Kinesis Data Streams or Firehose, you need to provide AWS security credentials somehow. Without specifying credentials in config file, this plugin automatically fetch credential just following AWS SDK for Ruby does (environment variable, shared profile, and instance profile).

This plugin uses the same configuration in [fluent-plugin-s3][fluent-plugin-s3].
This plugin uses the same configuration in [fluent-plugin-s3][fluent-plugin-s3], but also supports aws session tokens for temporary credentials.

**aws_key_id**

Expand All @@ -128,6 +128,10 @@ AWS access key id. This parameter is required when your agent is not running on

AWS secret key. This parameter is required when your agent is not running on EC2 instance with an IAM Role.

**aws_ses_token**

AWS session token. This parameter is optional, but can be provided if using MFA or temporary credentials when your agent is not running on EC2 instance with an IAM Role.

**aws_iam_retries**

The number of attempts to make (with exponential backoff) when loading instance profile credentials from the EC2 metadata service using an IAM role. Defaults to 5 retries.
Expand Down
5 changes: 5 additions & 0 deletions lib/fluent/plugin/kinesis_helper/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module ClientParams

config_param :aws_key_id, :string, default: nil, secret: true
config_param :aws_sec_key, :string, default: nil, secret: true
config_param :aws_ses_token, :string, default: nil, secret: true
config_section :assume_role_credentials, multi: false do
desc "The Amazon Resource Name (ARN) of the role to assume"
config_param :role_arn, :string, secret: true
Expand Down Expand Up @@ -115,6 +116,10 @@ def setup_credentials
options = {}
credentials_options = {}
case
when @aws_key_id && @aws_sec_key && @aws_ses_token
options[:access_key_id] = @aws_key_id
options[:secret_access_key] = @aws_sec_key
options[:session_token] = @aws_ses_token
when @aws_key_id && @aws_sec_key
options[:access_key_id] = @aws_key_id
options[:secret_access_key] = @aws_sec_key
Expand Down

0 comments on commit 6fff686

Please sign in to comment.