class DatabaseInstanceBase
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.RDS.DatabaseInstanceBase |
![]() | github.com/aws/aws-cdk-go/awscdk/v2/awsrds#DatabaseInstanceBase |
![]() | software.amazon.awscdk.services.rds.DatabaseInstanceBase |
![]() | aws_cdk.aws_rds.DatabaseInstanceBase |
![]() | aws-cdk-lib » aws_rds » DatabaseInstanceBase |
Implements
IConstruct
, IDependable
, IResource
, IDatabase
, IConnectable
, ISecret
Extends
Resource
Implemented by
Database
, Database
, Database
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
Resource
Props
Properties
Name | Type | Description |
---|---|---|
connections | Connections | Access to network connections. |
db | string | The instance endpoint address. |
db | string | The instance endpoint port. |
env | Resource | The environment this resource belongs to. |
instance | string | The instance arn. |
instance | Endpoint | The instance endpoint. |
instance | string | The instance identifier. |
node | Node | The tree node. |
stack | Stack | The stack in which this resource is defined. |
enable | boolean | |
engine? | IInstance | The engine of this database Instance. |
instance | string | The 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:
Resource
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:
IInstance
(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
Name | Description |
---|---|
add | Add a new db proxy to this instance. |
apply | Apply the given removal policy to this resource. |
as | Renders the secret attachment target specifications. |
grant | Grant the given identity connection access to the database. |
metric(metricName, props?) | Return the given named metric for this DBInstance. |
metric | The percentage of CPU utilization. |
metric | The number of database connections in use. |
metric | The amount of available storage space. |
metric | The amount of available random access memory. |
metric | The average number of disk write I/O operations per second. |
metric | The average number of disk read I/O operations per second. |
on | Defines a CloudWatch event rule which triggers for instance events. |
to | Returns a string representation of this construct. |
static from | Import an existing database instance. |
addProxy(id, options)
public addProxy(id: string, options: DatabaseProxyOptions): DatabaseProxy
Parameters
- id
string
- options
Database
Proxy Options
Returns
Add a new db proxy to this instance.
applyRemovalPolicy(policy)
public applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
Removal
Policy
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
Renders the secret attachment target specifications.
grantConnect(grantee, dbUser?)
public grantConnect(grantee: IGrantable, dbUser?: string): Grant
Parameters
- grantee
IGrantable
- dbUser
string
Returns
Grant the given identity connection access to the database.
metric(metricName, props?)
public metric(metricName: string, props?: MetricOptions): Metric
Parameters
- metricName
string
- props
Metric
Options
Returns
Return the given named metric for this DBInstance.
metricCPUUtilization(props?)
public metricCPUUtilization(props?: MetricOptions): Metric
Parameters
- props
Metric
Options
Returns
The percentage of CPU utilization.
Average over 5 minutes
metricDatabaseConnections(props?)
public metricDatabaseConnections(props?: MetricOptions): Metric
Parameters
- props
Metric
Options
Returns
The number of database connections in use.
Average over 5 minutes
metricFreeStorageSpace(props?)
public metricFreeStorageSpace(props?: MetricOptions): Metric
Parameters
- props
Metric
Options
Returns
The amount of available storage space.
Average over 5 minutes
metricFreeableMemory(props?)
public metricFreeableMemory(props?: MetricOptions): Metric
Parameters
- props
Metric
Options
Returns
The amount of available random access memory.
Average over 5 minutes
metricReadIOPS(props?)
public metricReadIOPS(props?: MetricOptions): Metric
Parameters
- props
Metric
Options
Returns
The average number of disk write I/O operations per second.
Average over 5 minutes
metricWriteIOPS(props?)
public metricWriteIOPS(props?: MetricOptions): Metric
Parameters
- props
Metric
Options
Returns
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
On
Event Options
Returns
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
Database
Instance Attributes
Returns
Import an existing database instance.