Registry / devops / pulumi-random

pulumi-random

JSON →
library4.21.1pypypi✓ verified 25d ago

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.

pip install pulumi_random
INSTALL
IMPORT
SIG · PULUMI-RANDOM
P
pulumi-random
devopspythonv4.21.1
Install
6.6s avg
Import
1226ms
Disk
78MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v4.21.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 1.576s · 86.8MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 6.6s · import 0.876s · 73MB
78MB installed
● package 78MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

RandomPassword
✓ from pulumi_random import RandomPassword
✗ import pulumi_random.RandomPassword
Pulumi Python SDKs typically import classes directly from the top-level package or a sub-module like `pulumi_random.index` rather than deeply nested paths for resources.
pulumi_random
✓ import pulumi_random as random
Common convention to alias the provider for brevity.
pulumi
✓ import pulumi

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)
pulumi --version
Debug
Known issues
breakingIn version `v4.18.4`, there was a breaking schema change for the `pulumi:providers:random/terraformConfig` function. The input type of `__self__` changed from `#/resources/pulumi:providers:random` to `#/provider`.
fix
Review and update any explicit references or configurations related to the `terraformConfig` provider function if directly interacting with the provider's schema or low-level internals. Most user-level code should not be directly affected, but custom provider logic or advanced configurations might need adjustment.
affects: v4.18.4 and later
gotchaThe `pulumi-random` provider manages randomness by generating values once during resource creation and then holding them steady until the inputs change. To explicitly trigger recreation of a random value, use the `keepers` input property. Changes to the `keepers` map will force the resource to regenerate its random output.
fix
Use the `keepers` map with arbitrary key/value pairs that represent the dependencies for the random value. If any value in `keepers` changes, the random resource will be recreated. For example, include a version number or a hash of dependent inputs in `keepers`.
affects: All versions
gotchaThe default random results generated by this provider are generally not suitable for cryptographic use unless explicitly stated otherwise (e.g., `RandomPassword` which uses a cryptographic random number generator).
fix
Always check the specific resource documentation (e.g., `RandomPassword`, `RandomBytes`, `RandomId`) if you require cryptographically secure randomness. For general unique identifiers or simple random strings, the provider's resources are sufficient.
affects: All versions
gotchaChoose the appropriate random resource: `RandomString` generates a random alphanumeric string, `RandomPassword` generates a sensitive random string (suitable for passwords and treated as sensitive in Pulumi state), and `RandomId` generates unique identifiers (e.g., for resource names).
fix
Prefer `RandomPassword` for sensitive data that should not be displayed in logs or state, and `RandomId` for unique identifiers that minimize collision risk. Use `RandomString` for non-sensitive, general-purpose random alphanumeric strings.
affects: All versions
gotchaWhen defining dynamic provider resources, if your `Output` object contains more data elements than your `Input` (e.g., a field generated by the provider), these additional output fields might be undefined when attempting to access them later, even if they exist in the state file.
fix
Ensure that if your Pulumi resource outputs need to be used as inputs for subsequent operations, they are explicitly represented or 'predeclared' within the resource's type definition to allow for correct rehydration from the state. Consult the Pulumi dynamic provider documentation for best practices.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pulumi_random'
The `pulumi-random` Python package has not been installed in your Python environment or virtual environment.
fix
Ensure your virtual environment is activated (if used) and install the package using pip: `pip install pulumi_random`
AttributeError: module 'random' has no attribute 'RandomPassword'
You have likely imported the built-in Python `random` module instead of the `pulumi-random` provider's Python package. The Pulumi `pulumi-random` package is imported as `pulumi_random` or aliased as `random`.
fix
Change your import statement to `import pulumi_random as random` or `from pulumi_random import RandomPassword`.
error: Resource type random:index/randomPassword:RandomPassword not found
The Pulumi CLI is unable to find the `pulumi-random` provider plugin. This can happen due to plugin installation issues, version mismatches, or an environment where the plugin is not accessible.
fix
Run `pulumi plugin install resource random --version 4.19.2` (or your desired version) to ensure the provider plugin is correctly installed and registered with Pulumi.
Required attribute is not set. Examine values at 'RandomPassword. Length'
When attempting to import an existing `RandomPassword` (or other random resource) using `pulumi import`, the resource definition in your Pulumi program does not specify all the required input properties (like `length` for `RandomPassword`) that define the existing resource's state. Pulumi needs these properties to accurately represent the imported resource.
fix
Ensure that the `RandomPassword` resource in your Pulumi program has all the necessary arguments (e.g., `length=20`, `special=True`) that match the properties of the *existing* password you are trying to import. You might also need to use `ignore_changes` if certain properties are not strictly managed or known during import.
Upgrade
Version history
4.21.1latest on PyPI · released Jul 22, 2026
Audit
Dependencies
pulumirequiredCore Pulumi SDK required for all Pulumi providers.
pythonrequiredRequires Python 3.9 or newer.
Agent activity
8 hits · last 30 days
node
6
Amazon
1
Resources
pulumi-random — pip install pulumi-random · libregistry