lib/fluent/plugin/out_s3.rb in fluent-plugin-s3-1.3.2 vs lib/fluent/plugin/out_s3.rb in fluent-plugin-s3-1.3.3
- old
+ new
@@ -37,10 +37,12 @@
config_param :policy, :string, default: nil
desc "The duration, in seconds, of the role session (900-3600)"
config_param :duration_seconds, :integer, default: nil
desc "A unique identifier that is used by third parties when assuming roles in their customers' accounts."
config_param :external_id, :string, default: nil, secret: true
+ desc "The region of the STS endpoint to use."
+ config_param :sts_region, :string, default: nil
end
# See the following link for additional params that could be added:
# https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/STS/Client.html#assume_role_with_web_identity-instance_method
config_section :web_identity_credentials, multi: false do
desc "The Amazon Resource Name (ARN) of the role to assume"
@@ -51,10 +53,12 @@
config_param :web_identity_token_file, :string #required
desc "An IAM policy in JSON format"
config_param :policy, :string, default: nil
desc "The duration, in seconds, of the role session (900-43200)"
config_param :duration_seconds, :integer, default: nil
+ desc "The region of the STS endpoint to use."
+ config_param :sts_region, :string, default: nil
end
config_section :instance_profile_credentials, multi: false do
desc "Number of times to retry when retrieving credentials"
config_param :retries, :integer, default: nil
desc "IP address (default:169.254.169.254)"
@@ -169,11 +173,11 @@
super
Aws.use_bundled_cert! if @use_bundled_cert
- if @s3_endpoint && @s3_endpoint.end_with?('amazonaws.com')
+ if @s3_endpoint && (@s3_endpoint.end_with?('amazonaws.com') && !['fips', 'gov'].any? { |e| @s3_endpoint.include?(e) })
raise Fluent::ConfigError, "s3_endpoint parameter is not supported for S3, use s3_region instead. This parameter is for S3 compatible services"
end
begin
buffer_type = @buffer_config[:@type]
@@ -483,21 +487,25 @@
credentials_options[:role_arn] = c.role_arn
credentials_options[:role_session_name] = c.role_session_name
credentials_options[:policy] = c.policy if c.policy
credentials_options[:duration_seconds] = c.duration_seconds if c.duration_seconds
credentials_options[:external_id] = c.external_id if c.external_id
- if @s3_region
+ if c.sts_region
+ credentials_options[:client] = Aws::STS::Client.new(region: c.sts_region)
+ elsif @s3_region
credentials_options[:client] = Aws::STS::Client.new(region: @s3_region)
end
options[:credentials] = Aws::AssumeRoleCredentials.new(credentials_options)
when @web_identity_credentials
c = @web_identity_credentials
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 @s3_region
+ if c.sts_region
+ credentials_options[:client] = Aws::STS::Client.new(:region => c.sts_region)
+ elsif @s3_region
credentials_options[:client] = Aws::STS::Client.new(:region => @s3_region)
end
options[:credentials] = Aws::AssumeRoleWebIdentityCredentials.new(credentials_options)
when @instance_profile_credentials
c = @instance_profile_credentials