UNPKG

@pulumi/random

Version:

A Pulumi package to safely use randomness in Pulumi programs.

81 lines 3.28 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.RandomPet = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("./utilities"); /** * The resource `random.RandomPet` generates random pet names that are intended to be used as unique identifiers for other resources. * * This resource can be used in conjunction with resources that have the `createBeforeDestroy` lifecycle flag set, to avoid conflicts with unique names during the brief period where both the old and new resources exist concurrently. * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * import * as random from "@pulumi/random"; * * // The following example shows how to generate a unique pet name * // for an AWS EC2 instance that changes each time a new AMI id is * // selected. * const server = new random.RandomPet("server", {keepers: { * ami_id: amiId, * }}); * const serverInstance = new aws.index.Instance("server", { * tags: { * name: `web-server-${server.id}`, * }, * ami: server.keepers?.amiId, * }); * ``` */ class RandomPet extends pulumi.CustomResource { /** * Get an existing RandomPet 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 RandomPet(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of RandomPet. 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'] === RandomPet.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["keepers"] = state?.keepers; resourceInputs["length"] = state?.length; resourceInputs["prefix"] = state?.prefix; resourceInputs["separator"] = state?.separator; } else { const args = argsOrState; resourceInputs["keepers"] = args?.keepers; resourceInputs["length"] = args?.length; resourceInputs["prefix"] = args?.prefix; resourceInputs["separator"] = args?.separator; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(RandomPet.__pulumiType, name, resourceInputs, opts); } } exports.RandomPet = RandomPet; /** @internal */ RandomPet.__pulumiType = 'random:index/randomPet:RandomPet'; //# sourceMappingURL=randomPet.js.map