85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
# File 'lib/fluent/plugin/in_cloudwatch_logs.rb', line 85
def start
super
options = {}
options[:region] = @region if @region
options[:endpoint] = @endpoint if @endpoint
options[:ssl_verify_peer] = @ssl_verify_peer
options[:http_proxy] = @http_proxy if @http_proxy
if @aws_use_sts
Aws.config[:region] = options[:region]
credentials_options = {
role_arn: @aws_sts_role_arn,
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
credentials_options[:client] = Aws::STS::Client.new(:region => @region)
end
options[:credentials] = Aws::AssumeRoleCredentials.new(credentials_options)
elsif @web_identity_credentials
c = @web_identity_credentials
credentials_options = {}
credentials_options[:role_arn] = c.role_arn
credentials_options[:role_session_name] = c.role_session_name
credentials_options[:web_identity_token_file] = c.web_identity_token_file
credentials_options[:policy] = c.policy if c.policy
credentials_options[:duration_seconds] = c.duration_seconds if c.duration_seconds
if @region
credentials_options[:client] = Aws::STS::Client.new(:region => @region)
end
options[:credentials] = Aws::AssumeRoleWebIdentityCredentials.new(credentials_options)
elsif @aws_ecs_authentication
aws_container_credentials_relative_uri = ENV["AWS_CONTAINER_CREDENTIALS_RELATIVE_URI"]
options[:credentials] = Aws::ECSCredentials.new({credential_path: aws_container_credentials_relative_uri}).credentials
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_create(:in_cloudwatch_logs_runner, &method(:run))
@json_handler = case @json_handler
when :yajl
Yajl
when :json
JSON
end
end
|