@pulumi/random
Version: 
A Pulumi package to safely use randomness in Pulumi programs.
88 lines • 3.57 kB
JavaScript
;
// *** 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.RandomBytes = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
 * The resource `random.RandomBytes` generates random bytes that are intended to be used as a secret, or key. Use this in preference to `random.RandomId` when the output is considered sensitive, and should not be displayed in the CLI.
 *
 * This resource *does* use a cryptographic random number generator.
 *
 * ## Example Usage
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azurerm from "@pulumi/azurerm";
 * import * as random from "@pulumi/random";
 *
 * const jwtSecret = new random.RandomBytes("jwt_secret", {length: 64});
 * const jwtSecretKeyVaultSecret = new azurerm.index.KeyVaultSecret("jwt_secret", {
 *     keyVaultId: "some-azure-key-vault-id",
 *     name: "JwtSecret",
 *     value: jwtSecret.base64,
 * });
 * ```
 *
 * ## Import
 *
 * Random bytes can be imported by specifying the value as base64 string.
 *
 * ```sh
 * $ pulumi import random:index/randomBytes:RandomBytes basic "8/fu3q+2DcgSJ19i0jZ5Cw=="
 * ```
 */
class RandomBytes extends pulumi.CustomResource {
    /**
     * Get an existing RandomBytes 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 RandomBytes(name, state, { ...opts, id: id });
    }
    /**
     * Returns true if the given object is an instance of RandomBytes.  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'] === RandomBytes.__pulumiType;
    }
    constructor(name, argsOrState, opts) {
        let resourceInputs = {};
        opts = opts || {};
        if (opts.id) {
            const state = argsOrState;
            resourceInputs["base64"] = state?.base64;
            resourceInputs["hex"] = state?.hex;
            resourceInputs["keepers"] = state?.keepers;
            resourceInputs["length"] = state?.length;
        }
        else {
            const args = argsOrState;
            if (args?.length === undefined && !opts.urn) {
                throw new Error("Missing required property 'length'");
            }
            resourceInputs["keepers"] = args?.keepers;
            resourceInputs["length"] = args?.length;
            resourceInputs["base64"] = undefined /*out*/;
            resourceInputs["hex"] = undefined /*out*/;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        const secretOpts = { additionalSecretOutputs: ["base64", "hex"] };
        opts = pulumi.mergeOptions(opts, secretOpts);
        super(RandomBytes.__pulumiType, name, resourceInputs, opts);
    }
}
exports.RandomBytes = RandomBytes;
/** @internal */
RandomBytes.__pulumiType = 'random:index/randomBytes:RandomBytes';
//# sourceMappingURL=randomBytes.js.map