lib/fluent/plugin/in_cloudwatch_logs.rb in fluent-plugin-cloudwatch-logs-0.13.4 vs lib/fluent/plugin/in_cloudwatch_logs.rb in fluent-plugin-cloudwatch-logs-0.14.0
- old
+ new
@@ -15,10 +15,13 @@
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 :aws_sts_external_id, :string, default: nil
+ config_param :aws_sts_policy, :string, default: nil
+ config_param :aws_sts_duration_seconds, :time, default: nil
config_param :aws_sts_endpoint_url, :string, default: nil
config_param :region, :string, default: nil
config_param :endpoint, :string, default: nil
config_param :tag, :string
config_param :log_group_name, :string
@@ -86,11 +89,14 @@
if @aws_use_sts
Aws.config[:region] = options[:region]
credentials_options = {
role_arn: @aws_sts_role_arn,
- role_session_name: @aws_sts_session_name
+ role_session_name: @aws_sts_session_name,
+ external_id: @aws_sts_external_id,
+ policy: @aws_sts_policy,
+ duration_seconds: @aws_sts_duration_seconds
}
credentials_options[:sts_endpoint_url] = @aws_sts_endpoint_url if @aws_sts_endpoint_url
if @region and @aws_sts_endpoint_url
credentials_options[:client] = Aws::STS::Client.new(:region => @region, endpoint: @aws_sts_endpoint_url)
elsif @region
@@ -270,10 +276,11 @@
log_next_token = next_token(log_stream_name, log_group_name)
else
log_next_token = next_token(log_stream_name)
end
request[:next_token] = log_next_token if !log_next_token.nil? && !log_next_token.empty?
+ request[:start_from_head] = true if read_from_head?(log_next_token)
response = @logs.get_log_events(request)
if valid_next_token(log_next_token, response.next_forward_token)
if @use_log_group_name_prefix
store_next_token(response.next_forward_token, log_stream_name, log_group_name)
else
@@ -281,9 +288,13 @@
end
end
response.events
end
+ end
+
+ def read_from_head?(next_token)
+ (!next_token.nil? && !next_token.empty?) || @start_time || @end_time
end
def describe_log_streams(log_stream_name_prefix, log_streams = nil, next_token = nil, log_group_name=nil)
throttling_handler('describe_log_streams') do
request = {