Terraform resource for managing an AWS OpenSearch Serverless Lifecycle Policy. See AWS documentation for lifecycle policies.
resource "aws_opensearchserverless_lifecycle_policy" "example" {
name = "example"
type = "retention"
policy = jsonencode({
"Rules" : [
{
"ResourceType" : "index",
"Resource" : ["index/autoparts-inventory/*"],
"MinIndexRetention" : "81d"
},
{
"ResourceType" : "index",
"Resource" : ["index/sales/orders*"],
"NoMinIndexRetention" : true
}
]
})
}
The following arguments are required:
name
- (Required) Name of the policy.policy
- (Required) JSON policy document to use as the content for the new policy.type
- (Required) Type of lifecycle policy. Must be retention
.The following arguments are optional:
description
- (Optional) Description of the policy.This resource exports the following attributes in addition to the arguments above:
policy_version
- Version of the policy.In Terraform v1.5.0 and later, use an import
block to import OpenSearch Serverless Lifecycle Policy using the name
and type
arguments separated by a slash (/
). For example:
import {
to = aws_opensearchserverless_lifecycle_policy.example
id = "example/retention"
}
Using terraform import
, import OpenSearch Serverless Lifecycle Policy using the name
and type
arguments separated by a slash (/
). For example:
% terraform import aws_opensearchserverless_lifecycle_policy.example example/retention