title: S3 Default server side encryption on large number of buckets using Python boto3
body: <p>Hi Iam trying to turn on default s3 encryption on all my buckets in an account using python boto3 script see below.</p>
  
  <pre><code>import boto3
  from botocore.exceptions import ClientError
  
  
  s3 = boto3.client('s3')
  
  response = s3.list_buckets()
  
  for bucket in response['Buckets']:
      enc = s3.get_bucket_encryption(Bucket=bucket['Name'])
      s3.put_bucket_encryption(
          Bucket=bucket['Name'],
          ServerSideEncryptionConfiguration={
            'Rules': [
              {
                  'ApplyServerSideEncryptionByDefault': {
                      'SSEAlgorithm': 'AES256'
                  }
              },
            ]
          }
      )
  </code></pre>
  
  <p>But i am struggling with my code which is not working</p>
  
  <p>gives error</p>
  
  <pre><code>  File "apply.py", line 10, in &lt;module&gt;
      enc = s3.get_bucket_encryption(Bucket=bucket['Name'])
    File "/Users/hhaqqani/Library/Python/2.7/lib/python/site-packages/botocore/client.py", line 272, in _api_call
      return self._make_api_call(operation_name, kwargs)
    File "/Users/hhaqqani/Library/Python/2.7/lib/python/site-packages/botocore/client.py", line 576, in _make_api_call
      raise error_class(parsed_response, operation_name)
  botocore.exceptions.ClientError: An error occurred (ServerSideEncryptionConfigurationNotFoundError) when calling the GetBucketEncryption operation: The server side encryption configuration was not found
  
  </code></pre>