Show / Hide Table of Contents

Namespace Pulumi.Random

Classes

Provider

The provider type for the random package. By default, resources use package-wide configuration settings, however an explicit Provider instance may be created and passed during resource construction to achieve fine-grained programmatic control over provider settings. See the documentation for more information.

ProviderArgs

RandomId

The resource random..RandomId generates random numbers that are intended to be used as unique identifiers for other resources.

This resource does use a cryptographic random number generator in order to minimize the chance of collisions, making the results of this resource when a 16-byte identifier is requested of equivalent uniqueness to a type-4 UUID.

This resource can be used in conjunction with resources that have the create_before_destroy lifecycle flag set to avoid conflicts with unique names during the brief period where both the old and new resources exist concurrently.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;
using Random = Pulumi.Random;

class MyStack : Stack
{
public MyStack()
{
    var serverRandomId = new Random.RandomId("serverRandomId", new Random.RandomIdArgs
    {
        ByteLength = 8,
        Keepers = 
        {
            { "ami_id", @var.Ami_id },
        },
    });
    var serverInstance = new Aws.Ec2.Instance("serverInstance", new Aws.Ec2.InstanceArgs
    {
        Ami = serverRandomId.Keepers.Apply(keepers => keepers.AmiId),
        Tags = 
        {
            { "Name", serverRandomId.Hex.Apply(hex => $"web-server {hex}") },
        },
    });
}

}

RandomIdArgs

RandomIdState

RandomInteger

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 create_before_destroy lifecycle flag set, to avoid conflicts with unique names during the brief period where both the old and new resources exist concurrently.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;
using Random = Pulumi.Random;

class MyStack : Stack
{
public MyStack()
{
    var priority = new Random.RandomInteger("priority", new Random.RandomIntegerArgs
    {
        Keepers = 
        {
            { "listener_arn", @var.Listener_arn },
        },
        Max = 50000,
        Min = 1,
    });
    var main = new Aws.Alb.ListenerRule("main", new Aws.Alb.ListenerRuleArgs
    {
        Actions = 
        {
            new Aws.Alb.Inputs.ListenerRuleActionArgs
            {
                TargetGroupArn = @var.Target_group_arn,
                Type = "forward",
            },
        },
        ListenerArn = @var.Listener_arn,
        Priority = priority.Result,
    });
}

}

RandomIntegerArgs

RandomIntegerState

RandomPassword

Note: Requires random provider version >= 2.2.0

Identical to random..RandomString with the exception that the result is treated as sensitive and, thus, not displayed in console output.

Note: All attributes including the generated password will be stored in the raw state as plain-text. Read more about sensitive data in state.

This resource does use a cryptographic random number generator.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;
using Random = Pulumi.Random;

class MyStack : Stack
{
public MyStack()
{
    var password = new Random.RandomPassword("password", new Random.RandomPasswordArgs
    {
        Length = 16,
        Special = true,
        OverrideSpecial = "_%@",
    });
    var example = new Aws.Rds.Instance("example", new Aws.Rds.InstanceArgs
    {
        InstanceClass = "db.t3.micro",
        AllocatedStorage = 64,
        Engine = "mysql",
        Username = "someone",
        Password = random_string.Password.Result,
    });
}

}

RandomPasswordArgs

RandomPasswordState

RandomPet

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 create_before_destroy lifecycle flag set, to avoid conflicts with unique names during the brief period where both the old and new resources exist concurrently.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;
using Random = Pulumi.Random;

class MyStack : Stack
{
public MyStack()
{
    var serverRandomPet = new Random.RandomPet("serverRandomPet", new Random.RandomPetArgs
    {
        Keepers = 
        {
            { "ami_id", @var.Ami_id },
        },
    });
    var serverInstance = new Aws.Ec2.Instance("serverInstance", new Aws.Ec2.InstanceArgs
    {
        Ami = serverRandomPet.Keepers.Apply(keepers => keepers.AmiId),
        Tags = 
        {
            { "Name", serverRandomPet.Id.Apply(id => $"web-server-{id}") },
        },
    });
}

}

RandomPetArgs

RandomPetState

RandomShuffle

The resource random..RandomShuffle generates a random permutation of a list of strings given as an argument.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;
using Random = Pulumi.Random;

class MyStack : Stack
{
public MyStack()
{
    var az = new Random.RandomShuffle("az", new Random.RandomShuffleArgs
    {
        Inputs = 
        {
            "us-west-1a",
            "us-west-1c",
            "us-west-1d",
            "us-west-1e",
        },
        ResultCount = 2,
    });
    var example = new Aws.Elb.LoadBalancer("example", new Aws.Elb.LoadBalancerArgs
    {
        AvailabilityZones = az.Results,
    });
}

}

RandomShuffleArgs

RandomShuffleState

RandomString

The resource random..RandomString generates a random permutation of alphanumeric characters and optionally special characters.

This resource does use a cryptographic random number generator.

Historically this resource's intended usage has been ambiguous as the original example used it in a password. For backwards compatibility it will continue to exist. For unique ids please use random_id, for sensitive random values please use random_password.

Example Usage

using Pulumi;
using Random = Pulumi.Random;

class MyStack : Stack
{
public MyStack()
{
    var random = new Random.RandomString("random", new Random.RandomStringArgs
    {
        Length = 16,
        OverrideSpecial = "/@£$$",
        Special = true,
    });
}

}

RandomStringArgs

RandomStringState

RandomUuid

The resource random..RandomUuid generates random uuid string that is intended to be used as unique identifiers for other resources.

This resource uses the hashicorp/go-uuid to generate a UUID-formatted string for use with services needed a unique string identifier.

Example Usage

using Pulumi;
using Azure = Pulumi.Azure;
using Random = Pulumi.Random;

class MyStack : Stack
{
public MyStack()
{
    var testRandomUuid = new Random.RandomUuid("testRandomUuid", new Random.RandomUuidArgs
    {
    });
    var testResourceGroup = new Azure.Core.ResourceGroup("testResourceGroup", new Azure.Core.ResourceGroupArgs
    {
        Location = "Central US",
    });
}

}

RandomUuidArgs

RandomUuidState

Back to top Copyright 2016-2020, Pulumi Corporation.