UNPKG

@pulumi/linode

Version:

A Pulumi package for creating and managing linode cloud resources.

123 lines 4.82 kB
"use strict"; // *** WARNING: this file was generated by pulumi-language-nodejs. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.Lock = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("./utilities"); /** * > **Early Access** Locks are in Early Access and may not be available to all users. * * > **Important** Only unrestricted users can create and delete locks. Restricted users cannot manage locks even if they have read/write permissions for the resource. * * Manages a Linode Lock which prevents accidental deletion and modification of resources. Locks protect against deletion, rebuild operations, and service transfers. The `cannotDeleteWithSubresources` lock type also protects subresources such as disks, configs, interfaces, and IP addresses. * * For more information, see the Linode APIv4 docs (TBD). * * > **Note** Only one lock can exist per resource at a time. You cannot have both `cannotDelete` and `cannotDeleteWithSubresources` locks on the same resource simultaneously. * * ## Example Usage * * Create a basic lock that prevents a Linode from being deleted: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as linode from "@pulumi/linode"; * * const my_inst = new linode.Instance("my-inst", { * label: "my-inst", * region: "us-east", * type: "g6-nanode-1", * }); * const my_lock = new linode.Lock("my-lock", { * entityId: my_inst.id, * entityType: "linode", * lockType: "cannot_delete", * }); * ``` * * Create a lock that prevents a Linode and its subresources (disks, configs, etc.) from being deleted: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as linode from "@pulumi/linode"; * * const my_inst = new linode.Instance("my-inst", { * label: "my-inst", * region: "us-east", * type: "g6-nanode-1", * }); * const my_lock = new linode.Lock("my-lock", { * entityId: my_inst.id, * entityType: "linode", * lockType: "cannot_delete_with_subresources", * }); * ``` * * ## Import * * Locks can be imported using the Lock's ID, e.g. * * ```sh * $ pulumi import linode:index/lock:Lock my-lock 1234567 * ``` */ class Lock extends pulumi.CustomResource { /** * Get an existing Lock 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 Lock(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of Lock. 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'] === Lock.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["entityId"] = state?.entityId; resourceInputs["entityLabel"] = state?.entityLabel; resourceInputs["entityType"] = state?.entityType; resourceInputs["entityUrl"] = state?.entityUrl; resourceInputs["lockType"] = state?.lockType; } else { const args = argsOrState; if (args?.entityId === undefined && !opts.urn) { throw new Error("Missing required property 'entityId'"); } if (args?.entityType === undefined && !opts.urn) { throw new Error("Missing required property 'entityType'"); } if (args?.lockType === undefined && !opts.urn) { throw new Error("Missing required property 'lockType'"); } resourceInputs["entityId"] = args?.entityId; resourceInputs["entityType"] = args?.entityType; resourceInputs["lockType"] = args?.lockType; resourceInputs["entityLabel"] = undefined /*out*/; resourceInputs["entityUrl"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(Lock.__pulumiType, name, resourceInputs, opts); } } exports.Lock = Lock; /** @internal */ Lock.__pulumiType = 'linode:index/lock:Lock'; //# sourceMappingURL=lock.js.map