title: How to enable s3 server access logging using the boto3 sdk?
body: <p>I am trying to use the boto3 SDK to enable server access logging through python. However, I keep getting the error of: </p>
  
  <blockquote>
    <p>You must give the log-delivery group WRITE and READ_ACP permissions to the target bucket</p>
  </blockquote>
  
  <p>I know I need to add permissions to that group, but I don't know how to do that through the Python SDK.</p>
  
  <p>I've tried following <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/enable-logging-programming.html" rel="nofollow noreferrer">Enabling Logging Programmatically - Amazon Simple Storage Service</a> but I was unable to convert it to Python.</p>
  
  <p>I've additionally tried putting the Grantee and Permissions inside of the put_bucket_logging call, but to no avail.</p>
  
  <p>Listed below is my function to attempt to do this resulting in the aforementioned error:</p>
  
  <pre class="lang-py prettyprint-override"><code>def enableAccessLogging(clientS3, bucketName, storageBucket, 
                          targetPrefix):
  
      #Give the group log-delievery WRITE and READ_ACP permisions to the
      #target bucket
      acl = get_bucket_acl(clientS3, storageBucket)
  
      new_grant = {
          'Grantee': {
              'ID' : 'LogDelivery',
              'Type' : 'Group'
          },
          'Permission': 'FULL_CONTROL',
      }
  
      modified_acl = copy.deepcopy(acl)
      modified_acl['Grants'].append(new_grant)
  
      setBucketAcl(clientS3, bucketName, modified_acl)
  
      response = clientS3.put_bucket_logging(
          Bucket=bucketName,
          BucketLoggingStatus={
              'LoggingEnabled': {
                  'TargetBucket': storageBucket,
                  'TargetPrefix': targetPrefix
              }
          }
  
      )
  </code></pre>