AWSSupportRemediator-EnableRedshiftClusterAuditLogging
Description
Enables audit logging to Amazon CloudWatch Logs on an Amazon Redshift cluster.
The runbook calls the Amazon Redshift EnableLogging API with LogDestinationType set to cloudwatch and the requested log types.
This automation remediates findings identified by Amazon Well-Architected Agent. It remediates findings from Amazon Security Hub CSPM control Amazon Redshift clusters should have audit logging enabled.
If the Amazon Redshift cluster does not exist or audit logging is already enabled, the automation completes successfully without making changes.
Amazon Redshift supports Amazon Simple Storage Service (Amazon S3) and CloudWatch Logs as audit logging destinations. If the cluster already publishes audit logs to Amazon S3, this automation does not switch the destination to CloudWatch Logs because doing so would disrupt downstream consumers of the existing logs.
Enabling audit logging causes Amazon Redshift to publish the requested log types to CloudWatch Logs. By default, this automation publishes connection logs and user logs. Amazon Redshift delivers logs in the same Amazon Region as the cluster. CloudWatch Logs storage and ingestion charges apply. For more information about pricing, see Amazon CloudWatch Logs pricing/aws/redshift/cluster/<cluster-identifier>/<log-type> on first log delivery. To disable audit logging after enabling it, call the Amazon Redshift DisableLogging API on the cluster.
The user activity log stream contains full SQL statement text, which can include literals, personally identifiable information (PII), or other sensitive content. By default, this automation does not export the user activity log. To include user activity logging, pass LogExports as [connectionlog, userlog, useractivitylog]. Amazon Redshift publishes user activity content only when the cluster's parameter group has enable_user_activity_logging set to true. By default, this parameter is false, and the cluster does not capture SQL text.
Amazon Redshift creates the CloudWatch log groups with the account's default CloudWatch Logs settings. This automation does not associate an Amazon Key Management Service (Amazon KMS) key or set a retention period on the log groups. To customize encryption, see Encrypt log data in CloudWatch Logs using Amazon Key Management Service. To set a finite retention period, see Change log data retention in CloudWatch Logs.
Amazon Redshift uses its service principal to deliver audit logs to CloudWatch Logs asynchronously after this automation enables logging. If your CloudWatch Logs resource policy or Amazon KMS key policy denies the Amazon Redshift service principal, log delivery does not succeed. Before running this automation, verify that any such policies allow the Amazon Redshift service principal for the cluster's Amazon Region. To confirm delivery after running this automation, call the Amazon Redshift DescribeLoggingStatus API. Inspect LastSuccessfulDeliveryTime and LastFailureMessage to verify the result.
You are responsible for reviewing automation actions before they run.
This automation might cause stack drift if the resource is part of an Amazon CloudFormation stack. The next stack update or rollback reverts the audit logging configuration to the value defined in the stack template.
Access to
AWSSupportRemediator-*runbooks requires an active Business Support+, Enterprise Support, or Unified Operations Support plan. For more information, see Compare Amazon Web Services Support Planson the Amazon website.
Document type
Automation
Owner
Amazon
Platforms
Linux, macOS, Windows
Parameters
-
AutomationAssumeRole
Type: String
Description: (Optional) The Amazon Resource Name (ARN) of the Amazon Identity and Access Management (IAM) role that allows Systems Manager Automation to perform the actions on your behalf. If no role is specified, Systems Manager Automation uses the permissions of the user that starts this runbook.
-
ClusterIdentifier
Type: String
Description: (Required) The unique identifier of the Amazon Redshift cluster on which to enable audit logging.
-
LogExports
Type: StringList
Description: (Optional) The collection of exported log types. Possible values are
connectionlog,userlog, anduseractivitylog. Default: [connectionlog, userlog]. The default excludesuseractivitylogbecause that log stream can contain full SQL statement text. Passuseractivitylogonly when you need to capture SQL text in CloudWatch Logs and have appropriate retention and access controls configured.Default: ['connectionlog', 'userlog']
Required IAM permissions
The AutomationAssumeRole parameter requires the following actions to
use the runbook successfully.
-
redshift:DescribeLoggingStatus -
redshift:EnableLogging
Document Steps
-
validateInputs - Checks whether the specified Amazon Redshift cluster exists and whether audit logging is already enabled. Returns no change required when the cluster does not exist or already has logging enabled.
-
branchOnChangeRequired - Branches on whether a change is required. Continues to
enableLoggingwhenvalidateInputs.ChangeRequiredistrue. Otherwise, ends the runbook successfully. -
enableLogging - Calls the Amazon Redshift
EnableLoggingAPI for the specified cluster withLogDestinationTypeset tocloudwatchand the requested log export types.
Outputs
-
validateInputs.ChangeRequired: Whether a change is required.
falsewhen the cluster does not exist or already has audit logging enabled. -
validateInputs.ValidationMessage: A message describing why no change is required, or
N/Awhen a change is required. -
validateInputs.ExistingLoggingConfiguration: The initial audit logging configuration from
DescribeLoggingStatus. Useful for post-execution review when the cluster already has logging enabled. -
enableLogging.Response: The response from the Amazon Redshift
EnableLoggingAPI after the automation applies a change.