Table of Contents

Class SecretStringGenerator

Namespace
Amazon.CDK.AWS.SecretsManager
Assembly
Amazon.CDK.AWS.SecretsManager.dll

Configuration to generate secrets such as passwords automatically.

public class SecretStringGenerator : ISecretStringGenerator
Inheritance
SecretStringGenerator
Implements
Inherited Members

Examples

// Default secret
            var secret = new Secret(this, "Secret");
            // Using the default secret
            // Using the default secret
            new User(this, "User", new UserProps {
                Password = secret.SecretValue
            });
            // Templated secret
            var templatedSecret = new Secret(this, "TemplatedSecret", new SecretProps {
                GenerateSecretString = new SecretStringGenerator {
                    SecretStringTemplate = JSON.Stringify(new Dictionary<string, string> { { "username", "user" } }),
                    GenerateStringKey = "password"
                }
            });
            // Using the templated secret
            // Using the templated secret
            new User(this, "OtherUser", new UserProps {
                UserName = templatedSecret.SecretValueFromJson("username").ToString(),
                Password = templatedSecret.SecretValueFromJson("password")
            });

Remarks

ExampleMetadata: infused

Constructors

SecretStringGenerator()

public SecretStringGenerator()

Properties

ExcludeCharacters

A string that includes characters that shouldn't be included in the generated password.

public string? ExcludeCharacters { get; set; }

Property Value

string

Remarks

The string can be a minimum of 0 and a maximum of 4096 characters long.

Default: no exclusions

ExcludeLowercase

Specifies that the generated password shouldn't include lowercase letters.

public bool? ExcludeLowercase { get; set; }

Property Value

bool?

Remarks

Default: false

ExcludeNumbers

Specifies that the generated password shouldn't include digits.

public bool? ExcludeNumbers { get; set; }

Property Value

bool?

Remarks

Default: false

ExcludePunctuation

Specifies that the generated password shouldn't include punctuation characters.

public bool? ExcludePunctuation { get; set; }

Property Value

bool?

Remarks

Default: false

ExcludeUppercase

Specifies that the generated password shouldn't include uppercase letters.

public bool? ExcludeUppercase { get; set; }

Property Value

bool?

Remarks

Default: false

GenerateStringKey

The JSON key name that's used to add the generated password to the JSON structure specified by the secretStringTemplate parameter.

public string? GenerateStringKey { get; set; }

Property Value

string

Remarks

If you specify generateStringKey then secretStringTemplate must be also be specified.

IncludeSpace

Specifies that the generated password can include the space character.

public bool? IncludeSpace { get; set; }

Property Value

bool?

Remarks

Default: false

PasswordLength

The desired length of the generated password.

public double? PasswordLength { get; set; }

Property Value

double?

Remarks

Default: 32

RequireEachIncludedType

Specifies whether the generated password must include at least one of every allowed character type.

public bool? RequireEachIncludedType { get; set; }

Property Value

bool?

Remarks

Default: true

SecretStringTemplate

A properly structured JSON string that the generated password can be added to.

public string? SecretStringTemplate { get; set; }

Property Value

string

Remarks

The generateStringKey is combined with the generated random string and inserted into the JSON structure that's specified by this parameter. The merged JSON string is returned as the completed SecretString of the secret. If you specify secretStringTemplate then generateStringKey must be also be specified.