@piclemx/pulumi-opensearch
Version:
A Pulumi package for creating and managing Opensearch resources. Based on terraform-provider-opensearch: version v2.2.1
125 lines • 4.76 kB
JavaScript
;
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.SmPolicy = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* Provides an OpenSearch Snapshot Management (SM) policy. Please refer to the OpenSearch SM documentation for details.
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as opensearch from "@piclemx/pulumi-opensearch";
*
* // Create a snapshot repository. Make sure you also have created the bucket (eg.
* // via `terraform-aws-modules/s3-bucket/aws`) and matching IAM role.
* const repo = new opensearch.SnapshotRepository("repo", {
* type: "s3",
* settings: {
* bucket: module.s3_snapshot.s3_bucket_id,
* region: module.s3_snapshot.s3_bucket_region,
* role_arn: aws_iam_role.snapshot_create.arn,
* server_side_encryption: true,
* },
* });
* // Create the SM policy
* const snapshotToS3 = new opensearch.SmPolicy("snapshotToS3", {
* policyName: "snapshot_to_s3",
* body: repo.name.apply(name => JSON.stringify({
* enabled: true,
* description: "My snapshot policy",
* creation: {
* schedule: {
* cron: {
* expression: "0 0 * * *",
* timezone: "UTC",
* },
* },
* time_limit: "1h",
* },
* deletion: {
* schedule: {
* cron: {
* expression: "0 0 * * *",
* timezone: "UTC",
* },
* },
* condition: {
* max_age: "14d",
* max_count: 400,
* min_count: 1,
* },
* time_limit: "1h",
* },
* snapshot_config: {
* timezone: "UTC",
* indices: "*",
* repository: name,
* },
* })),
* });
* ```
*
* ## Import
*
* ```sh
* $ pulumi import opensearch:index/smPolicy:SmPolicy cleanup snapshot_to_s3
* ```
*/
class SmPolicy extends pulumi.CustomResource {
/**
* Get an existing SmPolicy resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name, id, state, opts) {
return new SmPolicy(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of SmPolicy. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === SmPolicy.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["body"] = state ? state.body : undefined;
resourceInputs["policyName"] = state ? state.policyName : undefined;
resourceInputs["primaryTerm"] = state ? state.primaryTerm : undefined;
resourceInputs["seqNo"] = state ? state.seqNo : undefined;
}
else {
const args = argsOrState;
if ((!args || args.body === undefined) && !opts.urn) {
throw new Error("Missing required property 'body'");
}
if ((!args || args.policyName === undefined) && !opts.urn) {
throw new Error("Missing required property 'policyName'");
}
resourceInputs["body"] = args ? args.body : undefined;
resourceInputs["policyName"] = args ? args.policyName : undefined;
resourceInputs["primaryTerm"] = args ? args.primaryTerm : undefined;
resourceInputs["seqNo"] = args ? args.seqNo : undefined;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(SmPolicy.__pulumiType, name, resourceInputs, opts);
}
}
exports.SmPolicy = SmPolicy;
/** @internal */
SmPolicy.__pulumiType = 'opensearch:index/smPolicy:SmPolicy';
//# sourceMappingURL=smPolicy.js.map