Random String Args
data class RandomStringArgs(val keepers: Output<Map<String, String>>? = null, val length: Output<Int>? = null, val lower: Output<Boolean>? = null, val minLower: Output<Int>? = null, val minNumeric: Output<Int>? = null, val minSpecial: Output<Int>? = null, val minUpper: Output<Int>? = null, val number: Output<Boolean>? = null, val numeric: Output<Boolean>? = null, val overrideSpecial: Output<String>? = null, val special: Output<Boolean>? = null, val upper: Output<Boolean>? = null) : ConvertibleToJava<RandomStringArgs>
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 random_id, for sensitive random values please use random_password.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as random from "@pulumi/random";
const random = new random.RandomString("random", {
length: 16,
special: true,
overrideSpecial: "/@£$",
});
Content copied to clipboard
import pulumi
import pulumi_random as random
random = random.RandomString("random",
length=16,
special=True,
override_special="/@£$")
Content copied to clipboard
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Random = Pulumi.Random;
return await Deployment.RunAsync(() =>
{
var random = new Random.RandomString("random", new()
{
Length = 16,
Special = true,
OverrideSpecial = "/@£$",
});
});
Content copied to clipboard
package main
import (
"github.com/pulumi/pulumi-random/sdk/v4/go/random"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := random.NewRandomString(ctx, "random", &random.RandomStringArgs{
Length: pulumi.Int(16),
Special: pulumi.Bool(true),
OverrideSpecial: pulumi.String("/@£$"),
})
if err != nil {
return err
}
return nil
})
}
Content copied to clipboard
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.random.RandomString;
import com.pulumi.random.RandomStringArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var random = new RandomString("random", RandomStringArgs.builder()
.length(16)
.special(true)
.overrideSpecial("/@£$")
.build());
}
}
Content copied to clipboard
resources:
random:
type: random:RandomString
properties:
length: 16
special: true
overrideSpecial: /@£$
Content copied to clipboard
Import
You can import external strings into your Pulumi programs as RandomString resources as follows:
$ import random:index/randomString:RandomString newString myspecialdata
<break>```
This command will encode the `myspecialdata` token in Pulumi state and generate a code suggestion to
include a new RandomString resource in your Pulumi program. Include the suggested code and do a
`pulumi up`. Your data is now stored in Pulumi, and you can reference it in your Pulumi program as
`newString.result`.
If the data needs to be stored securily as a secret, consider using the RandomPassword resource
instead.
@property keepers Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.
@property length The length of the string desired. The minimum value for length is 1 and, length must also be >= (`min_upper` + `min_lower` + `min_numeric` + `min_special`).
@property lower Include lowercase alphabet characters in the result. Default value is `true`.
@property minLower Minimum number of lowercase alphabet characters in the result. Default value is `0`.
@property minNumeric Minimum number of numeric characters in the result. Default value is `0`.
@property minSpecial Minimum number of special characters in the result. Default value is `0`.
@property minUpper Minimum number of uppercase alphabet characters in the result. Default value is `0`.
@property number Include numeric characters in the result. Default value is `true`. If `number`, `upper`, `lower`, and `special` are all configured, at least one of them must be set to `true`. **NOTE**: This is deprecated, use `numeric` instead.
@property numeric Include numeric characters in the result. Default value is `true`. If `numeric`, `upper`, `lower`, and `special` are all configured, at least one of them must be set to `true`.
@property overrideSpecial 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.
@property special Include special characters in the result. These are `!@#$%&*()-_=+[]{}<>:?`. Default value is `true`.
@property upper Include uppercase alphabet characters in the result. Default value is `true`.
Content copied to clipboard
Constructors
Link copied to clipboard
constructor(keepers: Output<Map<String, String>>? = null, length: Output<Int>? = null, lower: Output<Boolean>? = null, minLower: Output<Int>? = null, minNumeric: Output<Int>? = null, minSpecial: Output<Int>? = null, minUpper: Output<Int>? = null, number: Output<Boolean>? = null, numeric: Output<Boolean>? = null, overrideSpecial: Output<String>? = null, special: Output<Boolean>? = null, upper: Output<Boolean>? = null)