Class SnapshotCredentials
Credentials to update the password for a DatabaseInstanceFromSnapshot
.
Inheritance
Namespace: Amazon.CDK.AWS.RDS
Assembly: Amazon.CDK.AWS.RDS.dll
Syntax (csharp)
public abstract class SnapshotCredentials : DeputyBase
Syntax (vb)
Public MustInherit Class SnapshotCredentials
Inherits DeputyBase
Remarks
ExampleMetadata: infused
Examples
Vpc vpc;
var engine = DatabaseInstanceEngine.Postgres(new PostgresInstanceEngineProps { Version = PostgresEngineVersion.VER_12_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" } }
})
});
Synopsis
Constructors
SnapshotCredentials() | |
SnapshotCredentials(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
SnapshotCredentials(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
Properties
EncryptionKey | KMS encryption key to encrypt the generated secret. |
ExcludeCharacters | |
GeneratePassword | Whether a new password should be generated. |
Password | The master user password. |
ReplaceOnPasswordCriteriaChanges | Whether to replace the generated secret when the criteria for the password change. |
ReplicaRegions | A list of regions where to replicate the generated secret. |
Secret | Secret used to instantiate this Login. |
Username | The master user name. |
Methods
FromGeneratedPassword(String, ISnapshotCredentialsFromGeneratedPasswordOptions) | Generate a new password for the snapshot, using the existing username and an optional encryption key. |
FromGeneratedSecret(String, ISnapshotCredentialsFromGeneratedPasswordOptions) | Generate a new password for the snapshot, using the existing username and an optional encryption key. |
FromPassword(SecretValue) | Update the snapshot login with an existing password. |
FromSecret(ISecret) | Update the snapshot login with an existing password from a Secret. |
Constructors
SnapshotCredentials()
protected SnapshotCredentials()
SnapshotCredentials(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected SnapshotCredentials(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
SnapshotCredentials(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected SnapshotCredentials(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
Properties
EncryptionKey
KMS encryption key to encrypt the generated secret.
public abstract IKey EncryptionKey { get; }
Property Value
Remarks
Default: - default master key
ExcludeCharacters
public abstract string ExcludeCharacters { get; }
Property Value
System.String
GeneratePassword
Whether a new password should be generated.
public abstract bool GeneratePassword { get; }
Property Value
System.Boolean
Password
The master user password.
public abstract SecretValue Password { get; }
Property Value
Remarks
Do not put passwords in your CDK code directly.
Default: - the existing password from the snapshot
ReplaceOnPasswordCriteriaChanges
Whether to replace the generated secret when the criteria for the password change.
public abstract Nullable<bool> ReplaceOnPasswordCriteriaChanges { get; }
Property Value
System.Nullable<System.Boolean>
Remarks
Default: false
ReplicaRegions
A list of regions where to replicate the generated secret.
public abstract IReplicaRegion[] ReplicaRegions { get; }
Property Value
Remarks
Default: - Secret is not replicated
Secret
Secret used to instantiate this Login.
public abstract ISecret Secret { get; }
Property Value
Remarks
Default: - none
Username
The master user name.
public abstract string Username { get; }
Property Value
System.String
Remarks
Must be the current master user name of the snapshot. It is not possible to change the master user name of a RDS instance.
Default: - the existing username from the snapshot
Methods
FromGeneratedPassword(String, ISnapshotCredentialsFromGeneratedPasswordOptions)
Generate a new password for the snapshot, using the existing username and an optional encryption key.
public static SnapshotCredentials FromGeneratedPassword(string username, ISnapshotCredentialsFromGeneratedPasswordOptions options = null)
Parameters
- username System.String
- options ISnapshotCredentialsFromGeneratedPasswordOptions
Returns
Remarks
Note - The username must match the existing master username of the snapshot.
NOTE: use fromGeneratedSecret()
for new Clusters and Instances. Switching from
fromGeneratedPassword()
to fromGeneratedSecret()
for already deployed Clusters
or Instances will update their master password.
FromGeneratedSecret(String, ISnapshotCredentialsFromGeneratedPasswordOptions)
Generate a new password for the snapshot, using the existing username and an optional encryption key.
public static SnapshotCredentials FromGeneratedSecret(string username, ISnapshotCredentialsFromGeneratedPasswordOptions options = null)
Parameters
- username System.String
- options ISnapshotCredentialsFromGeneratedPasswordOptions
Returns
Remarks
The new credentials are stored in Secrets Manager.
Note - The username must match the existing master username of the snapshot.
FromPassword(SecretValue)
Update the snapshot login with an existing password.
public static SnapshotCredentials FromPassword(SecretValue password)
Parameters
- password SecretValue
Returns
FromSecret(ISecret)
Update the snapshot login with an existing password from a Secret.
public static SnapshotCredentials FromSecret(ISecret secret)
Parameters
- secret ISecret
Returns
Remarks
The Secret must be a JSON string with a password
field:
{
...
"password": <required: password>,
}