Skip to content

feat(redshift): audit logging to cloudwatch#36410

Open
badmintoncryer wants to merge 20 commits intoaws:mainfrom
badmintoncryer:redshift
Open

feat(redshift): audit logging to cloudwatch#36410
badmintoncryer wants to merge 20 commits intoaws:mainfrom
badmintoncryer:redshift

Conversation

@badmintoncryer
Copy link
Copy Markdown
Contributor

Issue # (if applicable)

Closes #25755.

Reason for this change

Redshift supports for configuring audit logging sent to Cloudwatch or S3.
https://docs.aws.amazon.com/redshift/latest/mgmt/db-auditing.html

Description of changes

  • Define ClusterLogging abstract class
  • Add S3ClusterLogging and CloudwatchClusterLogging

The existing loggingProperty argument also exists, but I felt the design was insufficient for properly switching between CloudWatch and S3 configurations.
In this PR, I am deprecating the existing argument and adding a new logging argument with an entirely different structure.
Since this is an alpha module, breaking changes should be acceptable. If the reviewer deems it necessary, it is also possible to remove the existing argument entirely.

Describe any new or updated permissions being added

Add S3 bucket resource policy for logging bucket.

const statement = new iam.PolicyStatement({
          actions: [
            's3:GetBucketAcl',
            's3:PutObject',
          ],
          resources: [
            props.logging._bucket.arnForObjects('*'),
            props.logging._bucket.bucketArn,
          ],
          principals: [
            new iam.ServicePrincipal('redshift.amazonaws.com'),
          ],
        });
        const result = props.logging._bucket.addToResourcePolicy(statement);

https://docs.aws.amazon.com/redshift/latest/mgmt/db-auditing.html#db-auditing-bucket-permissions

The resource policy being applied is completely identical to the logic used for the existing loggingProperty configuration.

Description of how you validated changes

Add both unit and integ tests.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

…gExports and add integration tests for CloudWatch and S3 logging
…lusters

- Created a new integration test file for Redshift clusters with CloudWatch and S3 logging.
- Implemented a test stack that provisions a VPC, a CloudWatch logging cluster, and an S3 logging cluster.
- Configured logging for both clusters and set up a logging bucket with auto-delete enabled.
- Added parameter group configuration to enable user activity logging for the CloudWatch logging cluster.
@github-actions github-actions bot added bug This issue is a bug. effort/medium Medium work item – several days of effort p2 labels Dec 17, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team December 17, 2025 09:10
@github-actions github-actions bot added the distinguished-contributor [Pilot] contributed 50+ PRs to the CDK label Dec 17, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 17, 2025

⚠️ Experimental Feature: This security report is currently in experimental phase. Results may include false positives and the rules are being actively refined.
This security report is NOT a review blocker. Please try merge from main to avoid findings unrelated to the PR.


TestsPassed ✅SkippedFailed
Security Guardian Results48 ran48 passed
TestResult
No test annotations available

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 17, 2025

⚠️ Experimental Feature: This security report is currently in experimental phase. Results may include false positives and the rules are being actively refined.
This security report is NOT a review blocker. Please try merge from main to avoid findings unrelated to the PR.


TestsPassed ✅SkippedFailed
Security Guardian Results with resolved templates48 ran48 passed
TestResult
No test annotations available

*
* @default - All log types
*/
readonly logExports?: LogExport[];
Copy link
Copy Markdown
Contributor Author

@badmintoncryer badmintoncryer Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Configuring S3 bucket audit logging and logExports settings simultaneously causes a deployment error. Therefore, I've added logExports prop to only CloudWatchLoggingOptions.

This AWS::Redshift::Cluster resource is in a CREATE_FAILED state.
Resource handler returned message: "Log exports can only be used with CloudWatch export (Service: Redshift, Status Code: 400, Request ID: 58cb6b05-1577-4c42-ac6f-34755d2fbf8e) (SDK Attempt Count: 1)" (RequestToken: 103dc9fa-608c-310c-5376-18e3d12c7bd0, HandlerErrorCode: GeneralServiceException)

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Dec 17, 2025
@badmintoncryer badmintoncryer changed the title feat(redshift): audit logging feat(redshift): audit logging to cloudwatch Dec 17, 2025
@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Dec 17, 2025
@aws-cdk-automation aws-cdk-automation added pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. pr/needs-further-review PR requires additional review from our team specialists due to the scope or complexity of changes. labels Dec 17, 2025
@aws-cdk-automation aws-cdk-automation removed the pr/needs-further-review PR requires additional review from our team specialists due to the scope or complexity of changes. label Dec 17, 2025
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug This issue is a bug. distinguished-contributor [Pilot] contributed 50+ PRs to the CDK effort/medium Medium work item – several days of effort p2 pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(redshift): How to enable audit logging from redshift module

3 participants