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}") },
},
});
}
}
Inherited Members
Namespace: Pulumi.Random
Assembly: Pulumi.Random.dll
Syntax
public class RandomId : CustomResource
Constructors
View SourceRandomId(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 SourceB64
Declaration
public Output<string> B64 { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
B64Std
The generated id presented in base64 without additional transformations.
Declaration
public Output<string> B64Std { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
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> |
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> |
Dec
The generated id presented in non-padded decimal digits.
Declaration
public Output<string> Dec { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
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> |
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>> |
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 SourceGet(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 |