Use the put_bucket_logging() method to configure bucket logging.
The following example enables logging to a destination bucket named c-2024-10-10-112417-595579, where the log object keys will have a prefix of -V/E-Test-. Users with emails myuser@example.com and onemoreuser@example.com will have full control permissions to the log objects.
s3.client.put_bucket_logging(
Bucket=bucket_name,
BucketLoggingStatus={
'LoggingEnabled': {
'TargetBucket': 'c-2024-10-10-112417-595579', 'TargetPrefix': '-V/E-Test-', 'TargetGrants':
[{'Grantee': {'Type':'AmazonCustomerByEmail', 'EmailAddress': 'myuser@example.com'}, 'Permission': 'FULL_CONTROL'},
{'Grantee': {'Type': 'AmazonCustomerByEmail', 'EmailAddress':'onemoreuser@example.com'}, 'Permission': 'FULL_CONTROL'}]
}
}
)