Interface SecretStringGenerator
- All Superinterfaces:
software.amazon.jsii.JsiiSerializable
- All Known Implementing Classes:
SecretStringGenerator.Jsii$Proxy
@Generated(value="jsii-pacmak/1.116.0 (build 0eddcff)",
date="2025-10-29T11:15:48.528Z")
@Stability(Stable)
public interface SecretStringGenerator
extends software.amazon.jsii.JsiiSerializable
Configuration to generate secrets such as passwords automatically.
Example:
IVpc vpc;
DatabaseInstance instance1 = DatabaseInstance.Builder.create(this, "PostgresInstance1")
.engine(DatabaseInstanceEngine.POSTGRES)
// Generate the secret with admin username `postgres` and random password
.credentials(Credentials.fromGeneratedSecret("postgres"))
.vpc(vpc)
.build();
// Templated secret with username and password fields
Secret templatedSecret = Secret.Builder.create(this, "TemplatedSecret")
.generateSecretString(SecretStringGenerator.builder()
.secretStringTemplate(JSON.stringify(Map.of("username", "postgres")))
.generateStringKey("password")
.excludeCharacters("/@\"")
.build())
.build();
// Using the templated secret as credentials
DatabaseInstance instance2 = DatabaseInstance.Builder.create(this, "PostgresInstance2")
.engine(DatabaseInstanceEngine.POSTGRES)
.credentials(Map.of(
"username", templatedSecret.secretValueFromJson("username").toString(),
"password", templatedSecret.secretValueFromJson("password")))
.vpc(vpc)
.build();
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classA builder forSecretStringGeneratorstatic final classAn implementation forSecretStringGenerator -
Method Summary
Modifier and TypeMethodDescriptionbuilder()default StringA string that includes characters that shouldn't be included in the generated password.default BooleanSpecifies that the generated password shouldn't include lowercase letters.default BooleanSpecifies that the generated password shouldn't include digits.default BooleanSpecifies that the generated password shouldn't include punctuation characters.default BooleanSpecifies that the generated password shouldn't include uppercase letters.default StringThe JSON key name that's used to add the generated password to the JSON structure specified by thesecretStringTemplateparameter.default BooleanSpecifies that the generated password can include the space character.default NumberThe desired length of the generated password.default BooleanSpecifies whether the generated password must include at least one of every allowed character type.default StringA properly structured JSON string that the generated password can be added to.Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Method Details
-
getExcludeCharacters
A string that includes characters that shouldn't be included in the generated password.The string can be a minimum of
0and a maximum of4096characters long.Default: no exclusions
-
getExcludeLowercase
Specifies that the generated password shouldn't include lowercase letters.Default: false
-
getExcludeNumbers
Specifies that the generated password shouldn't include digits.Default: false
-
getExcludePunctuation
Specifies that the generated password shouldn't include punctuation characters.Default: false
-
getExcludeUppercase
Specifies that the generated password shouldn't include uppercase letters.Default: false
-
getGenerateStringKey
The JSON key name that's used to add the generated password to the JSON structure specified by thesecretStringTemplateparameter.If you specify
generateStringKeythensecretStringTemplatemust be also be specified. -
getIncludeSpace
Specifies that the generated password can include the space character.Default: false
-
getPasswordLength
The desired length of the generated password.Default: 32
-
getRequireEachIncludedType
Specifies whether the generated password must include at least one of every allowed character type.Default: true
-
getSecretStringTemplate
A properly structured JSON string that the generated password can be added to.The
generateStringKeyis 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 specifysecretStringTemplatethengenerateStringKeymust be also be specified. -
builder
- Returns:
- a
SecretStringGenerator.BuilderofSecretStringGenerator
-