Skip to main content

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.

Deploying and running the program#

  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
    Previewing update (dev)
    ...
    Updating (dev)
    View Live: https://app.pulumi.com/.../random/dev/updates/1
    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 ...

Related

The infrastructure as code platform for any cloud.