aws-cdk-lib.aws_rds.DatabaseInstanceBase

class DatabaseInstanceBase

LanguageType name
.NETAmazon.CDK.AWS.RDS.DatabaseInstanceBase
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsrds#DatabaseInstanceBase
Javasoftware.amazon.awscdk.services.rds.DatabaseInstanceBase
Pythonaws_cdk.aws_rds.DatabaseInstanceBase
TypeScript (source)aws-cdk-lib » aws_rds » DatabaseInstanceBase

Implements IConstruct, IDependable, IResource, IDatabaseInstance, IConnectable, ISecretAttachmentTarget

Extends Resource

Implemented by DatabaseInstance, DatabaseInstanceFromSnapshot, DatabaseInstanceReadReplica

A new or imported database instance.

Example

// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_ec2 as ec2 } from 'aws-cdk-lib';
import { aws_rds as rds } from 'aws-cdk-lib';

declare const instanceEngine: rds.IInstanceEngine;
declare const securityGroup: ec2.SecurityGroup;
const databaseInstanceBase = rds.DatabaseInstanceBase.fromDatabaseInstanceAttributes(this, 'MyDatabaseInstanceBase', {
  instanceEndpointAddress: 'instanceEndpointAddress',
  instanceIdentifier: 'instanceIdentifier',
  port: 123,
  securityGroups: [securityGroup],

  // the properties below are optional
  engine: instanceEngine,
  instanceResourceId: 'instanceResourceId',
});

Initializer

new DatabaseInstanceBase(scope: Construct, id: string, props?: ResourceProps)

Parameters

  • scope Construct
  • id string
  • props ResourceProps

Properties

NameTypeDescription
connectionsConnectionsAccess to network connections.
dbInstanceEndpointAddressstringThe instance endpoint address.
dbInstanceEndpointPortstringThe instance endpoint port.
envResourceEnvironmentThe environment this resource belongs to.
instanceArnstringThe instance arn.
instanceEndpointEndpointThe instance endpoint.
instanceIdentifierstringThe instance identifier.
nodeNodeThe tree node.
stackStackThe stack in which this resource is defined.
enableIamAuthentication?boolean
engine?IInstanceEngineThe engine of this database Instance.
instanceResourceId?stringThe AWS Region-unique, immutable identifier for the DB instance.

connections

Type: Connections

Access to network connections.


dbInstanceEndpointAddress

Type: string

The instance endpoint address.


dbInstanceEndpointPort

Type: string

The instance endpoint port.


env

Type: ResourceEnvironment

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.


instanceArn

Type: string

The instance arn.


instanceEndpoint

Type: Endpoint

The instance endpoint.


instanceIdentifier

Type: string

The instance identifier.


node

Type: Node

The tree node.


stack

Type: Stack

The stack in which this resource is defined.


enableIamAuthentication?

Type: boolean (optional)


engine?

Type: IInstanceEngine (optional)

The engine of this database Instance.

May be not known for imported Instances if it wasn't provided explicitly, or for read replicas.


instanceResourceId?

Type: string (optional)

The AWS Region-unique, immutable identifier for the DB instance.

This identifier is found in AWS CloudTrail log entries whenever the AWS KMS key for the DB instance is accessed.

Methods

NameDescription
addProxy(id, options)Add a new db proxy to this instance.
applyRemovalPolicy(policy)Apply the given removal policy to this resource.
asSecretAttachmentTarget()Renders the secret attachment target specifications.
grantConnect(grantee, dbUser?)Grant the given identity connection access to the database.
metric(metricName, props?)Return the given named metric for this DBInstance.
metricCPUUtilization(props?)The percentage of CPU utilization.
metricDatabaseConnections(props?)The number of database connections in use.
metricFreeStorageSpace(props?)The amount of available storage space.
metricFreeableMemory(props?)The amount of available random access memory.
metricReadIOPS(props?)The average number of disk write I/O operations per second.
metricWriteIOPS(props?)The average number of disk read I/O operations per second.
onEvent(id, options?)Defines a CloudWatch event rule which triggers for instance events.
toString()Returns a string representation of this construct.
static fromDatabaseInstanceAttributes(scope, id, attrs)Import an existing database instance.

addProxy(id, options)

public addProxy(id: string, options: DatabaseProxyOptions): DatabaseProxy

Parameters

  • id string
  • options DatabaseProxyOptions

Returns

  • DatabaseProxy

Add a new db proxy to this instance.


applyRemovalPolicy(policy)

public applyRemovalPolicy(policy: RemovalPolicy): void

Parameters

  • policy RemovalPolicy

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).


asSecretAttachmentTarget()

public asSecretAttachmentTarget(): SecretAttachmentTargetProps

Returns

  • SecretAttachmentTargetProps

Renders the secret attachment target specifications.


grantConnect(grantee, dbUser?)

public grantConnect(grantee: IGrantable, dbUser?: string): Grant

Parameters

  • grantee IGrantable
  • dbUser string

Returns

  • Grant

Grant the given identity connection access to the database.


metric(metricName, props?)

public metric(metricName: string, props?: MetricOptions): Metric

Parameters

  • metricName string
  • props MetricOptions

Returns

  • Metric

Return the given named metric for this DBInstance.


metricCPUUtilization(props?)

public metricCPUUtilization(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

The percentage of CPU utilization.

Average over 5 minutes


metricDatabaseConnections(props?)

public metricDatabaseConnections(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

The number of database connections in use.

Average over 5 minutes


metricFreeStorageSpace(props?)

public metricFreeStorageSpace(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

The amount of available storage space.

Average over 5 minutes


metricFreeableMemory(props?)

public metricFreeableMemory(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

The amount of available random access memory.

Average over 5 minutes


metricReadIOPS(props?)

public metricReadIOPS(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

The average number of disk write I/O operations per second.

Average over 5 minutes


metricWriteIOPS(props?)

public metricWriteIOPS(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

The average number of disk read I/O operations per second.

Average over 5 minutes


onEvent(id, options?)

public onEvent(id: string, options?: OnEventOptions): Rule

Parameters

  • id string
  • options OnEventOptions

Returns

  • Rule

Defines a CloudWatch event rule which triggers for instance events.

Use rule.addEventPattern(pattern) to specify a filter.


toString()

public toString(): string

Returns

  • string

Returns a string representation of this construct.


static fromDatabaseInstanceAttributes(scope, id, attrs)

public static fromDatabaseInstanceAttributes(scope: Construct, id: string, attrs: DatabaseInstanceAttributes): IDatabaseInstance

Parameters

  • scope Construct
  • id string
  • attrs DatabaseInstanceAttributes

Returns

  • IDatabaseInstance

Import an existing database instance.