Skip to content
v2.278.0

SnapshotCredentialsFromGeneratedPasswordOptions Struct ​

Options used in the SnapshotCredentials.fromGeneratedPassword method.

Example ​

ts
declare const vpc: ec2.Vpc;
const engine = rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_3 });
const myKey = new kms.Key(this, 'MyKey');

new rds.DatabaseInstanceFromSnapshot(this, 'InstanceFromSnapshotWithCustomizedSecret', {
  engine,
  vpc,
  snapshotIdentifier: 'mySnapshot',
  credentials: rds.SnapshotCredentials.fromGeneratedSecret('username', {
    encryptionKey: myKey,
    excludeCharacters: '!&*^#@()',
    replicaRegions: [{ region: 'eu-west-1' }, { region: 'eu-west-2' }],
  }),
});
python
# vpc: ec2.Vpc

engine = rds.DatabaseInstanceEngine.postgres(version=rds.PostgresEngineVersion.VER_16_3)
my_key = kms.Key(self, "MyKey")

rds.DatabaseInstanceFromSnapshot(self, "InstanceFromSnapshotWithCustomizedSecret",
    engine=engine,
    vpc=vpc,
    snapshot_identifier="mySnapshot",
    credentials=rds.SnapshotCredentials.from_generated_secret("username",
        encryption_key=my_key,
        exclude_characters="!&*^#@()",
        replica_regions=[secretsmanager.ReplicaRegion(region="eu-west-1"), secretsmanager.ReplicaRegion(region="eu-west-2")]
    )
)
java
Vpc vpc;

IInstanceEngine engine = DatabaseInstanceEngine.postgres(PostgresInstanceEngineProps.builder().version(PostgresEngineVersion.VER_16_3).build());
Key myKey = new Key(this, "MyKey");

DatabaseInstanceFromSnapshot.Builder.create(this, "InstanceFromSnapshotWithCustomizedSecret")
        .engine(engine)
        .vpc(vpc)
        .snapshotIdentifier("mySnapshot")
        .credentials(SnapshotCredentials.fromGeneratedSecret("username", SnapshotCredentialsFromGeneratedPasswordOptions.builder()
                .encryptionKey(myKey)
                .excludeCharacters("!&*^#@()")
                .replicaRegions(List.of(ReplicaRegion.builder().region("eu-west-1").build(), ReplicaRegion.builder().region("eu-west-2").build()))
                .build()))
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
Vpc vpc;

var engine = DatabaseInstanceEngine.Postgres(new PostgresInstanceEngineProps { Version = PostgresEngineVersion.VER_16_3 });
var myKey = new Key(this, "MyKey");

new DatabaseInstanceFromSnapshot(this, "InstanceFromSnapshotWithCustomizedSecret", new DatabaseInstanceFromSnapshotProps {
    Engine = engine,
    Vpc = vpc,
    SnapshotIdentifier = "mySnapshot",
    Credentials = SnapshotCredentials.FromGeneratedSecret("username", new SnapshotCredentialsFromGeneratedPasswordOptions {
        EncryptionKey = myKey,
        ExcludeCharacters = "!&*^#@()",
        ReplicaRegions = new [] { new ReplicaRegion { Region = "eu-west-1" }, new ReplicaRegion { Region = "eu-west-2" } }
    })
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var vpc Vpc

engine := rds.DatabaseInstanceEngine_Postgres(&PostgresInstanceEngineProps{
	Version: rds.PostgresEngineVersion_VER_16_3(),
})
myKey := kms.NewKey(this, jsii.String("MyKey"))

rds.NewDatabaseInstanceFromSnapshot(this, jsii.String("InstanceFromSnapshotWithCustomizedSecret"), &DatabaseInstanceFromSnapshotProps{
	Engine: Engine,
	Vpc: Vpc,
	SnapshotIdentifier: jsii.String("mySnapshot"),
	Credentials: rds.SnapshotCredentials_FromGeneratedSecret(jsii.String("username"), &SnapshotCredentialsFromGeneratedPasswordOptions{
		EncryptionKey: myKey,
		ExcludeCharacters: jsii.String("!&*^#@()"),
		ReplicaRegions: []ReplicaRegion{
			&ReplicaRegion{
				Region: jsii.String("eu-west-1"),
			},
			&ReplicaRegion{
				Region: jsii.String("eu-west-2"),
			},
		},
	}),
})

Properties ​

encryptionKeyoptionalIKeyencryption_keyoptionalIKeyencryptionKeyoptionalIKeyEncryptionKeyoptionalIKeyEncryptionKeyoptionalIKey #
KMS encryption key to encrypt the generated secret.

Default: default master key

excludeCharactersoptionalstringexclude_charactersoptionalstrexcludeCharactersoptionalStringExcludeCharactersoptionalstringExcludeCharactersoptional*string #
The characters to exclude from the generated password.

Default: the DatabaseSecret default exclude character set (" %+~`#$&*()|[]{}:;<>?!'/@"\")

replicaRegionsoptionalReplicaRegion[]replica_regionsoptionaltyping.List[ReplicaRegion]replicaRegionsoptionalList<ReplicaRegion>ReplicaRegionsoptionalReplicaRegion[]ReplicaRegionsoptional*[]ReplicaRegion #
A list of regions where to replicate this secret.

Default: Secret is not replicated