Review Elasticsearch and OpenSearch audit logging

Configure audit log generation together with CloudWatch delivery.

Description

Domain audit logs can record failed authentication, permission use and index changes. The events recorded depend on the categories you enable.

Potential impact

Without those records, it can be hard to tell who performed an administrative action. Request bodies can contain sensitive data.

Remediation

Auditing requires a supported engine and fine-grained access control. Before enabling access control on an existing domain, check client authentication and role mappings. You cannot turn it off afterward. Allow service writes in the CloudWatch Logs resource policy, then set the destination ARN and Enabled: true under AUDIT_LOGS. Turn on auditing for the required categories in OpenSearch Dashboards or another supported interface. Verify a matching event reaches the group, and restrict log access and retention.

Examples

The AWS::Elasticsearch::Domain excerpts change only audit-log publishing. Replace the sample log group ARN with your destination.

Before

yaml
Resources:
  ElasticsearchDomain:
    Type: AWS::Elasticsearch::Domain
    Properties:
      DomainName: my-domain
      LogPublishingOptions:
        AUDIT_LOGS:
          CloudWatchLogsLogGroupArn: arn:aws:logs:us-east-1:123456789012:log-group:/aws/aes/domains/audit
          Enabled: false

After

yaml
Resources:
  ElasticsearchDomain:
    Type: AWS::Elasticsearch::Domain
    Properties:
      DomainName: my-domain
      LogPublishingOptions:
        AUDIT_LOGS:
          CloudWatchLogsLogGroupArn: arn:aws:logs:us-east-1:123456789012:log-group:/aws/aes/domains/audit
          Enabled: true

References