Skip to content

Instantly share code, notes, and snippets.

@mmb
Created November 2, 2017 04:39
Show Gist options
  • Save mmb/45695ca3b0f4038895569e09e1e9bddc to your computer and use it in GitHub Desktop.
Save mmb/45695ca3b0f4038895569e09e1e9bddc to your computer and use it in GitHub Desktop.
List objects in an S3 bucket with no server-side encryption
require 'aws-sdk-s3'
client = Aws::S3::Client.new(region: 'us-west-2')
bucket = 'bucket1'
resp = client.list_objects(bucket: bucket)
resp.contents.each do |object|
metadata = client.head_object(bucket: bucket, key: object.key)
puts object.key unless metadata.server_side_encryption
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment