1. Packages
  2. AWS
  3. API Docs
  4. opensearch
  5. ServerlessLifecyclePolicy
AWS v6.60.0 published on Tuesday, Nov 19, 2024 by Pulumi

aws.opensearch.ServerlessLifecyclePolicy

Explore with Pulumi AI

aws logo
AWS v6.60.0 published on Tuesday, Nov 19, 2024 by Pulumi

    Resource for managing an AWS OpenSearch Serverless Lifecycle Policy. See AWS documentation for lifecycle policies.

    Example Usage

    Basic Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const example = new aws.opensearch.ServerlessLifecyclePolicy("example", {
        name: "example",
        type: "retention",
        policy: JSON.stringify({
            Rules: [
                {
                    ResourceType: "index",
                    Resource: ["index/autoparts-inventory/*"],
                    MinIndexRetention: "81d",
                },
                {
                    ResourceType: "index",
                    Resource: ["index/sales/orders*"],
                    NoMinIndexRetention: true,
                },
            ],
        }),
    });
    
    import pulumi
    import json
    import pulumi_aws as aws
    
    example = aws.opensearch.ServerlessLifecyclePolicy("example",
        name="example",
        type="retention",
        policy=json.dumps({
            "Rules": [
                {
                    "ResourceType": "index",
                    "Resource": ["index/autoparts-inventory/*"],
                    "MinIndexRetention": "81d",
                },
                {
                    "ResourceType": "index",
                    "Resource": ["index/sales/orders*"],
                    "NoMinIndexRetention": True,
                },
            ],
        }))
    
    package main
    
    import (
    	"encoding/json"
    
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/opensearch"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		tmpJSON0, err := json.Marshal(map[string]interface{}{
    			"Rules": []interface{}{
    				map[string]interface{}{
    					"ResourceType": "index",
    					"Resource": []string{
    						"index/autoparts-inventory/*",
    					},
    					"MinIndexRetention": "81d",
    				},
    				map[string]interface{}{
    					"ResourceType": "index",
    					"Resource": []string{
    						"index/sales/orders*",
    					},
    					"NoMinIndexRetention": true,
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		json0 := string(tmpJSON0)
    		_, err = opensearch.NewServerlessLifecyclePolicy(ctx, "example", &opensearch.ServerlessLifecyclePolicyArgs{
    			Name:   pulumi.String("example"),
    			Type:   pulumi.String("retention"),
    			Policy: pulumi.String(json0),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using System.Text.Json;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var example = new Aws.OpenSearch.ServerlessLifecyclePolicy("example", new()
        {
            Name = "example",
            Type = "retention",
            Policy = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["Rules"] = new[]
                {
                    new Dictionary<string, object?>
                    {
                        ["ResourceType"] = "index",
                        ["Resource"] = new[]
                        {
                            "index/autoparts-inventory/*",
                        },
                        ["MinIndexRetention"] = "81d",
                    },
                    new Dictionary<string, object?>
                    {
                        ["ResourceType"] = "index",
                        ["Resource"] = new[]
                        {
                            "index/sales/orders*",
                        },
                        ["NoMinIndexRetention"] = true,
                    },
                },
            }),
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.opensearch.ServerlessLifecyclePolicy;
    import com.pulumi.aws.opensearch.ServerlessLifecyclePolicyArgs;
    import static com.pulumi.codegen.internal.Serialization.*;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var example = new ServerlessLifecyclePolicy("example", ServerlessLifecyclePolicyArgs.builder()
                .name("example")
                .type("retention")
                .policy(serializeJson(
                    jsonObject(
                        jsonProperty("Rules", jsonArray(
                            jsonObject(
                                jsonProperty("ResourceType", "index"),
                                jsonProperty("Resource", jsonArray("index/autoparts-inventory/*")),
                                jsonProperty("MinIndexRetention", "81d")
                            ), 
                            jsonObject(
                                jsonProperty("ResourceType", "index"),
                                jsonProperty("Resource", jsonArray("index/sales/orders*")),
                                jsonProperty("NoMinIndexRetention", true)
                            )
                        ))
                    )))
                .build());
    
        }
    }
    
    resources:
      example:
        type: aws:opensearch:ServerlessLifecyclePolicy
        properties:
          name: example
          type: retention
          policy:
            fn::toJSON:
              Rules:
                - ResourceType: index
                  Resource:
                    - index/autoparts-inventory/*
                  MinIndexRetention: 81d
                - ResourceType: index
                  Resource:
                    - index/sales/orders*
                  NoMinIndexRetention: true
    

    Create ServerlessLifecyclePolicy Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new ServerlessLifecyclePolicy(name: string, args: ServerlessLifecyclePolicyArgs, opts?: CustomResourceOptions);
    @overload
    def ServerlessLifecyclePolicy(resource_name: str,
                                  args: ServerlessLifecyclePolicyArgs,
                                  opts: Optional[ResourceOptions] = None)
    
    @overload
    def ServerlessLifecyclePolicy(resource_name: str,
                                  opts: Optional[ResourceOptions] = None,
                                  policy: Optional[str] = None,
                                  type: Optional[str] = None,
                                  description: Optional[str] = None,
                                  name: Optional[str] = None)
    func NewServerlessLifecyclePolicy(ctx *Context, name string, args ServerlessLifecyclePolicyArgs, opts ...ResourceOption) (*ServerlessLifecyclePolicy, error)
    public ServerlessLifecyclePolicy(string name, ServerlessLifecyclePolicyArgs args, CustomResourceOptions? opts = null)
    public ServerlessLifecyclePolicy(String name, ServerlessLifecyclePolicyArgs args)
    public ServerlessLifecyclePolicy(String name, ServerlessLifecyclePolicyArgs args, CustomResourceOptions options)
    
    type: aws:opensearch:ServerlessLifecyclePolicy
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args ServerlessLifecyclePolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args ServerlessLifecyclePolicyArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args ServerlessLifecyclePolicyArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args ServerlessLifecyclePolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args ServerlessLifecyclePolicyArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var serverlessLifecyclePolicyResource = new Aws.OpenSearch.ServerlessLifecyclePolicy("serverlessLifecyclePolicyResource", new()
    {
        Policy = "string",
        Type = "string",
        Description = "string",
        Name = "string",
    });
    
    example, err := opensearch.NewServerlessLifecyclePolicy(ctx, "serverlessLifecyclePolicyResource", &opensearch.ServerlessLifecyclePolicyArgs{
    	Policy:      pulumi.String("string"),
    	Type:        pulumi.String("string"),
    	Description: pulumi.String("string"),
    	Name:        pulumi.String("string"),
    })
    
    var serverlessLifecyclePolicyResource = new ServerlessLifecyclePolicy("serverlessLifecyclePolicyResource", ServerlessLifecyclePolicyArgs.builder()
        .policy("string")
        .type("string")
        .description("string")
        .name("string")
        .build());
    
    serverless_lifecycle_policy_resource = aws.opensearch.ServerlessLifecyclePolicy("serverlessLifecyclePolicyResource",
        policy="string",
        type="string",
        description="string",
        name="string")
    
    const serverlessLifecyclePolicyResource = new aws.opensearch.ServerlessLifecyclePolicy("serverlessLifecyclePolicyResource", {
        policy: "string",
        type: "string",
        description: "string",
        name: "string",
    });
    
    type: aws:opensearch:ServerlessLifecyclePolicy
    properties:
        description: string
        name: string
        policy: string
        type: string
    

    ServerlessLifecyclePolicy Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The ServerlessLifecyclePolicy resource accepts the following input properties:

    Policy string
    JSON policy document to use as the content for the new policy.
    Type string

    Type of lifecycle policy. Must be retention.

    The following arguments are optional:

    Description string
    Description of the policy.
    Name string
    Name of the policy.
    Policy string
    JSON policy document to use as the content for the new policy.
    Type string

    Type of lifecycle policy. Must be retention.

    The following arguments are optional:

    Description string
    Description of the policy.
    Name string
    Name of the policy.
    policy String
    JSON policy document to use as the content for the new policy.
    type String

    Type of lifecycle policy. Must be retention.

    The following arguments are optional:

    description String
    Description of the policy.
    name String
    Name of the policy.
    policy string
    JSON policy document to use as the content for the new policy.
    type string

    Type of lifecycle policy. Must be retention.

    The following arguments are optional:

    description string
    Description of the policy.
    name string
    Name of the policy.
    policy str
    JSON policy document to use as the content for the new policy.
    type str

    Type of lifecycle policy. Must be retention.

    The following arguments are optional:

    description str
    Description of the policy.
    name str
    Name of the policy.
    policy String
    JSON policy document to use as the content for the new policy.
    type String

    Type of lifecycle policy. Must be retention.

    The following arguments are optional:

    description String
    Description of the policy.
    name String
    Name of the policy.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the ServerlessLifecyclePolicy resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    PolicyVersion string
    Version of the policy.
    Id string
    The provider-assigned unique ID for this managed resource.
    PolicyVersion string
    Version of the policy.
    id String
    The provider-assigned unique ID for this managed resource.
    policyVersion String
    Version of the policy.
    id string
    The provider-assigned unique ID for this managed resource.
    policyVersion string
    Version of the policy.
    id str
    The provider-assigned unique ID for this managed resource.
    policy_version str
    Version of the policy.
    id String
    The provider-assigned unique ID for this managed resource.
    policyVersion String
    Version of the policy.

    Look up Existing ServerlessLifecyclePolicy Resource

    Get an existing ServerlessLifecyclePolicy resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: ServerlessLifecyclePolicyState, opts?: CustomResourceOptions): ServerlessLifecyclePolicy
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            description: Optional[str] = None,
            name: Optional[str] = None,
            policy: Optional[str] = None,
            policy_version: Optional[str] = None,
            type: Optional[str] = None) -> ServerlessLifecyclePolicy
    func GetServerlessLifecyclePolicy(ctx *Context, name string, id IDInput, state *ServerlessLifecyclePolicyState, opts ...ResourceOption) (*ServerlessLifecyclePolicy, error)
    public static ServerlessLifecyclePolicy Get(string name, Input<string> id, ServerlessLifecyclePolicyState? state, CustomResourceOptions? opts = null)
    public static ServerlessLifecyclePolicy get(String name, Output<String> id, ServerlessLifecyclePolicyState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    Description string
    Description of the policy.
    Name string
    Name of the policy.
    Policy string
    JSON policy document to use as the content for the new policy.
    PolicyVersion string
    Version of the policy.
    Type string

    Type of lifecycle policy. Must be retention.

    The following arguments are optional:

    Description string
    Description of the policy.
    Name string
    Name of the policy.
    Policy string
    JSON policy document to use as the content for the new policy.
    PolicyVersion string
    Version of the policy.
    Type string

    Type of lifecycle policy. Must be retention.

    The following arguments are optional:

    description String
    Description of the policy.
    name String
    Name of the policy.
    policy String
    JSON policy document to use as the content for the new policy.
    policyVersion String
    Version of the policy.
    type String

    Type of lifecycle policy. Must be retention.

    The following arguments are optional:

    description string
    Description of the policy.
    name string
    Name of the policy.
    policy string
    JSON policy document to use as the content for the new policy.
    policyVersion string
    Version of the policy.
    type string

    Type of lifecycle policy. Must be retention.

    The following arguments are optional:

    description str
    Description of the policy.
    name str
    Name of the policy.
    policy str
    JSON policy document to use as the content for the new policy.
    policy_version str
    Version of the policy.
    type str

    Type of lifecycle policy. Must be retention.

    The following arguments are optional:

    description String
    Description of the policy.
    name String
    Name of the policy.
    policy String
    JSON policy document to use as the content for the new policy.
    policyVersion String
    Version of the policy.
    type String

    Type of lifecycle policy. Must be retention.

    The following arguments are optional:

    Import

    Using pulumi import, import OpenSearch Serverless Lifecycle Policy using the name and type arguments separated by a slash (/). For example:

    $ pulumi import aws:opensearch/serverlessLifecyclePolicy:ServerlessLifecyclePolicy example example/retention
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    AWS Classic pulumi/pulumi-aws
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the aws Terraform Provider.
    aws logo
    AWS v6.60.0 published on Tuesday, Nov 19, 2024 by Pulumi