CredentialsBaseOptions Struct
Base options for creating Credentials.
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.DatabaseInstance(this, 'InstanceWithCustomizedSecret', {
engine,
vpc,
credentials: rds.Credentials.fromGeneratedSecret('postgres', {
secretName: 'my-cool-name',
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.DatabaseInstance(self, "InstanceWithCustomizedSecret",
engine=engine,
vpc=vpc,
credentials=rds.Credentials.from_generated_secret("postgres",
secret_name="my-cool-name",
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");
DatabaseInstance.Builder.create(this, "InstanceWithCustomizedSecret")
.engine(engine)
.vpc(vpc)
.credentials(Credentials.fromGeneratedSecret("postgres", CredentialsBaseOptions.builder()
.secretName("my-cool-name")
.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 DatabaseInstance(this, "InstanceWithCustomizedSecret", new DatabaseInstanceProps {
Engine = engine,
Vpc = vpc,
Credentials = Credentials.FromGeneratedSecret("postgres", new CredentialsBaseOptions {
SecretName = "my-cool-name",
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.NewDatabaseInstance(this, jsii.String("InstanceWithCustomizedSecret"), &DatabaseInstanceProps{
Engine: Engine,
Vpc: Vpc,
Credentials: rds.Credentials_FromGeneratedSecret(jsii.String("postgres"), &CredentialsBaseOptions{
SecretName: jsii.String("my-cool-name"),
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 (" %+~`#$&*()|[]{}:;<>?!'/@"\")
Has no effect if password has been provided.
replicaRegionsoptionalReplicaRegion[]replica_regionsoptionaltyping.List[ReplicaRegion]replicaRegionsoptionalList<ReplicaRegion>ReplicaRegionsoptionalReplicaRegion[]ReplicaRegionsoptional*[]ReplicaRegion#A list of regions where to replicate this secret.
Default: Secret is not replicated
secretNameoptionalstringsecret_nameoptionalstrsecretNameoptionalStringSecretNameoptionalstringSecretNameoptional*string#The name of the secret.
Default: A name is generated by CloudFormation.