Skip to main content

Search the Dev Center

Search tutorials, templates, examples, and more.

Generate secure random passwords to use in deployments

Generate secure random passwords to use in deployments

This example lives in the pulumi/examples repository. Check out just this directory to use it:

Get started with this example
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examples
git -C pulumi-examples sparse-checkout set random-yaml
cd pulumi-examples/random-yaml

The Random package provides resources with outputs that are random IDs, passwords, or other data.

Prerequisites#

  1. Install Pulumi

Deploying the example#

  1. Create a new stack:

    Terminal window
    pulumi stack init dev
  2. Install required plugins:

    Terminal window
    pulumi plugin install resource random 4.3.1
  3. Run pulumi up to preview and deploy changes. After the preview is shown you will be prompted if you want to continue or not.

    Terminal window
    pulumi up
    Updating (dev)
    Type Name Status
    + pulumi:pulumi:Stack random-dev created
    + └─ random:index:RandomPassword randomPassword created
    Outputs:
    password: "[secret]"
    Resources:
    + 2 created
  4. To see the resources that were created, run pulumi stack output:

    Terminal window
    pulumi stack output --show-secrets
    Current stack outputs (1):
    OUTPUT VALUE
    password ...

Cleaning up#

Once you’re finished experimenting, destroy your stack and remove it to avoid incurring any additional cost:

Terminal window
pulumi destroy
pulumi stack rm

Related

The infrastructure as code platform for any cloud.