Skip to main content

Triage and Remediation

Remediation

Using Console

To remediate the CloudTrail Must Log Data Events misconfiguration for AWS using the AWS console, follow these steps:
  1. Log in to the AWS Management Console.
  2. Navigate to the CloudTrail service.
  3. Select the trail that is not logging data events.
  4. Click on the “Edit” button.
  5. Scroll down to the “Data events” section.
  6. Click on the “Add data event” button.
  7. Select the AWS service(s) that you want to log data events for.
  8. Select the specific data events that you want to log.
  9. Click on the “Save” button to save the changes.
After completing these steps, CloudTrail will be configured to log data events for the selected AWS service(s) and specific data events.

To remediate the CloudTrail must log data events misconfiguration for AWS using AWS CLI, you can follow the below steps:
  1. Open the AWS CLI on your local machine or EC2 instance.
  2. Run the following command to check if CloudTrail is enabled:
  3. If CloudTrail is not enabled, run the following command to create a trail:
    Replace <trail-name> with a name for your trail and <bucket-name> with the name of the S3 bucket where you want to store the log files.
  4. Run the following command to update the trail to log data events:
    This command updates the trail to include global service events and enables multi-region logging.
  5. Run the following command to start logging data events:
    This command starts logging data events to the specified trail.
  6. Verify that data events are being logged by checking the S3 bucket for log files.
By following these steps, you can remediate the CloudTrail must log data events misconfiguration for AWS using AWS CLI.
To remediate the misconfiguration “CloudTrail Must Log Data Events” in AWS using Python, you can follow the below steps:
  1. Import the necessary libraries:
  1. Create a boto3 client for CloudTrail:
  1. Get the current CloudTrail configuration:
  1. Check if data events logging is enabled:
  1. Update the CloudTrail configuration to enable data events logging:
  1. Verify that data events logging is enabled:
  1. Optionally, you can also create a CloudWatch alarm to monitor the CloudTrail logs for specific events:
By following these steps, you can remediate the “CloudTrail Must Log Data Events” misconfiguration in AWS using Python.
This change updates the existing aws_cloudtrail trail in-place (no forced replacement), but it will replace any prior event_selector configuration on this resource, so merge carefully before applying. After updating, terraform plan should show an in-place update for aws_cloudtrail.TRAIL_RESOURCE_NAME with the new event_selector (ReadWriteType All, include_management_events = true, and data_resource for AWS::S3::Object with arn:aws:s3:::).