AWS::OpenSearchServerless::LifecyclePolicy
Creates a lifecyle policy to be applied to OpenSearch Serverless indexes. Lifecycle policies define the number of days or hours to retain the data on an OpenSearch Serverless index. For more information, see Creating data lifecycle policies.
Syntax
To declare this entity in your AWS CloudFormation template, use the following syntax:
JSON
{ "Type" : "AWS::OpenSearchServerless::LifecyclePolicy", "Properties" : { "Description" :
String
, "Name" :String
, "Policy" :String
, "Type" :String
} }
YAML
Type: AWS::OpenSearchServerless::LifecyclePolicy Properties: Description:
String
Name:String
Policy:String
Type:String
Properties
Description
-
The description of the lifecycle policy.
Required: No
Type: String
Minimum:
0
Maximum:
1000
Update requires: No interruption
Name
-
The name of the lifecycle policy.
Required: Yes
Type: String
Pattern:
^[a-z][a-z0-9-]+$
Minimum:
3
Maximum:
32
Update requires: Replacement
Policy
-
The JSON policy document without any whitespaces.
Required: Yes
Type: String
Pattern:
[\u0009\u000A\u000D\u0020-\u007E\u00A1-\u00FF]+
Minimum:
1
Maximum:
20480
Update requires: No interruption
Type
-
The type of lifecycle policy.
Required: Yes
Type: String
Allowed values:
retention
Update requires: Replacement
Return values
Ref
When you pass the logical ID of this resource to the intrinsic Ref
function, Ref
returns the type and name of the lifecycle policy. For more information about using the
Ref
function, see Ref.
Examples
Create a lifecycle policy that sets a minimum rollover period for all indexes in a collection
The following example specifies an OpenSearch Serverless lifecycle policy that
sets a minimum rollover period for all indexes within
my-collection
.
JSON
{ "AWSTemplateFormatVersion": "2010-09-09", "Description": "OpenSearch Serverless lifecycle policy template", "Resources": { "TestLifecyclePolicy": { "Type": "AWS::OpenSearchServerless::LifecyclePolicy", "Properties": { "Name": "test-lifecycle-policy", "Type": "retention", "Description": "Lifecycle policy for all indexes in my-collection", "Policy": {\"Rules\": [{\"Resource\": [\"index/my-collection/*\"],\"ResourceType\": \"index\",\"MinIndexRetention\": \"2d\"}} } } } }
YAML
AWSTemplateFormatVersion: 2010-09-09T00:00:00.000Z Description: OpenSearch Serverless lifecycle policy template Resources: TestLifecyclePolicy: Type: 'AWS::OpenSearchServerless::LifecyclePolicy' Properties: Name: test-lifecycle-policy Type: retention Description: Lifecycle policy for all indexes in my-collection Policy: {"Rules": [{"Resource": ["index/my-collection/*"],"ResourceType": "index","MinIndexRetention": "2d"}]}