Ready to level-up your engineering skills? Join a Pulumi Workshop. Register Now

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

}
package main

import (
    "github.com/pulumi/pulumi-azure/sdk/v3/go/azure/core"
    "github.com/pulumi/pulumi-random/sdk/v3/go/random"
    "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        _, err := random.NewRandomUuid(ctx, "testRandomUuid", nil)
        if err != nil {
            return err
        }
        _, err = core.NewResourceGroup(ctx, "testResourceGroup", &core.ResourceGroupArgs{
            Location: pulumi.String("Central US"),
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_azure as azure
import pulumi_random as random

test_random_uuid = random.RandomUuid("testRandomUuid")
test_resource_group = azure.core.ResourceGroup("testResourceGroup", location="Central US")
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
import * as random from "@pulumi/random";

const testRandomUuid = new random.RandomUuid("test", {});
const testResourceGroup = new azure.core.ResourceGroup("test", {
    location: "Central US",
});

Create a RandomUuid Resource

new RandomUuid(name: string, args?: RandomUuidArgs, opts?: CustomResourceOptions);
def RandomUuid(resource_name: str, opts: Optional[ResourceOptions] = None, keepers: Optional[Mapping[str, Any]] = None)
func NewRandomUuid(ctx *Context, name string, args *RandomUuidArgs, opts ...ResourceOption) (*RandomUuid, error)
public RandomUuid(string name, RandomUuidArgs? args = null, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args RandomUuidArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
opts ResourceOptions
A bag of options that control this resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args RandomUuidArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args RandomUuidArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

RandomUuid Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.

Inputs

The RandomUuid resource accepts the following input properties:

Keepers Dictionary<string, object>

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

Keepers map[string]interface{}

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

keepers {[key: string]: any}

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

keepers Mapping[str, Any]

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

Outputs

All input properties are implicitly available as output properties. Additionally, the RandomUuid resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Result string

The generated uuid presented in string format.

Id string
The provider-assigned unique ID for this managed resource.
Result string

The generated uuid presented in string format.

id string
The provider-assigned unique ID for this managed resource.
result string

The generated uuid presented in string format.

id str
The provider-assigned unique ID for this managed resource.
result str

The generated uuid presented in string format.

Look up an Existing RandomUuid Resource

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

public static get(name: string, id: Input<ID>, state?: RandomUuidState, opts?: CustomResourceOptions): RandomUuid
@staticmethod
def get(resource_name: str, id: str, opts: Optional[ResourceOptions] = None, keepers: Optional[Mapping[str, Any]] = None, result: Optional[str] = None) -> RandomUuid
func GetRandomUuid(ctx *Context, name string, id IDInput, state *RandomUuidState, opts ...ResourceOption) (*RandomUuid, error)
public static RandomUuid Get(string name, Input<string> id, RandomUuidState? state, CustomResourceOptions? opts = null)
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.

The following state arguments are supported:

Keepers Dictionary<string, object>

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

Result string

The generated uuid presented in string format.

Keepers map[string]interface{}

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

Result string

The generated uuid presented in string format.

keepers {[key: string]: any}

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

result string

The generated uuid presented in string format.

keepers Mapping[str, Any]

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

result str

The generated uuid presented in string format.

Import

Random UUID’s can be imported. This can be used to replace a config value with a value interpolated from the random provider without experiencing diffs. Example

 $ pulumi import random:index/randomUuid:RandomUuid main aabbccdd-eeff-0011-2233-445566778899

Package Details

Repository
https://github.com/pulumi/pulumi-random
License
Apache-2.0
Notes
This Pulumi package is based on the random Terraform Provider.