Show / Hide Table of Contents

Class 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}") },
        },
    });
}

}
Inheritance
System.Object
Resource
CustomResource
RandomId
Inherited Members
CustomResource.Id
Resource.GetResourceType()
Resource.GetResourceName()
Resource.Urn
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Pulumi.Random
Assembly: Pulumi.Random.dll
Syntax
public class RandomId : CustomResource

Constructors

View Source

RandomId(String, RandomIdArgs, CustomResourceOptions)

Create a RandomId resource with the given unique name, arguments, and options.

Declaration
public RandomId(string name, RandomIdArgs args, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resource

RandomIdArgs args

The arguments used to populate this resource's properties

CustomResourceOptions options

A bag of options that control this resource's behavior

Properties

View Source

B64

Declaration
public Output<string> B64 { get; }
Property Value
Type Description
Output<System.String>
View Source

B64Std

The generated id presented in base64 without additional transformations.

Declaration
public Output<string> B64Std { get; }
Property Value
Type Description
Output<System.String>
View Source

B64Url

The generated id presented in base64, using the URL-friendly character set: case-sensitive letters, digits and the characters _ and -.

Declaration
public Output<string> B64Url { get; }
Property Value
Type Description
Output<System.String>
View Source

ByteLength

The number of random bytes to produce. The minimum value is 1, which produces eight bits of randomness.

Declaration
public Output<int> ByteLength { get; }
Property Value
Type Description
Output<System.Int32>
View Source

Dec

The generated id presented in non-padded decimal digits.

Declaration
public Output<string> Dec { get; }
Property Value
Type Description
Output<System.String>
View Source

Hex

The generated id presented in padded hexadecimal digits. This result will always be twice as long as the requested byte length.

Declaration
public Output<string> Hex { get; }
Property Value
Type Description
Output<System.String>
View Source

Keepers

Arbitrary map of values that, when changed, will trigger a new id to be generated. See the main provider documentation for more information.

Declaration
public Output<ImmutableDictionary<string, object>> Keepers { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableDictionary<System.String, System.Object>>
View Source

Prefix

Arbitrary string to prefix the output value with. This string is supplied as-is, meaning it is not guaranteed to be URL-safe or base64 encoded.

Declaration
public Output<string> Prefix { get; }
Property Value
Type Description
Output<System.String>

Methods

View Source

Get(String, Input<String>, RandomIdState, CustomResourceOptions)

Get an existing RandomId resource's state with the given name, ID, and optional extra properties used to qualify the lookup.

Declaration
public static RandomId Get(string name, Input<string> id, RandomIdState state = null, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resulting resource.

Input<System.String> id

The unique provider ID of the resource to lookup.

RandomIdState state

Any extra arguments used during the lookup.

CustomResourceOptions options

A bag of options that control this resource's behavior

Returns
Type Description
RandomId
  • View Source
Back to top Copyright 2016-2020, Pulumi Corporation.