RandomPassword
Note: Requires random provider version >= 2.2.0
Identical to random.RandomString 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. Read more about sensitive data in state.
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 = password.Result,
});
}
}
package main
import (
"fmt"
"github.com/pulumi/pulumi-aws/sdk/v3/go/aws/rds"
"github.com/pulumi/pulumi-random/sdk/v3/go/random"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
password, 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: 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=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: password.result,
});
Create a RandomPassword Resource
new RandomPassword(name: string, args: RandomPasswordArgs, opts?: CustomResourceOptions);
def RandomPassword(resource_name: str, opts: Optional[ResourceOptions] = None, keepers: Optional[Mapping[str, Any]] = None, length: Optional[int] = None, lower: Optional[bool] = None, min_lower: Optional[int] = None, min_numeric: Optional[int] = None, min_special: Optional[int] = None, min_upper: Optional[int] = None, number: Optional[bool] = None, override_special: Optional[str] = None, special: Optional[bool] = None, upper: Optional[bool] = 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:
- Length int
The length of the string desired.
- Keepers Dictionary<string, object>
Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.
- Lower bool
Include lowercase alphabet characters in the result.
- Min
Lower int Minimum number of lowercase alphabet characters in the result.
- Min
Numeric int Minimum number of numeric characters in the result.
- Min
Special int Minimum number of special characters in the result.
- Min
Upper int Minimum number of uppercase alphabet characters in the result.
- Number bool
Include numeric characters in the result.
- Override
Special string Supply your own list of special characters to use for string generation. This overrides the default character list in the special argument. The
special
argument must still be set to true for any overwritten characters to be used in generation.- Special bool
Include special characters in the result. These are
!@#$%&*()-_=+[]{}<>:?
- Upper bool
Include uppercase alphabet characters in the result.
- Length int
The length of the string desired.
- Keepers map[string]interface{}
Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.
- Lower bool
Include lowercase alphabet characters in the result.
- Min
Lower int Minimum number of lowercase alphabet characters in the result.
- Min
Numeric int Minimum number of numeric characters in the result.
- Min
Special int Minimum number of special characters in the result.
- Min
Upper int Minimum number of uppercase alphabet characters in the result.
- Number bool
Include numeric characters in the result.
- Override
Special string Supply your own list of special characters to use for string generation. This overrides the default character list in the special argument. The
special
argument must still be set to true for any overwritten characters to be used in generation.- Special bool
Include special characters in the result. These are
!@#$%&*()-_=+[]{}<>:?
- Upper bool
Include uppercase alphabet characters in the result.
- length number
The length of the string desired.
- keepers {[key: string]: any}
Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.
- lower boolean
Include lowercase alphabet characters in the result.
- min
Lower number Minimum number of lowercase alphabet characters in the result.
- min
Numeric number Minimum number of numeric characters in the result.
- min
Special number Minimum number of special characters in the result.
- min
Upper number Minimum number of uppercase alphabet characters in the result.
- number boolean
Include numeric characters in the result.
- override
Special string Supply your own list of special characters to use for string generation. This overrides the default character list in the special argument. The
special
argument must still be set to true for any overwritten characters to be used in generation.- special boolean
Include special characters in the result. These are
!@#$%&*()-_=+[]{}<>:?
- upper boolean
Include uppercase alphabet characters in the result.
- length int
The length of the string desired.
- keepers Mapping[str, Any]
Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.
- lower bool
Include lowercase alphabet characters in the result.
- min_
lower int Minimum number of lowercase alphabet characters in the result.
- min_
numeric int Minimum number of numeric characters in the result.
- min_
special int Minimum number of special characters in the result.
- min_
upper int Minimum number of uppercase alphabet characters in the result.
- number bool
Include numeric characters in the result.
- override_
special str Supply your own list of special characters to use for string generation. This overrides the default character list in the special argument. The
special
argument must still be set to true for any overwritten characters to be used in generation.- special bool
Include special characters in the result. These are
!@#$%&*()-_=+[]{}<>:?
- upper bool
Include uppercase alphabet characters in the result.
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): RandomPassword
@staticmethod
def get(resource_name: str, id: str, opts: Optional[ResourceOptions] = None, keepers: Optional[Mapping[str, Any]] = None, length: Optional[int] = None, lower: Optional[bool] = None, min_lower: Optional[int] = None, min_numeric: Optional[int] = None, min_special: Optional[int] = None, min_upper: Optional[int] = None, number: Optional[bool] = None, override_special: Optional[str] = None, result: Optional[str] = None, special: Optional[bool] = None, upper: Optional[bool] = None) -> RandomPassword
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:
- Keepers Dictionary<string, object>
Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.
- Length int
The length of the string desired.
- Lower bool
Include lowercase alphabet characters in the result.
- Min
Lower int Minimum number of lowercase alphabet characters in the result.
- Min
Numeric int Minimum number of numeric characters in the result.
- Min
Special int Minimum number of special characters in the result.
- Min
Upper int Minimum number of uppercase alphabet characters in the result.
- Number bool
Include numeric characters in the result.
- Override
Special string Supply your own list of special characters to use for string generation. This overrides the default character list in the special argument. The
special
argument must still be set to true for any overwritten characters to be used in generation.- Result string
The generated random string.
- Special bool
Include special characters in the result. These are
!@#$%&*()-_=+[]{}<>:?
- Upper bool
Include uppercase alphabet characters in the result.
- Keepers map[string]interface{}
Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.
- Length int
The length of the string desired.
- Lower bool
Include lowercase alphabet characters in the result.
- Min
Lower int Minimum number of lowercase alphabet characters in the result.
- Min
Numeric int Minimum number of numeric characters in the result.
- Min
Special int Minimum number of special characters in the result.
- Min
Upper int Minimum number of uppercase alphabet characters in the result.
- Number bool
Include numeric characters in the result.
- Override
Special string Supply your own list of special characters to use for string generation. This overrides the default character list in the special argument. The
special
argument must still be set to true for any overwritten characters to be used in generation.- Result string
The generated random string.
- Special bool
Include special characters in the result. These are
!@#$%&*()-_=+[]{}<>:?
- Upper bool
Include uppercase alphabet characters in the result.
- keepers {[key: string]: any}
Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.
- length number
The length of the string desired.
- lower boolean
Include lowercase alphabet characters in the result.
- min
Lower number Minimum number of lowercase alphabet characters in the result.
- min
Numeric number Minimum number of numeric characters in the result.
- min
Special number Minimum number of special characters in the result.
- min
Upper number Minimum number of uppercase alphabet characters in the result.
- number boolean
Include numeric characters in the result.
- override
Special string Supply your own list of special characters to use for string generation. This overrides the default character list in the special argument. The
special
argument must still be set to true for any overwritten characters to be used in generation.- result string
The generated random string.
- special boolean
Include special characters in the result. These are
!@#$%&*()-_=+[]{}<>:?
- upper boolean
Include uppercase alphabet characters in the result.
- keepers Mapping[str, Any]
Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.
- length int
The length of the string desired.
- lower bool
Include lowercase alphabet characters in the result.
- min_
lower int Minimum number of lowercase alphabet characters in the result.
- min_
numeric int Minimum number of numeric characters in the result.
- min_
special int Minimum number of special characters in the result.
- min_
upper int Minimum number of uppercase alphabet characters in the result.
- number bool
Include numeric characters in the result.
- override_
special str Supply your own list of special characters to use for string generation. This overrides the default character list in the special argument. The
special
argument must still be set to true for any overwritten characters to be used in generation.- result str
The generated random string.
- special bool
Include special characters in the result. These are
!@#$%&*()-_=+[]{}<>:?
- upper bool
Include uppercase alphabet characters in the result.
Import
Random Password can be imported by specifying the value of the string
$ pulumi import random:index/randomPassword:RandomPassword password securepassword
Package Details
- Repository
- https://github.com/pulumi/pulumi-random
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
random
Terraform Provider.