Remediation
Perform the following to enable S3 bucket logging:
From Consoleβ
- Sign in to the AWS Management Console and open the S3 console at https://console.aws.amazon.com/s3.
- Under
All Bucketsclick on the target S3 bucket. - Click on
Propertiesin the top right of the console. - Under
Bucket: {{s3_bucket_for_cloudtrail}}click onLogging. - Configure bucket logging:
- Click on the
Enabledcheckbox. - Select Target Bucket from list.
- Enter a Target Prefix.
- Click on the
- Click
Save.
From Command Lineβ
-
Get the name of the S3 bucket that CloudTrail is logging to:
aws cloudtrail describe-trails --region {{region-name}} --query trailList[*].S3BucketName -
Copy and add target bucket name at
{{Logging_BucketName}}, Prefix for logfile at{{LogFilePrefix}}and optionally add an email address in the following template and save it as{{FileName.Json}}:{
"LoggingEnabled": {
"TargetBucket": "{{Logging_BucketName}}",
"TargetPrefix": "{{LogFilePrefix}}",
"TargetGrants": [
{
"Grantee": {
"Type": "AmazonCustomerByEmail",
"EmailAddress": "{{EmailID}}"
},
"Permission": "FULL_CONTROL"
}
]
}
} -
Run the
put-bucket-loggingcommand with bucket name and{{FileName.Json}}as input:aws s3api put-bucket-logging --bucket {{BucketName}} --bucket-logging-status file://{{FileName.Json}}