Class DatabaseInstance
A database instance.
Implements
Inherited Members
Namespace: Amazon.CDK.AWS.RDS
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class DatabaseInstance : DatabaseInstanceBase, IDatabaseInstance, IResource, IConnectable, ISecretAttachmentTarget
Syntax (vb)
Public Class DatabaseInstance
Inherits DatabaseInstanceBase
Implements IDatabaseInstance, IResource, IConnectable, ISecretAttachmentTarget
Remarks
Resource: AWS::RDS::DBInstance
ExampleMetadata: infused
Examples
IVpc vpc;
var instance1 = new DatabaseInstance(this, "PostgresInstance1", new DatabaseInstanceProps {
Engine = DatabaseInstanceEngine.POSTGRES,
// Generate the secret with admin username `postgres` and random password
Credentials = Credentials.FromGeneratedSecret("postgres"),
Vpc = vpc
});
// Templated secret with username and password fields
var templatedSecret = new Secret(this, "TemplatedSecret", new SecretProps {
GenerateSecretString = new SecretStringGenerator {
SecretStringTemplate = JSON.Stringify(new Dictionary<string, string> { { "username", "postgres" } }),
GenerateStringKey = "password",
ExcludeCharacters = "/@\""
}
});
// Using the templated secret as credentials
var instance2 = new DatabaseInstance(this, "PostgresInstance2", new DatabaseInstanceProps {
Engine = DatabaseInstanceEngine.POSTGRES,
Credentials = new Dictionary<string, object> {
{ "username", templatedSecret.SecretValueFromJson("username").ToString() },
{ "password", templatedSecret.SecretValueFromJson("password") }
},
Vpc = vpc
});
Synopsis
Constructors
DatabaseInstance(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
DatabaseInstance(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
DatabaseInstance(Construct, String, IDatabaseInstanceProps) |
Properties
CloudwatchLogGroups | The log group is created when |
Connections | Access to network connections. |
DbInstanceEndpointAddress | The instance endpoint address. |
DbInstanceEndpointPort | The instance endpoint port. |
EnableIamAuthentication | |
Engine | The engine of this database Instance. |
InstanceEndpoint | The instance endpoint. |
InstanceIdentifier | The instance identifier. |
InstanceResourceId | The AWS Region-unique, immutable identifier for the DB instance. |
InstanceType | |
NewCfnProps | |
Secret | The AWS Secrets Manager secret attached to the instance. |
SourceCfnProps | |
Vpc | The VPC where this database instance is deployed. |
VpcPlacement |
Methods
AddRotationMultiUser(String, IRotationMultiUserOptions) | Adds the multi user rotation to this instance. |
AddRotationSingleUser(IRotationSingleUserOptions) | Adds the single user rotation of the master password to this instance. |
GrantConnect(IGrantable, String) | Grant the given identity connection access to the database. |
SetLogRetention() |
Constructors
DatabaseInstance(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected DatabaseInstance(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
DatabaseInstance(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected DatabaseInstance(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
DatabaseInstance(Construct, String, IDatabaseInstanceProps)
public DatabaseInstance(Construct scope, string id, IDatabaseInstanceProps props)
Parameters
- scope Constructs.Construct
- id System.String
- props IDatabaseInstanceProps
Properties
CloudwatchLogGroups
The log group is created when cloudwatchLogsExports
is set.
public virtual IDictionary<string, ILogGroup> CloudwatchLogGroups { get; }
Property Value
System.Collections.Generic.IDictionary<System.String, ILogGroup>
Remarks
Each export value will create a separate log group.
Connections
Access to network connections.
public override Connections_ Connections { get; }
Property Value
Overrides
DbInstanceEndpointAddress
The instance endpoint address.
public override string DbInstanceEndpointAddress { get; }
Property Value
System.String
Overrides
DbInstanceEndpointPort
The instance endpoint port.
public override string DbInstanceEndpointPort { get; }
Property Value
System.String
Overrides
EnableIamAuthentication
protected override Nullable<bool> EnableIamAuthentication { get; set; }
Property Value
System.Nullable<System.Boolean>
Overrides
Engine
The engine of this database Instance.
public override IInstanceEngine Engine { get; }
Property Value
Overrides
Remarks
May be not known for imported Instances if it wasn't provided explicitly, or for read replicas.
InstanceEndpoint
The instance endpoint.
public override Endpoint InstanceEndpoint { get; }
Property Value
Overrides
InstanceIdentifier
The instance identifier.
public override string InstanceIdentifier { get; }
Property Value
System.String
Overrides
InstanceResourceId
The AWS Region-unique, immutable identifier for the DB instance.
public override string InstanceResourceId { get; }
Property Value
System.String
Overrides
Remarks
This identifier is found in AWS CloudTrail log entries whenever the AWS KMS key for the DB instance is accessed.
InstanceType
NewCfnProps
Secret
The AWS Secrets Manager secret attached to the instance.
public virtual ISecret Secret { get; }
Property Value
SourceCfnProps
Vpc
The VPC where this database instance is deployed.
public virtual IVpc Vpc { get; }
Property Value
VpcPlacement
Methods
AddRotationMultiUser(String, IRotationMultiUserOptions)
Adds the multi user rotation to this instance.
public virtual SecretRotation AddRotationMultiUser(string id, IRotationMultiUserOptions options)
Parameters
- id System.String
- options IRotationMultiUserOptions
Returns
AddRotationSingleUser(IRotationSingleUserOptions)
Adds the single user rotation of the master password to this instance.
public virtual SecretRotation AddRotationSingleUser(IRotationSingleUserOptions options = null)
Parameters
- options IRotationSingleUserOptions
the options for the rotation, if you want to override the defaults.
Returns
GrantConnect(IGrantable, String)
Grant the given identity connection access to the database.
public override Grant GrantConnect(IGrantable grantee, string dbUser = null)
Parameters
- grantee IGrantable
the Principal to grant the permissions to.
- dbUser System.String
the name of the database user to allow connecting as to the db instance, or the default database user, obtained from the Secret, if not specified.
Returns
Overrides
SetLogRetention()
protected virtual void SetLogRetention()