Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add aws session token as config parameter #166

Merged
merged 3 commits into from
Sep 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,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 @@ -126,6 +126,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 @@ -111,6 +112,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