class Multiwoven::Integrations::Source::AmazonS3::Client

def get_auth_data(connection_config)

def get_auth_data(connection_config)
  session = @session_name.gsub(/\s+/, "-")
  @session_name = ""
  if connection_config[:auth_type] == "user"
    Aws::Credentials.new(connection_config[:access_id], connection_config[:secret_access])
  elsif connection_config[:auth_type] == "role"
    sts_client = Aws::STS::Client.new(region: connection_config[:region])
    resp = sts_client.assume_role({
                                    role_arn: connection_config[:arn],
                                    role_session_name: session,
                                    external_id: connection_config[:external_id]
                                  })
    Aws::Credentials.new(
      resp.credentials.access_key_id,
      resp.credentials.secret_access_key,
      resp.credentials.session_token
    )
  end
end