UNPKG

@pulumi/random

Version:

A Pulumi package to safely use randomness in Pulumi programs.

144 lines (143 loc) 5 kB
import * as pulumi from "@pulumi/pulumi"; /** * The resource `random.RandomInteger` generates random values from a given range, described by the `min` and `max` attributes of a given resource. * * 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 random priority * // between 1 and 50000 for a aws_alb_listener_rule resource: * const priority = new random.RandomInteger("priority", { * min: 1, * max: 50000, * keepers: { * listener_arn: listenerArn, * }, * }); * const main = new aws.alb.ListenerRule("main", { * listenerArn: priority.keepers.apply(keepers => keepers?.listenerArn), * priority: priority.result, * actions: [{ * type: "forward", * targetGroupArn: targetGroupArn, * }], * }); * ``` * * ## Import * * Random integers can be imported using the result, min, and max, with an * * optional seed. This can be used to replace a config value with a value * * interpolated from the random provider without experiencing diffs. * * Example (values are separated by a ,): * * ```sh * $ pulumi import random:index/randomInteger:RandomInteger priority 15390,1,50000 * ``` */ export declare class RandomInteger extends pulumi.CustomResource { /** * Get an existing RandomInteger 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: string, id: pulumi.Input<pulumi.ID>, state?: RandomIntegerState, opts?: pulumi.CustomResourceOptions): RandomInteger; /** * Returns true if the given object is an instance of RandomInteger. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj: any): obj is RandomInteger; /** * Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information. */ readonly keepers: pulumi.Output<{ [key: string]: string; } | undefined>; /** * The maximum inclusive value of the range. */ readonly max: pulumi.Output<number>; /** * The minimum inclusive value of the range. */ readonly min: pulumi.Output<number>; /** * The random integer result. */ readonly result: pulumi.Output<number>; /** * A custom seed to always produce the same value. */ readonly seed: pulumi.Output<string | undefined>; /** * Create a RandomInteger resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: RandomIntegerArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering RandomInteger resources. */ export interface RandomIntegerState { /** * Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information. */ keepers?: pulumi.Input<{ [key: string]: pulumi.Input<string>; }>; /** * The maximum inclusive value of the range. */ max?: pulumi.Input<number>; /** * The minimum inclusive value of the range. */ min?: pulumi.Input<number>; /** * The random integer result. */ result?: pulumi.Input<number>; /** * A custom seed to always produce the same value. */ seed?: pulumi.Input<string>; } /** * The set of arguments for constructing a RandomInteger resource. */ export interface RandomIntegerArgs { /** * Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information. */ keepers?: pulumi.Input<{ [key: string]: pulumi.Input<string>; }>; /** * The maximum inclusive value of the range. */ max: pulumi.Input<number>; /** * The minimum inclusive value of the range. */ min: pulumi.Input<number>; /** * A custom seed to always produce the same value. */ seed?: pulumi.Input<string>; }