AWS S3 Access Logs
In this guide, you will configure Guardrails to enforce S3 access logging on every bucket within an AWS account. You'll set the access logging destination so logs are shipped to another bucket within the same account, and add a key prefix so log files are stored in a folder called Access-Logs/.
[!TIP] This configuration can also be deployed using Terraform. See the Guardrails Samples Repo for policy pack examples.
[!IMPORTANT] This guide is for account-owned S3 buckets. Guardrails deploys its own logging buckets to AWS accounts upon import if the policy
AWS > Turbot > Logging > Bucketis set toEnforce: Configured. To enable access logging on Guardrails logging buckets, use the policyAWS > Turbot > Logging > Bucket > Access Logging(set toEnabled) along withAWS > Turbot > Logging > Bucket > Access Logging > BucketandAWS > Turbot > Logging > Bucket > Access Logging > Bucket > Key Prefix, not the policies described in this guide.
Prerequisites
- Access to the Turbot Guardrails console with
Turbot/Adminpermissions or higher. - The
aws-s3mod installed. - An existing S3 bucket in the target account to receive access logs.
Step 1: Configure the Key Prefix
Click New Policy Setting in the top right of the Policies page to open the Create Policy Setting form.
For the Policy Type, search for access logging key prefix and select Key Prefix (AWS > S3 > Bucket > Access Logging > Key Prefix). For the Resource, select the AWS account where the setting will live. The setting affects all S3 buckets at this level and below in the policy hierarchy.
Because this policy is a free-text value, the Setting shows a text field. Enter the prefix for access logs. For this example, enter Access-Logs/ to store log files in a folder called Access-Logs.
Note the trailing slash. Without it, AWS appends the prefix text directly to the beginning of the log file name. For example, if the prefix is Access-Logs (no slash) and the log file is named aws-access-logs-123, the result is Access-Logsaws-access-logs-123. You can also use multiple slashes to create nested folders, such as Access-Logs/foo/bar/.
Click Create.

Step 2: Configure the Destination Bucket
Click New Policy Setting again. For the Policy Type, search for access logging bucket and select Bucket (AWS > S3 > Bucket > Access Logging > Bucket). Select the same Resource scope.
In the Setting field, enter the name of the bucket that should receive the access logs (for example goliath-federal-access-logs). The destination bucket must already exist in the same account and region.
Click Create.

Step 3: Enforce Access Logging
Click New Policy Setting. For the Policy Type, search for s3 access logging and select Access Logging (AWS > S3 > Bucket). Select the same Resource scope.
This policy is an enum, so the Setting shows the available values as radio buttons:
| Value | Behavior |
|---|---|
Skip | Access logging is not evaluated for S3 buckets. |
Check: Enabled | Checks whether access logging is enabled and raises an alarm if not, but makes no changes. |
Check: Enabled to Access Logging > Bucket | Additionally checks that logs are being sent to the destination bucket configured in Step 2. |
Enforce: Disabled | Disables access logging on buckets that have it enabled. |
Enforce: Enabled to Access Logging > Bucket | Enables access logging on non-compliant buckets and configures the destination bucket and key prefix. |
Select Enforce: Enabled to Access Logging > Bucket, then click Create.

Step 4: Verify the Configuration
Verify that the policy is taking effect by navigating to any S3 bucket that should now have access logging configured and checking its metadata. Alternatively, generate access logs by performing an action on an object in a bucket (such as viewing an object), then check the destination bucket to confirm that log files are being stored in the Access-Logs/ folder.
Navigate to Controls in the left sidebar and filter for AWS > S3 > Bucket > Access Logging to see the control states across all buckets in scope.
Next Steps
- Write YAML Policies: Learn more about YAML policy value syntax.
- Policy Settings: Understand the policy hierarchy and how settings inherit.
- AWS AMI Management: Another policy configuration example.