lib/fluent/plugin/in_cloudwatch_logs.rb in fluent-plugin-cloudwatch-logs-0.3.7.pre vs lib/fluent/plugin/in_cloudwatch_logs.rb in fluent-plugin-cloudwatch-logs-0.3.8

- old
+ new

@@ -11,10 +11,13 @@ define_method("router") { Engine } end config_param :aws_key_id, :string, :default => nil, :secret => true config_param :aws_sec_key, :string, :default => nil, :secret => true + config_param :aws_use_sts, :bool, default: false + config_param :aws_sts_role_arn, :string, default: nil + config_param :aws_sts_session_name, :string, default: 'fluentd' config_param :region, :string, :default => nil config_param :tag, :string config_param :log_group_name, :string config_param :log_stream_name, :string config_param :use_log_stream_name_prefix, :bool, default: false @@ -37,12 +40,22 @@ configure_parser(conf) end def start options = {} - options[:credentials] = Aws::Credentials.new(@aws_key_id, @aws_sec_key) if @aws_key_id && @aws_sec_key options[:region] = @region if @region options[:http_proxy] = @http_proxy if @http_proxy + + if @aws_use_sts + Aws.config[:region] = options[:region] + options[:credentials] = Aws::AssumeRoleCredentials.new( + role_arn: @aws_sts_role_arn, + role_session_name: @aws_sts_session_name + ) + else + options[:credentials] = Aws::Credentials.new(@aws_key_id, @aws_sec_key) if @aws_key_id && @aws_sec_key + end + @logs = Aws::CloudWatchLogs::Client.new(options) @finished = false @thread = Thread.new(&method(:run)) end