RandomPassword
Identical to the random.RandomString resource with the exception that the
result is treated as sensitive and, thus, not displayed in console output.
Note: All attributes including the generated password will be stored in the raw state as plain-text.
This resource does use a cryptographic random number generator.
Example Usage
using Pulumi;
using Aws = Pulumi.Aws;
using Random = Pulumi.Random;
class MyStack : Stack
{
public MyStack()
{
var password = new Random.RandomPassword("password", new Random.RandomPasswordArgs
{
Length = 16,
Special = true,
OverrideSpecial = "_%@",
});
var example = new Aws.Rds.Instance("example", new Aws.Rds.InstanceArgs
{
InstanceClass = "db.t3.micro",
AllocatedStorage = 64,
Engine = "mysql",
Username = "someone",
Password = random_string.Password.Result,
});
}
}
package main
import (
"fmt"
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/rds"
"github.com/pulumi/pulumi-random/sdk/v2/go/random"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := random.NewRandomPassword(ctx, "password", &random.RandomPasswordArgs{
Length: pulumi.Int(16),
Special: pulumi.Bool(true),
OverrideSpecial: pulumi.String(fmt.Sprintf("%v%v%v", "_", "%", "@")),
})
if err != nil {
return err
}
_, err = rds.NewInstance(ctx, "example", &rds.InstanceArgs{
InstanceClass: pulumi.String("db.t3.micro"),
AllocatedStorage: pulumi.Int(64),
Engine: pulumi.String("mysql"),
Username: pulumi.String("someone"),
Password: pulumi.String(random_string.Password.Result),
})
if err != nil {
return err
}
return nil
})
}import pulumi
import pulumi_aws as aws
import pulumi_random as random
password = random.RandomPassword("password",
length=16,
special=True,
override_special="_%@")
example = aws.rds.Instance("example",
instance_class="db.t3.micro",
allocated_storage=64,
engine="mysql",
username="someone",
password=random_string["password"]["result"])import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as random from "@pulumi/random";
const password = new random.RandomPassword("password", {
length: 16,
special: true,
overrideSpecial: `_%@`,
});
const example = new aws.rds.Instance("example", {
instanceClass: "db.t3.micro",
allocatedStorage: 64,
engine: "mysql",
username: "someone",
password: random_string.password.result,
});Create a RandomPassword Resource
new RandomPassword(name: string, args: RandomPasswordArgs, opts?: CustomResourceOptions);def RandomPassword(resource_name, opts=None, keepers=None, length=None, lower=None, min_lower=None, min_numeric=None, min_special=None, min_upper=None, number=None, override_special=None, special=None, upper=None, __props__=None);func NewRandomPassword(ctx *Context, name string, args RandomPasswordArgs, opts ...ResourceOption) (*RandomPassword, error)public RandomPassword(string name, RandomPasswordArgs args, CustomResourceOptions? opts = null)- name string
- The unique name of the resource.
- args RandomPasswordArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- opts ResourceOptions
- A bag of options that control this resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args RandomPasswordArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args RandomPasswordArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
RandomPassword Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.
Inputs
The RandomPassword resource accepts the following input properties:
Outputs
All input properties are implicitly available as output properties. Additionally, the RandomPassword resource produces the following output properties:
Look up an Existing RandomPassword Resource
Get an existing RandomPassword resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: RandomPasswordState, opts?: CustomResourceOptions): RandomPasswordstatic get(resource_name, id, opts=None, keepers=None, length=None, lower=None, min_lower=None, min_numeric=None, min_special=None, min_upper=None, number=None, override_special=None, result=None, special=None, upper=None, __props__=None);func GetRandomPassword(ctx *Context, name string, id IDInput, state *RandomPasswordState, opts ...ResourceOption) (*RandomPassword, error)public static RandomPassword Get(string name, Input<string> id, RandomPasswordState? state, CustomResourceOptions? opts = null)- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
The following state arguments are supported:
Package Details
- Repository
- https://github.com/pulumi/pulumi-random
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
randomTerraform Provider.