class DatabaseInstance (construct)
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.DocDB.DatabaseInstance |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsdocdb#DatabaseInstance |
Java | software.amazon.awscdk.services.docdb.DatabaseInstance |
Python | aws_cdk.aws_docdb.DatabaseInstance |
TypeScript (source) | aws-cdk-lib » aws_docdb » DatabaseInstance |
Implements
IConstruct
, IDependable
, IResource
, IDatabase
A database instance.
Example
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_docdb as docdb } from 'aws-cdk-lib';
import { aws_ec2 as ec2 } from 'aws-cdk-lib';
import { aws_rds as rds } from 'aws-cdk-lib';
declare const caCertificate: rds.CaCertificate;
declare const databaseCluster: docdb.DatabaseCluster;
declare const instanceType: ec2.InstanceType;
const databaseInstance = new docdb.DatabaseInstance(this, 'MyDatabaseInstance', {
cluster: databaseCluster,
instanceType: instanceType,
// the properties below are optional
autoMinorVersionUpgrade: false,
availabilityZone: 'availabilityZone',
caCertificate: caCertificate,
dbInstanceName: 'dbInstanceName',
enablePerformanceInsights: false,
preferredMaintenanceWindow: 'preferredMaintenanceWindow',
removalPolicy: cdk.RemovalPolicy.DESTROY,
});
Initializer
new DatabaseInstance(scope: Construct, id: string, props: DatabaseInstanceProps)
Parameters
- scope
Construct
- id
string
- props
Database
Instance Props
Construct Props
Name | Type | Description |
---|---|---|
cluster | IDatabase | The DocumentDB database cluster the instance should launch into. |
instance | Instance | The name of the compute and memory capacity classes. |
auto | boolean | Indicates that minor engine upgrades are applied automatically to the DB instance during the maintenance window. |
availability | string | The name of the Availability Zone where the DB instance will be located. |
ca | Ca | The identifier of the CA certificate for this DB instance. |
db | string | A name for the DB instance. |
enable | boolean | A value that indicates whether to enable Performance Insights for the DB Instance. |
preferred | string | The weekly time range (in UTC) during which system maintenance can occur. |
removal | Removal | The CloudFormation policy to apply when the instance is removed from the stack or replaced during an update. |
cluster
Type:
IDatabase
The DocumentDB database cluster the instance should launch into.
instanceType
Type:
Instance
The name of the compute and memory capacity classes.
autoMinorVersionUpgrade?
Type:
boolean
(optional, default: true)
Indicates that minor engine upgrades are applied automatically to the DB instance during the maintenance window.
availabilityZone?
Type:
string
(optional, default: no preference)
The name of the Availability Zone where the DB instance will be located.
caCertificate?
Type:
Ca
(optional, default: DocumentDB will choose a certificate authority)
The identifier of the CA certificate for this DB instance.
Specifying or updating this property triggers a reboot.
dbInstanceName?
Type:
string
(optional, default: a CloudFormation generated name)
A name for the DB instance.
If you specify a name, AWS CloudFormation converts it to lowercase.
enablePerformanceInsights?
Type:
boolean
(optional, default: false)
A value that indicates whether to enable Performance Insights for the DB Instance.
preferredMaintenanceWindow?
Type:
string
(optional, default: a 30-minute window selected at random from an 8-hour block of
time for each AWS Region, occurring on a random day of the week. To see
the time blocks available, see https://docs.aws.amazon.com/documentdb/latest/developerguide/db-instance-maintain.html#maintenance-window)
The weekly time range (in UTC) during which system maintenance can occur.
Format: ddd:hh24:mi-ddd:hh24:mi
Constraint: Minimum 30-minute window
removalPolicy?
Type:
Removal
(optional, default: RemovalPolicy.Retain)
The CloudFormation policy to apply when the instance is removed from the stack or replaced during an update.
Properties
Name | Type | Description |
---|---|---|
cluster | IDatabase | The instance's database cluster. |
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. |
cluster
Type:
IDatabase
The instance's database cluster.
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.
Methods
Name | Description |
---|---|
apply | Apply the given removal policy to this resource. |
to | Returns a string representation of this construct. |
static from | Import an existing database 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
).
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.