RandomString
The resource random.RandomString generates a random permutation of alphanumeric
characters and optionally special characters.
This resource does use a cryptographic random number generator.
Historically this resource’s intended usage has been ambiguous as the original example
used it in a password. For backwards compatibility it will
continue to exist. For unique ids please use the random.RandomId resource, for sensitive
random values please use the random.RandomPassword resource.
Example Usage
using Pulumi;
using Random = Pulumi.Random;
class MyStack : Stack
{
public MyStack()
{
var random = new Random.RandomString("random", new Random.RandomStringArgs
{
Length = 16,
OverrideSpecial = "/@£$",
Special = true,
});
}
}
package main
import (
"fmt"
"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.NewRandomString(ctx, "random", &random.RandomStringArgs{
Length: pulumi.Int(16),
OverrideSpecial: pulumi.String(fmt.Sprintf("%v%v", "/@£", "$")),
Special: pulumi.Bool(true),
})
if err != nil {
return err
}
return nil
})
}import pulumi
import pulumi_random as random
random = random.RandomString("random",
length=16,
override_special="/@£$",
special=True)import * as pulumi from "@pulumi/pulumi";
import * as random from "@pulumi/random";
const randomRandomString = new random.RandomString("random", {
length: 16,
overrideSpecial: "/@£$",
special: true,
});Create a RandomString Resource
new RandomString(name: string, args: RandomStringArgs, opts?: CustomResourceOptions);def RandomString(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 NewRandomString(ctx *Context, name string, args RandomStringArgs, opts ...ResourceOption) (*RandomString, error)public RandomString(string name, RandomStringArgs args, CustomResourceOptions? opts = null)- name string
- The unique name of the resource.
- args RandomStringArgs
- 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 RandomStringArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args RandomStringArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
RandomString Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.
Inputs
The RandomString 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 a new id to be generated.
- Lower bool
(default true) Include lowercase alphabet characters in random string.
- Min
Lower int (default 0) Minimum number of lowercase alphabet characters in random string.
- Min
Numeric int (default 0) Minimum number of numeric characters in random string.
- Min
Special int (default 0) Minimum number of special characters in random string.
- Min
Upper int (default 0) Minimum number of uppercase alphabet characters in random string.
- Number bool
(default true) Include numeric characters in random string.
- 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
(default true) Include special characters in random string. These are
!@#$%&*()-_=+[]{}<>:?- Upper bool
(default true) Include uppercase alphabet characters in random string.
- Length int
The length of the string desired
- Keepers map[string]interface{}
Arbitrary map of values that, when changed, will trigger a new id to be generated.
- Lower bool
(default true) Include lowercase alphabet characters in random string.
- Min
Lower int (default 0) Minimum number of lowercase alphabet characters in random string.
- Min
Numeric int (default 0) Minimum number of numeric characters in random string.
- Min
Special int (default 0) Minimum number of special characters in random string.
- Min
Upper int (default 0) Minimum number of uppercase alphabet characters in random string.
- Number bool
(default true) Include numeric characters in random string.
- 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
(default true) Include special characters in random string. These are
!@#$%&*()-_=+[]{}<>:?- Upper bool
(default true) Include uppercase alphabet characters in random string.
- length number
The length of the string desired
- keepers {[key: string]: any}
Arbitrary map of values that, when changed, will trigger a new id to be generated.
- lower boolean
(default true) Include lowercase alphabet characters in random string.
- min
Lower number (default 0) Minimum number of lowercase alphabet characters in random string.
- min
Numeric number (default 0) Minimum number of numeric characters in random string.
- min
Special number (default 0) Minimum number of special characters in random string.
- min
Upper number (default 0) Minimum number of uppercase alphabet characters in random string.
- number boolean
(default true) Include numeric characters in random string.
- 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
(default true) Include special characters in random string. These are
!@#$%&*()-_=+[]{}<>:?- upper boolean
(default true) Include uppercase alphabet characters in random string.
- length float
The length of the string desired
- keepers Dict[str, Any]
Arbitrary map of values that, when changed, will trigger a new id to be generated.
- lower bool
(default true) Include lowercase alphabet characters in random string.
- min_
lower float (default 0) Minimum number of lowercase alphabet characters in random string.
- min_
numeric float (default 0) Minimum number of numeric characters in random string.
- min_
special float (default 0) Minimum number of special characters in random string.
- min_
upper float (default 0) Minimum number of uppercase alphabet characters in random string.
- number bool
(default true) Include numeric characters in random string.
- 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
(default true) Include special characters in random string. These are
!@#$%&*()-_=+[]{}<>:?- upper bool
(default true) Include uppercase alphabet characters in random string.
Outputs
All input properties are implicitly available as output properties. Additionally, the RandomString resource produces the following output properties:
Look up an Existing RandomString Resource
Get an existing RandomString 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?: RandomStringState, opts?: CustomResourceOptions): RandomStringstatic 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 GetRandomString(ctx *Context, name string, id IDInput, state *RandomStringState, opts ...ResourceOption) (*RandomString, error)public static RandomString Get(string name, Input<string> id, RandomStringState? 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 a new id to be generated.
- Length int
The length of the string desired
- Lower bool
(default true) Include lowercase alphabet characters in random string.
- Min
Lower int (default 0) Minimum number of lowercase alphabet characters in random string.
- Min
Numeric int (default 0) Minimum number of numeric characters in random string.
- Min
Special int (default 0) Minimum number of special characters in random string.
- Min
Upper int (default 0) Minimum number of uppercase alphabet characters in random string.
- Number bool
(default true) Include numeric characters in random string.
- 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
Random string generated.
- Special bool
(default true) Include special characters in random string. These are
!@#$%&*()-_=+[]{}<>:?- Upper bool
(default true) Include uppercase alphabet characters in random string.
- Keepers map[string]interface{}
Arbitrary map of values that, when changed, will trigger a new id to be generated.
- Length int
The length of the string desired
- Lower bool
(default true) Include lowercase alphabet characters in random string.
- Min
Lower int (default 0) Minimum number of lowercase alphabet characters in random string.
- Min
Numeric int (default 0) Minimum number of numeric characters in random string.
- Min
Special int (default 0) Minimum number of special characters in random string.
- Min
Upper int (default 0) Minimum number of uppercase alphabet characters in random string.
- Number bool
(default true) Include numeric characters in random string.
- 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
Random string generated.
- Special bool
(default true) Include special characters in random string. These are
!@#$%&*()-_=+[]{}<>:?- Upper bool
(default true) Include uppercase alphabet characters in random string.
- keepers {[key: string]: any}
Arbitrary map of values that, when changed, will trigger a new id to be generated.
- length number
The length of the string desired
- lower boolean
(default true) Include lowercase alphabet characters in random string.
- min
Lower number (default 0) Minimum number of lowercase alphabet characters in random string.
- min
Numeric number (default 0) Minimum number of numeric characters in random string.
- min
Special number (default 0) Minimum number of special characters in random string.
- min
Upper number (default 0) Minimum number of uppercase alphabet characters in random string.
- number boolean
(default true) Include numeric characters in random string.
- 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
Random string generated.
- special boolean
(default true) Include special characters in random string. These are
!@#$%&*()-_=+[]{}<>:?- upper boolean
(default true) Include uppercase alphabet characters in random string.
- keepers Dict[str, Any]
Arbitrary map of values that, when changed, will trigger a new id to be generated.
- length float
The length of the string desired
- lower bool
(default true) Include lowercase alphabet characters in random string.
- min_
lower float (default 0) Minimum number of lowercase alphabet characters in random string.
- min_
numeric float (default 0) Minimum number of numeric characters in random string.
- min_
special float (default 0) Minimum number of special characters in random string.
- min_
upper float (default 0) Minimum number of uppercase alphabet characters in random string.
- number bool
(default true) Include numeric characters in random string.
- 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
Random string generated.
- special bool
(default true) Include special characters in random string. These are
!@#$%&*()-_=+[]{}<>:?- upper bool
(default true) Include uppercase alphabet characters in random string.
Package Details
- Repository
- https://github.com/pulumi/pulumi-random
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
randomTerraform Provider.