Pipeline: 3.4 Ensure S3 bucket access logging is enabled on the CloudTrail S3 bucket
Description
S3 Bucket Access Logging generates a log that contains access records for each request made to your S3 bucket. An access log record contains details about the request, such as the request type, the resources specified in the request worked, and the time and date the request was processed. It is recommended that bucket access logging be enabled on the CloudTrail S3 bucket.
By enabling S3 bucket logging on target S3 buckets, it is possible to capture all events which may affect objects within any target buckets. Configuring logs to be placed in a separate bucket allows access to log information which can be useful in security and incident response workflows.
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 Buckets
click on the target S3 bucket - Click on
Properties
in the top right of the console - Under
Bucket
:<s3_bucket_for_cloudtrail>
click on Logging - Configure bucket logging
- Click on the
Enabled
checkbox - Select Target Bucket from list
- Enter a Target Prefix
- 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-logging
command with bucket name and<FileName.Json>
as input: for more information refer to put-bucket-logging:
aws s3api put-bucket-logging --bucket <BucketName> --bucket-logging-status file://<FileName.Json>
Run the pipeline
To run this pipeline from your terminal:
flowpipe pipeline run aws_cis.pipeline.cis_v300_3_4
Use this pipeline
To call this pipeline from your pipeline, use a step:
step "pipeline" "step_name" { pipeline = aws_cis.pipeline.cis_v300_3_4 }
Params
Name | Type | Required | Description | Default |
---|---|---|---|---|
database | connection.steampipe | Yes | Database connection string. | connection.steampipe.default |
notifier | notifier | Yes | The name of the notifier to use for sending notification messages. | notifier.default |
notification_level | string | Yes | The verbosity level of notification messages to send. Valid options are 'verbose', 'info', 'error'. | info |
approvers | list(notifier) | Yes | List of notifiers to be used for obtaining action/approval decisions. | notifier.default |
Outputs
This pipeline has no outputs.