This template creates an OpenSearch Serverless encryption policy named 'logs-encryption-policy' with an AWS owned key. The policy will apply to all future collections with names that begin with 'logs'.

CloudFormation Template

AWSTemplateFormatVersion: '2010-09-09'
Description: OpenSearch Serverless Encryption Policy
Resources:
  TestSecurityPolicy:
    Type: 'AWS::OpenSearchServerless::SecurityPolicy'
    Properties:
      Name: "logs-encryption-policy"
      Type: "encryption"
      Description: "Encryption policy for test collections"
      Policy: '{"Rules":[{"ResourceType":"collection","Resource":["collection/logs*"]}],"AWSOwnedKey":true}'