title: How to find un encrypted file in Amazon AWS S3 bucket?
body: <p>What i have: several old s3 buckets with 1M objects in each, with server-side encryption turned on. </p>
  
  <p>Problem: old files are unencrypted. And i can't say when encryption was turned on. 
  So, i need to find all unencrypted files. </p>
  
  <p>I've tried solution with <code>awscli</code>, but it is pretty slow - 1 request in 2 seconds. </p>
  
  <p>my solution: </p>
  
  <pre><code>s3_buckets="uploads tmp logs whatever "
  for s3_bucket in $s3_buckets;
  do
      aws s3 ls s3://$s3_bucket --recursive \
      | awk '{print $NF}' \
      | ( while read object ; 
          do 
              object_status=$(aws s3api head-object --bucket $s3_bucket --key $object --query ServerSideEncryption --output text 2&gt;&amp;1) 
              if [ "$object_status" != "AES256" ]; then
                  echo "Unencrypted object $object in s3://$s3_bucket"; &gt;&gt; /tmp/body.tmp
                  objects_unencrypted=$((objects_unencrypted + 1))
              fi
              objects_count=$((objects_count + 1))
          done
      echo "Bucket $s3_bucket has $objects_count, where unencrypted $objects_unencrypted." &gt;&gt; /tmp/body.tmp )
  done
  </code></pre>
  
  <p>so, maybe there are any better solutions? </p>
  
  <p>is it possible to create <code>Cloudwatch</code> metric to show unencrypted fiels? or any others?</p>