Pulumi Random

4.19.2 · active · verified Mon Apr 13

The `pulumi-random` provider enables the safe use of randomness in Pulumi programs, allowing users to generate resource properties, such as names or passwords, that incorporate randomness in a way that aligns with Pulumi's goal state-oriented approach. It avoids constant re-convergence by managing random values within the Pulumi state. The library is actively maintained, with frequent releases, and is currently at version 4.19.2.

Warnings

Install

Imports

Quickstart

This example demonstrates how to create a `RandomPassword` resource with specific length and character requirements. The `keepers` map ensures the password is only regenerated if the values in the map change. The `bcrypt_hash` is exported instead of the raw `result` due to its sensitive nature.

import pulumi
import pulumi_random as random

# Generate a random password for a database user
# The result is treated as sensitive and not displayed in console output
password = random.RandomPassword("db-password",
    length=16,
    special=True,
    override_special="_@%",
    keepers={
        "purpose": "db_user_password"
    }
)

pulumi.export("generated_password_result_hash", password.bcrypt_hash)

view raw JSON →