1. Answers
  2. Building a Random UUID with Pulumi

How do I build a random UUID with Pulumi?

In this guide, we will demonstrate how to generate a random UUID. This can be useful in various scenarios, such as creating unique identifiers for your resources. We will use the random_uuid resource to achieve this. The generated UUID is then outputted to be used in your stack.

Let’s dive into the code:

import * as pulumi from "@pulumi/pulumi";
import * as random from "@pulumi/random";

// Generate a random UUID
const example = new random.RandomUuid("example", {keepers: {
    trigger: "recreation-trigger",
}});
export const generatedUuid = example.result;

Key Points:

  • Provider: The random provider is used for generating random values.
  • Resource: The random_uuid resource generates a new UUID each time it is applied.
  • Output: The generated UUID is outputted so it can be referenced in other parts of your stack.

Summary:

In this example, we demonstrated how to generate a random UUID and output it using Pulumi. This simple configuration helps to create unique identifiers dynamically in your infrastructure.

Deploy this code

Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.

Sign up

New to Pulumi?

Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.

Sign up