class DatabaseInstanceBase
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.RDS.DatabaseInstanceBase |
Java | software.amazon.awscdk.services.rds.DatabaseInstanceBase |
Python | aws_cdk.aws_rds.DatabaseInstanceBase |
TypeScript (source) | @aws-cdk/aws-rds » DatabaseInstanceBase |
Implements
IConstruct
, 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 * as ec2 from '@aws-cdk/aws-ec2';
import * as rds from '@aws-cdk/aws-rds';
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,
});
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 | Construct | The construct tree node associated with this construct. |
stack | Stack | The stack in which this resource is defined. |
enable | boolean | |
engine? | IInstance | The engine of this database 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:
Construct
The construct tree node associated with this construct.
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.
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. |
Proxy(id, options)
addpublic addProxy(id: string, options: DatabaseProxyOptions): DatabaseProxy
Parameters
- id
string
- options
Database
Proxy Options
Returns
Add a new db proxy to this instance.
RemovalPolicy(policy)
applypublic 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
).
SecretAttachmentTarget()
aspublic asSecretAttachmentTarget(): SecretAttachmentTargetProps
Returns
Renders the secret attachment target specifications.
Connect(grantee)
grantpublic grantConnect(grantee: IGrantable): Grant
Parameters
- grantee
IGrantable
Returns
Grant the given identity connection access to the database.
Note: this method does not currently work, see https://github.com/aws/aws-cdk/issues/11851 for details.
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.
CPUUtilization(props?)
metricpublic metricCPUUtilization(props?: MetricOptions): Metric
Parameters
- props
Metric
Options
Returns
The percentage of CPU utilization.
Average over 5 minutes
DatabaseConnections(props?)
metricpublic metricDatabaseConnections(props?: MetricOptions): Metric
Parameters
- props
Metric
Options
Returns
The number of database connections in use.
Average over 5 minutes
FreeStorageSpace(props?)
metricpublic metricFreeStorageSpace(props?: MetricOptions): Metric
Parameters
- props
Metric
Options
Returns
The amount of available storage space.
Average over 5 minutes
FreeableMemory(props?)
metricpublic metricFreeableMemory(props?: MetricOptions): Metric
Parameters
- props
Metric
Options
Returns
The amount of available random access memory.
Average over 5 minutes
ReadIOPS(props?)
metricpublic metricReadIOPS(props?: MetricOptions): Metric
Parameters
- props
Metric
Options
Returns
The average number of disk write I/O operations per second.
Average over 5 minutes
WriteIOPS(props?)
metricpublic metricWriteIOPS(props?: MetricOptions): Metric
Parameters
- props
Metric
Options
Returns
The average number of disk read I/O operations per second.
Average over 5 minutes
Event(id, options?)
onpublic 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.
String()
topublic toString(): string
Returns
string
Returns a string representation of this construct.
DatabaseInstanceAttributes(scope, id, attrs)
static frompublic static fromDatabaseInstanceAttributes(scope: Construct, id: string, attrs: DatabaseInstanceAttributes): IDatabaseInstance
Parameters
- scope
Construct
- id
string
- attrs
Database
Instance Attributes
Returns
Import an existing database instance.