lib/aws_recon/collectors/s3.rb in aws_recon-0.2.2 vs lib/aws_recon/collectors/s3.rb in aws_recon-0.2.3
- old
+ new
@@ -13,25 +13,27 @@
#
@client.list_buckets.each_with_index do |response, page|
log(response.context.operation_name, page)
Parallel.map(response.buckets.each, in_threads: @options.threads) do |bucket|
- # use shared client instance
- client = @client
@thread = Parallel.worker_number
log(response.context.operation_name, bucket.name)
struct = OpenStruct.new(bucket)
struct.type = 'bucket'
struct.arn = "arn:aws:s3:::#{bucket.name}"
# check bucket region constraint
location = @client.get_bucket_location({ bucket: bucket.name }).location_constraint
- # reset client if needed
- unless location.empty?
- client = Aws::S3::Client.new({ region: location })
- end
+ # if you use a region other than the us-east-1 endpoint
+ # to create a bucket, you must set the location_constraint
+ # bucket parameter to the same region. (https://docs.aws.amazon.com/general/latest/gr/s3.html)
+ client = if location.empty?
+ @client
+ else
+ Aws::S3::Client.new({ region: location })
+ end
operations = [
{ func: 'get_bucket_acl', key: 'acl', field: nil },
{ func: 'get_bucket_encryption', key: 'encryption', field: 'server_side_encryption_configuration' },
{ func: 'get_bucket_policy', key: 'policy', field: 'policy' },