Control: Elasticsearch domain should send logs to cloudWatch
Description
Ensure if Amazon OpenSearch Service (OpenSearch Service) domains are configured to send logs to Amazon CloudWatch Logs. The rule is complaint if a log is enabled for an OpenSearch Service domain. This rule is non complain if logging is not configured.
Usage
Run the control in your terminal:
powerpipe control run terraform_aws_compliance.control.es_domain_logs_to_cloudwatch
Snapshot and share results via Turbot Pipes:
powerpipe loginpowerpipe control run terraform_aws_compliance.control.es_domain_logs_to_cloudwatch --share
SQL
This control uses a named query:
select address as resource, case when (attributes_std -> 'log_publishing_options') @> '[{"log_type": "ES_APPLICATION_LOGS"}]' and (attributes_std -> 'log_publishing_options') @> '[{"log_type": "ES_APPLICATION_LOGS"}]' and (attributes_std -> 'log_publishing_options') @> '[{"log_type": "ES_APPLICATION_LOGS"}]' then 'ok' else 'alarm' end status, split_part(address, '.', 2) || case when (attributes_std -> 'log_publishing_options') @> '[{"log_type": "ES_APPLICATION_LOGS"}]' and (attributes_std -> 'log_publishing_options') @> '[{"log_type": "ES_APPLICATION_LOGS"}]' and (attributes_std -> 'log_publishing_options') @> '[{"log_type": "ES_APPLICATION_LOGS"}]' then ' logging enabled for search , index and error' else ' logging not enabled for all search, index and error' end || '.' reason , path || ':' || start_linefrom terraform_resourcewhere type = 'aws_elasticsearch_domain';