Skip to content
v2.277.0

GenerateSecretStringProperty Struct ​

Generates a random password.

We recommend that you specify the maximum length and include every character type that the system you are generating a password for can support.

Required permissions: secretsmanager:GetRandomPassword . For more information, see IAM policy actions for Secrets Manager and Authentication and access control in Secrets Manager .

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_secretsmanager as secretsmanager } from 'aws-cdk-lib';
const generateSecretStringProperty: secretsmanager.CfnSecret.GenerateSecretStringProperty = {
  excludeCharacters: 'excludeCharacters',
  excludeLowercase: false,
  excludeNumbers: false,
  excludePunctuation: false,
  excludeUppercase: false,
  generateStringKey: 'generateStringKey',
  includeSpace: false,
  passwordLength: 123,
  requireEachIncludedType: false,
  secretStringTemplate: 'secretStringTemplate',
};
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_secretsmanager as secretsmanager

generate_secret_string_property = secretsmanager.CfnSecret.GenerateSecretStringProperty(
    exclude_characters="excludeCharacters",
    exclude_lowercase=False,
    exclude_numbers=False,
    exclude_punctuation=False,
    exclude_uppercase=False,
    generate_string_key="generateStringKey",
    include_space=False,
    password_length=123,
    require_each_included_type=False,
    secret_string_template="secretStringTemplate"
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.secretsmanager.*;

GenerateSecretStringProperty generateSecretStringProperty = GenerateSecretStringProperty.builder()
        .excludeCharacters("excludeCharacters")
        .excludeLowercase(false)
        .excludeNumbers(false)
        .excludePunctuation(false)
        .excludeUppercase(false)
        .generateStringKey("generateStringKey")
        .includeSpace(false)
        .passwordLength(123)
        .requireEachIncludedType(false)
        .secretStringTemplate("secretStringTemplate")
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.SecretsManager;

var generateSecretStringProperty = new GenerateSecretStringProperty {
    ExcludeCharacters = "excludeCharacters",
    ExcludeLowercase = false,
    ExcludeNumbers = false,
    ExcludePunctuation = false,
    ExcludeUppercase = false,
    GenerateStringKey = "generateStringKey",
    IncludeSpace = false,
    PasswordLength = 123,
    RequireEachIncludedType = false,
    SecretStringTemplate = "secretStringTemplate"
};
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

generateSecretStringProperty := &GenerateSecretStringProperty{
	ExcludeCharacters: jsii.String("excludeCharacters"),
	ExcludeLowercase: jsii.Boolean(false),
	ExcludeNumbers: jsii.Boolean(false),
	ExcludePunctuation: jsii.Boolean(false),
	ExcludeUppercase: jsii.Boolean(false),
	GenerateStringKey: jsii.String("generateStringKey"),
	IncludeSpace: jsii.Boolean(false),
	PasswordLength: jsii.Number(123),
	RequireEachIncludedType: jsii.Boolean(false),
	SecretStringTemplate: jsii.String("secretStringTemplate"),
}

Properties ​

excludeCharactersoptionalstringexclude_charactersoptionalstrexcludeCharactersoptionalStringExcludeCharactersoptionalstringExcludeCharactersoptional*string#
A string of the characters that you don't want in the password.
excludeLowercaseoptionalboolean | IResolvableexclude_lowercaseoptionaltyping.Union[bool, IResolvable]excludeLowercaseoptionalBooleanExcludeLowercaseoptionalboolExcludeLowercaseoptionalinterface{}#
Specifies whether to exclude lowercase letters from the password.

If you don't include this switch, the password can contain lowercase letters.

excludeNumbersoptionalboolean | IResolvableexclude_numbersoptionaltyping.Union[bool, IResolvable]excludeNumbersoptionalBooleanExcludeNumbersoptionalboolExcludeNumbersoptionalinterface{}#
Specifies whether to exclude numbers from the password.

If you don't include this switch, the password can contain numbers.

excludePunctuationoptionalboolean | IResolvableexclude_punctuationoptionaltyping.Union[bool, IResolvable]excludePunctuationoptionalBooleanExcludePunctuationoptionalboolExcludePunctuationoptionalinterface{}#
Specifies whether to exclude the following punctuation characters from the password: `!

" # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ { | } ~ . If you don't include this switch, the password can contain punctuation.

excludeUppercaseoptionalboolean | IResolvableexclude_uppercaseoptionaltyping.Union[bool, IResolvable]excludeUppercaseoptionalBooleanExcludeUppercaseoptionalboolExcludeUppercaseoptionalinterface{}#
Specifies whether to exclude uppercase letters from the password.

If you don't include this switch, the password can contain uppercase letters.

generateStringKeyoptionalstringgenerate_string_keyoptionalstrgenerateStringKeyoptionalStringGenerateStringKeyoptionalstringGenerateStringKeyoptional*string#
The JSON key name for the key/value pair, where the value is the generated password.

This pair is added to the JSON structure specified by the SecretStringTemplate parameter. If you specify this parameter, then you must also specify SecretStringTemplate .

includeSpaceoptionalboolean | IResolvableinclude_spaceoptionaltyping.Union[bool, IResolvable]includeSpaceoptionalBooleanIncludeSpaceoptionalboolIncludeSpaceoptionalinterface{}#
Specifies whether to include the space character.

If you include this switch, the password can contain space characters.

passwordLengthoptionalnumberpassword_lengthoptionalint | floatpasswordLengthoptionalNumberPasswordLengthoptionaldoublePasswordLengthoptional*float64#
The length of the password.

If you don't include this parameter, the default length is 32 characters.

requireEachIncludedTypeoptionalboolean | IResolvablerequire_each_included_typeoptionaltyping.Union[bool, IResolvable]requireEachIncludedTypeoptionalBooleanRequireEachIncludedTypeoptionalboolRequireEachIncludedTypeoptionalinterface{}#
Specifies whether to include at least one upper and lowercase letter, one number, and one punctuation.

If you don't include this switch, the password contains at least one of every character type.

secretStringTemplateoptionalstringsecret_string_templateoptionalstrsecretStringTemplateoptionalStringSecretStringTemplateoptionalstringSecretStringTemplateoptional*string#
A template that the generated string must match.

When you make a change to this property, a new secret version is created.