turbot/steampipe-mod-aws-compliance

Control: 4 OpenSearch domain error logging to CloudWatch Logs should be enabled

Description

This control checks whether OpenSearch domains are configured to send error logs to CloudWatch Logs. This control fails if error logging to CloudWatch is not enabled for a domain.

You should enable error logs for OpenSearch domains and send those logs to CloudWatch Logs for retention and response. Domain error logs can assist with security and access audits, and can help to diagnose availability issues.

Remediation

For information on how to enable log publishing, see Enabling log publishing (console) in the Amazon OpenSearch Service Developer Guide.

Usage

Run the control in your terminal:

powerpipe control run aws_compliance.control.foundational_security_opensearch_4

Snapshot and share results via Turbot Pipes:

powerpipe login
powerpipe control run aws_compliance.control.foundational_security_opensearch_4 --share

SQL

This control uses a named query:

select
arn as resource,
case
when log_publishing_options is null then 'alarm'
when
( log_publishing_options -> 'AUDIT_LOGS' is null
or log_publishing_options -> 'AUDIT_LOGS' -> 'Enabled' = 'false'
or (log_publishing_options -> 'AUDIT_LOGS' -> 'Enabled' = 'true' and log_publishing_options -> 'AUDIT_LOGS' -> 'CloudWatchLogsLogGroupArn' is not null)
)
and
( log_publishing_options -> 'INDEX_SLOW_LOGS' is null
or log_publishing_options -> 'INDEX_SLOW_LOGS' -> 'Enabled' = 'false'
or (log_publishing_options -> 'INDEX_SLOW_LOGS' -> 'Enabled' = 'true' and log_publishing_options -> 'INDEX_SLOW_LOGS' -> 'CloudWatchLogsLogGroupArn' is not null)
)
and
( log_publishing_options -> 'SEARCH_SLOW_LOGS' is null
or log_publishing_options -> 'SEARCH_SLOW_LOGS' -> 'Enabled' = 'false'
or (log_publishing_options -> 'SEARCH_SLOW_LOGS' -> 'Enabled' = 'true' and log_publishing_options -> 'SEARCH_SLOW_LOGS' -> 'CloudWatchLogsLogGroupArn' is not null)
)
and
( log_publishing_options -> 'ES_APPLICATION_LOGS' is null
or log_publishing_options -> 'ES_APPLICATION_LOGS' -> 'Enabled' = 'false'
or (log_publishing_options -> 'ES_APPLICATION_LOGS' -> 'Enabled' = 'true' and log_publishing_options -> 'ES_APPLICATION_LOGS' -> 'CloudWatchLogsLogGroupArn' is not null)
)
then 'ok'
else 'alarm'
end as status,
case
when log_publishing_options is null then title || ' logging not enabled.'
when
( log_publishing_options -> 'AUDIT_LOGS' is null
or log_publishing_options -> 'AUDIT_LOGS' -> 'Enabled' = 'false'
or (log_publishing_options -> 'AUDIT_LOGS' -> 'Enabled' = 'true' and log_publishing_options -> 'AUDIT_LOGS' -> 'CloudWatchLogsLogGroupArn' is not null)
)
and
( log_publishing_options -> 'INDEX_SLOW_LOGS' is null
or log_publishing_options -> 'INDEX_SLOW_LOGS' -> 'Enabled' = 'false'
or (log_publishing_options -> 'INDEX_SLOW_LOGS' -> 'Enabled' = 'true' and log_publishing_options -> 'INDEX_SLOW_LOGS' -> 'CloudWatchLogsLogGroupArn' is not null)
)
and
( log_publishing_options -> 'SEARCH_SLOW_LOGS' is null
or log_publishing_options -> 'SEARCH_SLOW_LOGS' -> 'Enabled' = 'false'
or (log_publishing_options -> 'SEARCH_SLOW_LOGS' -> 'Enabled' = 'true' and log_publishing_options -> 'SEARCH_SLOW_LOGS' -> 'CloudWatchLogsLogGroupArn' is not null)
)
and
( log_publishing_options -> 'ES_APPLICATION_LOGS' is null
or log_publishing_options -> 'ES_APPLICATION_LOGS' -> 'Enabled' = 'false'
or (log_publishing_options -> 'ES_APPLICATION_LOGS' -> 'Enabled' = 'true' and log_publishing_options -> 'ES_APPLICATION_LOGS' -> 'CloudWatchLogsLogGroupArn' is not null)
) then title || ' send logs to AWS CloudWatch.'
else title || ' does not send logs to AWS CloudWatch.'
end as reason
, region, account_id
from
aws_opensearch_domain;

Tags