# DatabaseInstanceReadReplica

A read replica database instance.

Extends: Construct › Resource › DatabaseInstanceBase › DatabaseInstanceReadReplica
Implements: IResource, IConnectable, IDatabaseInstance, ISecretAttachmentTarget, IEnvironmentAware, IDBInstanceRef, IConstruct, IDependable

- CloudFormation: [`AWS::RDS::DBInstance`](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-rds-dbinstance.html)
- L1 type: [`CfnDBInstance`](/cdk/api/v2/docs/aws-cdk-lib.aws_rds.CfnDBInstance.html)
- Source: [`aws-rds/lib/instance.ts`](https://github.com/aws/aws-cdk/blob/v2.273.0/packages/aws-cdk-lib/aws-rds/lib/instance.ts#L1609)
- Type last changed: v2.196.0 · 16 May 2025

## Example

```ts
declare const vpc: ec2.Vpc;
new rds.DatabaseInstanceFromSnapshot(this, 'Instance', {
  snapshotIdentifier: 'my-snapshot',
  engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_3 }),
  // optional, defaults to m5.large
  instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE2, ec2.InstanceSize.LARGE),
  vpc,
});

declare const sourceInstance: rds.DatabaseInstance;
new rds.DatabaseInstanceReadReplica(this, 'ReadReplica', {
  sourceDatabaseInstance: sourceInstance,
  instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE2, ec2.InstanceSize.LARGE),
  vpc,
});
```

## Initializer

```ts
new DatabaseInstanceReadReplica(scope: Construct, id: string, props: DatabaseInstanceReadReplicaProps)
```

## Construct Props

- `allocatedStorage`: number = The replica will inherit the allocated storage of the source database instance — The allocated storage size, specified in gibibytes (GiB).

  **Default:** The replica will inherit the allocated storage of the source database instance

- `applyImmediately`: boolean = Changes will be applied immediately — Specifies whether changes to the DB instance and any pending modifications are applied immediately, regardless of the `preferredMaintenanceWindow` setting.

  If set to `false`, changes are applied during the next maintenance window.

  Until RDS applies the changes, the DB instance remains in a drift state.
  As a result, the configuration doesn't fully reflect the requested modifications and temporarily diverges from the intended state.

  This property also determines whether the DB instance reboots when a static parameter is modified in the associated DB parameter group.

  **Default:** Changes will be applied immediately

- `autoMinorVersionUpgrade`: boolean = true — Indicates that minor engine upgrades are applied automatically to the DB instance during the maintenance window.

- `availabilityZone`: string = no preference — The name of the Availability Zone where the DB instance will be located.

- `backupRetention`: [Duration](/cdk/api/v2/docs/aws-cdk-lib.Duration.html) = Duration.days(1) for source instances, disabled for read replicas — The number of days during which automatic DB snapshots are retained.

  Set to zero to disable backups.
  When creating a read replica, you must enable automatic backups on the source
  database instance by setting the backup retention to a value other than zero.

  **Default:** Duration.days(1) for source instances, disabled for read replicas

- `caCertificate`: [CaCertificate](/cdk/api/v2/docs/aws-cdk-lib.aws_rds.CaCertificate.html) = RDS will choose a certificate authority — The identifier of the CA certificate for this DB instance.

  Specifying or updating this property triggers a reboot.

  For RDS DB engines:

  **Default:** RDS will choose a certificate authority

- `cloudwatchLogsExports`: string[] = no log exports — The list of log types that need to be enabled for exporting to CloudWatch Logs.

- `cloudwatchLogsRetention`: [RetentionDays](/cdk/api/v2/docs/aws-cdk-lib.aws_logs.RetentionDays.html) = logs never expire — The number of days log events are kept in CloudWatch Logs.

  When updating
  this property, unsetting it doesn't remove the log retention policy. To
  remove the retention policy, set the value to `Infinity`.

- `cloudwatchLogsRetentionRole`: [IRole](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) = a new role is created. — The IAM role for the Lambda function associated with the custom resource that sets the retention policy.

- `copyTagsToSnapshot`: boolean = true — Indicates whether to copy all of the user-defined tags from the DB instance to snapshots of the DB instance.

- `databaseInsightsMode`: [DatabaseInsightsMode](/cdk/api/v2/docs/aws-cdk-lib.aws_rds.DatabaseInsightsMode.html) = DatabaseInsightsMode.STANDARD when performance insights are enabled, otherwise not set. — The database insights mode.

  **Default:** DatabaseInsightsMode.STANDARD when performance insights are enabled, otherwise not set.

- `deleteAutomatedBackups`: boolean = true — Indicates whether automated backups should be deleted or retained when you delete a DB instance.

- `deletionProtection`: boolean = true if ``removalPolicy`` is RETAIN, false otherwise — Indicates whether the DB instance should have deletion protection enabled.

  **Default:** true if ``removalPolicy`` is RETAIN, false otherwise

- `domain`: string = Do not join domain — The Active Directory directory ID to create the DB instance in.

- `domainRole`: [IRoleRef](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_iam.IRoleRef.html) = The role will be created for you if `DatabaseInstanceNewProps#domain` is specified — The IAM role to be used when making API calls to the Directory Service.

  The role needs the AWS-managed policy
  AmazonRDSDirectoryServiceAccess or equivalent.

  **Default:** The role will be created for you if `DatabaseInstanceNewProps#domain` is specified

- `enablePerformanceInsights`: boolean = false, unless ``performanceInsightRetention`` or ``performanceInsightEncryptionKey`` is set. — Whether to enable Performance Insights for the DB instance.

  **Default:** false, unless ``performanceInsightRetention`` or ``performanceInsightEncryptionKey`` is set.

- `engineLifecycleSupport`: [EngineLifecycleSupport](/cdk/api/v2/docs/aws-cdk-lib.aws_rds.EngineLifecycleSupport.html) = undefined - AWS RDS default setting is `EngineLifecycleSupport.OPEN_SOURCE_RDS_EXTENDED_SUPPORT` — The life cycle type for this DB instance.

  This setting applies only to RDS for MySQL and RDS for PostgreSQL.

  **Default:** undefined - AWS RDS default setting is `EngineLifecycleSupport.OPEN_SOURCE_RDS_EXTENDED_SUPPORT`

- `iamAuthentication`: boolean = false — Whether to enable mapping of AWS Identity and Access Management (IAM) accounts to database accounts.

- `instanceIdentifier`: string = a CloudFormation generated name — A name for the DB instance.

  If you specify a name, AWS CloudFormation
  converts it to lowercase.

- `instanceType`: [InstanceType](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.InstanceType.html) (required) — The name of the compute and memory capacity classes.

- `iops`: number = no provisioned iops if storage type is not specified. For GP3: 3,000 IOPS if allocated storage is less than 400 GiB for MariaDB, MySQL, and PostgreSQL, less than 200 GiB for Oracle and less than 20 GiB for SQL Server. 12,000 IOPS otherwise (except for SQL Server where the default is always 3,000 IOPS). — The number of I/O operations per second (IOPS) that the database provisions.

  The value must be equal to or greater than 1000.

  **Default:** no provisioned iops if storage type is not specified. For GP3: 3,000 IOPS if allocated storage is less than 400 GiB for MariaDB, MySQL, and PostgreSQL, less than 200 GiB for Oracle and less than 20 GiB for SQL Server. 12,000 IOPS otherwise (except for SQL Server where the default is always 3,000 IOPS).

- `maxAllocatedStorage`: number = No autoscaling of RDS instance — Upper limit to which RDS can scale the storage in GiB(Gibibyte).

- `monitoringInterval`: [Duration](/cdk/api/v2/docs/aws-cdk-lib.Duration.html) = no enhanced monitoring — The interval, in seconds, between points when Amazon RDS collects enhanced monitoring metrics for the DB instance.

- `monitoringRole`: [IRoleRef](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_iam.IRoleRef.html) = A role is automatically created for you — Role that will be used to manage DB instance monitoring.

  **Default:** A role is automatically created for you

- `multiAz`: boolean = false — Specifies if the database instance is a multiple Availability Zone deployment.

- `networkType`: [NetworkType](/cdk/api/v2/docs/aws-cdk-lib.aws_rds.NetworkType.html) = IPV4 — The network type of the DB instance.

- `optionGroup`: [IOptionGroup](/cdk/api/v2/docs/aws-cdk-lib.aws_rds.IOptionGroup.html) = no option group — The option group to associate with the instance.

- `parameterGroup`: [IParameterGroup](/cdk/api/v2/docs/aws-cdk-lib.aws_rds.IParameterGroup.html) = no parameter group — The DB parameter group to associate with the instance.

- `performanceInsightEncryptionKey`: [IKeyRef](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_kms.IKeyRef.html) = default master key — The AWS KMS key for encryption of Performance Insights data.

- `performanceInsightRetention`: [PerformanceInsightRetention](/cdk/api/v2/docs/aws-cdk-lib.aws_rds.PerformanceInsightRetention.html) = 7 this is the free tier — The amount of time, in days, to retain Performance Insights data.

  If you set `databaseInsightsMode` to `DatabaseInsightsMode.ADVANCED`, you must set this property to `PerformanceInsightRetention.MONTHS_15`.

- `port`: number = the default port for the chosen engine. — The port for the instance.

  **Default:** the default port for the chosen engine.

- `preferredBackupWindow`: string = a 30-minute window selected at random from an 8-hour block of time for each AWS Region. To see the time blocks available, see https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_WorkingWithAutomatedBackups.html#USER_WorkingWithAutomatedBackups.BackupWindow — The daily time range during which automated backups are performed.

  Constraints:
  - Must be in the format `hh24:mi-hh24:mi`.
  - Must be in Universal Coordinated Time (UTC).
  - Must not conflict with the preferred maintenance window.
  - Must be at least 30 minutes.

  **Default:** a 30-minute window selected at random from an 8-hour block of time for each AWS Region. To see the time blocks available, see https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_WorkingWithAutomatedBackups.html#USER_WorkingWithAutomatedBackups.BackupWindow

- `preferredMaintenanceWindow`: string = 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/AmazonRDS/latest/UserGuide/USER_UpgradeDBInstance.Maintenance.html#Concepts.DBMaintenance — The weekly time range (in UTC) during which system maintenance can occur.

  Format: `ddd:hh24:mi-ddd:hh24:mi`
  Constraint: Minimum 30-minute window

  **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/AmazonRDS/latest/UserGuide/USER_UpgradeDBInstance.Maintenance.html#Concepts.DBMaintenance

- `processorFeatures`: [ProcessorFeatures](/cdk/api/v2/docs/aws-cdk-lib.aws_rds.ProcessorFeatures.html) = the default number of CPU cores and threads per core for the chosen instance class. See https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.DBInstanceClass.html#USER_ConfigureProcessor — The number of CPU cores and the number of threads per core.

  **Default:** the default number of CPU cores and threads per core for the chosen instance class. See https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.DBInstanceClass.html#USER_ConfigureProcessor

- `publiclyAccessible`: boolean = `true` if the instance's `vpcSubnets` is `subnetType: SubnetType.PUBLIC`, `false` otherwise — Indicates whether the DB instance is an internet-facing instance.

  If not specified,
  the instance's vpcSubnets will be used to determine if the instance is internet-facing
  or not.

  **Default:** `true` if the instance's `vpcSubnets` is `subnetType: SubnetType.PUBLIC`, `false` otherwise

- `removalPolicy`: [RemovalPolicy](/cdk/api/v2/docs/aws-cdk-lib.RemovalPolicy.html) = RemovalPolicy.SNAPSHOT (remove the resource, but retain a snapshot of the data) — The CloudFormation policy to apply when the instance is removed from the stack or replaced during an update.

  **Default:** RemovalPolicy.SNAPSHOT (remove the resource, but retain a snapshot of the data)

- `s3ExportBuckets`: [IBucket](/cdk/api/v2/docs/aws-cdk-lib.aws_s3.IBucket.html)[] = None — S3 buckets that you want to load data into.

  This property must not be used if `s3ExportRole` is used.

  For Microsoft SQL Server:

- `s3ExportRole`: [IRole](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) = New role is created if `s3ExportBuckets` is set, no role is defined otherwise — Role that will be associated with this DB instance to enable S3 export.

  This property must not be used if `s3ExportBuckets` is used.

  For Microsoft SQL Server:

  **Default:** New role is created if `s3ExportBuckets` is set, no role is defined otherwise

- `s3ImportBuckets`: [IBucket](/cdk/api/v2/docs/aws-cdk-lib.aws_s3.IBucket.html)[] = None — S3 buckets that you want to load data from.

  This feature is only supported by the Microsoft SQL Server, Oracle, and PostgreSQL engines.

  This property must not be used if `s3ImportRole` is used.

  For Microsoft SQL Server:

- `s3ImportRole`: [IRole](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) = New role is created if `s3ImportBuckets` is set, no role is defined otherwise — Role that will be associated with this DB instance to enable S3 import.

  This feature is only supported by the Microsoft SQL Server, Oracle, and PostgreSQL engines.

  This property must not be used if `s3ImportBuckets` is used.

  For Microsoft SQL Server:

  **Default:** New role is created if `s3ImportBuckets` is set, no role is defined otherwise

- `securityGroups`: [ISecurityGroup](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.ISecurityGroup.html)[] = a new security group is created — The security groups to assign to the DB instance.

- `sourceDatabaseInstance`: [IDatabaseInstance](/cdk/api/v2/docs/aws-cdk-lib.aws_rds.IDatabaseInstance.html) (required) — The source database instance.

  Each DB instance can have a limited number of read replicas. For more
  information, see https://docs.aws.amazon.com/AmazonRDS/latest/DeveloperGuide/USER_ReadRepl.html.

- `storageEncrypted`: boolean = true if storageEncryptionKey has been provided, false otherwise — Indicates whether the DB instance is encrypted.

  **Default:** true if storageEncryptionKey has been provided, false otherwise

- `storageEncryptionKey`: [IKeyRef](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_kms.IKeyRef.html) = default master key if storageEncrypted is true, no key otherwise — The KMS key that's used to encrypt the DB instance.

  **Default:** default master key if storageEncrypted is true, no key otherwise

- `storageThroughput`: number = 125 MiBps if allocated storage is less than 400 GiB for MariaDB, MySQL, and PostgreSQL, less than 200 GiB for Oracle and less than 20 GiB for SQL Server. 500 MiBps otherwise (except for SQL Server where the default is always 125 MiBps). — The storage throughput, specified in mebibytes per second (MiBps).

  Only applicable for GP3.

  **Default:** 125 MiBps if allocated storage is less than 400 GiB for MariaDB, MySQL, and PostgreSQL, less than 200 GiB for Oracle and less than 20 GiB for SQL Server. 500 MiBps otherwise (except for SQL Server where the default is always 125 MiBps).

- `storageType`: [StorageType](/cdk/api/v2/docs/aws-cdk-lib.aws_rds.StorageType.html) = StorageType.GP2 — The storage type to associate with the DB instance.

  Storage types supported are gp2, gp3, io1, io2, and standard.

- `subnetGroup`: [IDBSubnetGroupRef](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_rds.IDBSubnetGroupRef.html) = a new subnet group will be created. — Existing subnet group for the instance.

  **Default:** a new subnet group will be created.

- `vpc`: [IVpc](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IVpc.html) (required) — The VPC network where the DB subnet group should be created.

- `vpcSubnets`: [SubnetSelection](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.SubnetSelection.html) = private subnets — The type of subnets to add to the created DB subnet group.

## Properties

- `cloudwatchLogGroups`: { [key: string]: [ILogGroup](/cdk/api/v2/docs/aws-cdk-lib.aws_logs.ILogGroup.html) } (required) — The log group is created when `cloudwatchLogsExports` is set.

  Each export value will create a separate log group.

- `connections`: [Connections](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.Connections.html) (required) — Access to network connections.

- `dbInstanceEndpointAddress`: string (required) — The instance endpoint address.

- `dbInstanceEndpointPort`: string (required) — The instance endpoint port.

- `dbInstanceRef`: [DBInstanceReference](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_rds.DBInstanceReference.html) (required) — A reference to this database instance.

- `engine`: [IInstanceEngine](/cdk/api/v2/docs/aws-cdk-lib.aws_rds.IInstanceEngine.html) — The engine of this database Instance.

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

- `env`: [ResourceEnvironment](/cdk/api/v2/docs/aws-cdk-lib.interfaces.ResourceEnvironment.html) (required) — The environment this resource belongs to.

  For resources that are created and managed in a Stack (those created by
  creating new class instances like `new Role()`, `new Bucket()`, etc.), this
  is always the same as the environment of the stack they belong to.

  For referenced resources (those obtained from referencing methods like
  `Role.fromRoleArn()`, `Bucket.fromBucketName()`, etc.), they might be
  different than the stack they were imported into.

- `instanceArn`: string (required) — The instance arn.

- `instanceEndpoint`: [Endpoint](/cdk/api/v2/docs/aws-cdk-lib.aws_rds.Endpoint.html) (required) — The instance endpoint.

- `instanceIdentifier`: string (required) — The instance identifier.

- `instanceResourceId`: string — 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.

- `node`: [Node](/cdk/api/v2/docs/constructs.Node.html) (required) — The tree node.

- `PROPERTY_INJECTION_ID`: string (required) (static) — Uniquely identifies this class.

- `stack`: [Stack](/cdk/api/v2/docs/aws-cdk-lib.Stack.html) (required) — The stack in which this resource is defined.

- `vpc`: [IVpc](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IVpc.html) (required) — The VPC where this database instance is deployed.

## Methods

- `addProxy(id: string, options: DatabaseProxyOptions): DatabaseProxy` — Add a new db proxy to this instance.

- `applyCrossStackReferenceStrength(strength: ReferenceStrength): void` — Override the cross-stack reference strength for this resource.

  When set, any cross-stack reference to this resource will use the specified
  mechanism instead of the global default determined by the
  `@aws-cdk/core:defaultCrossStackReferences` context key. This is useful for
  selectively weakening specific references to avoid the "deadly embrace" problem
  without changing the app-wide default.

  **Parameters**

  - `strength` — - The reference strength to use for this resource.

- `applyRemovalPolicy(policy: RemovalPolicy): void` — 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(): SecretAttachmentTargetProps` — Renders the secret attachment target specifications.

- `fromDatabaseInstanceAttributes(scope: Construct, id: string, attrs: DatabaseInstanceAttributes): IDatabaseInstance` (static) — Import an existing database instance.

- `fromLookup(scope: Construct, id: string, options: DatabaseInstanceLookupOptions): IDatabaseInstance` (static) — Lookup an existing DatabaseInstance using instanceIdentifier.

- `grantConnect(grantee: IGrantable, dbUser?: string): Grant` — [disable-awslint:no-grants].

- `isConstruct(x: any): boolean` (static) — Checks if `x` is a construct.

  Use this method instead of `instanceof` to properly detect `Construct`
  instances, even when the construct library is symlinked.

  Explanation: in JavaScript, multiple copies of the `constructs` library on
  disk are seen as independent, completely different libraries. As a
  consequence, the class `Construct` in each copy of the `constructs` library
  is seen as a different class, and an instance of one class will not test as
  `instanceof` the other class. `npm install` will not create installations
  like this, but users may manually symlink construct libraries together or
  use a monorepo tool: in those cases, multiple copies of the `constructs`
  library can be accidentally installed, and `instanceof` will behave
  unpredictably. It is safest to avoid using `instanceof`, and using
  this type-testing method instead.

  **Parameters**

  - `x` — Any object.

  **Returns:** true if `x` is an object created from a class which extends `Construct`.

- `isOwnedResource(construct: IConstruct): boolean` (static) — Returns true if the construct was created by CDK, and false otherwise.

- `isResource(construct: IConstruct): boolean` (static) — Check whether the given construct is a Resource.

- `metric(metricName: string, props?: MetricOptions): Metric` — Return the given named metric for this DBInstance.

- `metricCPUUtilization(props?: MetricOptions): Metric` — The percentage of CPU utilization.

  Average over 5 minutes

- `metricDatabaseConnections(props?: MetricOptions): Metric` — The number of database connections in use.

  Average over 5 minutes

- `metricFreeableMemory(props?: MetricOptions): Metric` — The amount of available random access memory.

  Average over 5 minutes

- `metricFreeStorageSpace(props?: MetricOptions): Metric` — The amount of available storage space.

  Average over 5 minutes

- `metricReadIOPS(props?: MetricOptions): Metric` — The average number of disk read I/O operations per second. The average number of disk write I/O operations per second.

  Average over 5 minutes

- `metricWriteIOPS(props?: MetricOptions): Metric` — The average number of disk write I/O operations per second. The average number of disk read I/O operations per second.

  Average over 5 minutes

- `onEvent(id: string, options?: OnEventOptions): Rule` — Defines a CloudWatch event rule which triggers for instance events.

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

- `toString(): string` — Returns a string representation of this construct.

- `with(...mixins: IMixin[]): IConstruct` — Applies one or more mixins to this construct.

  Mixins are applied in order. The list of constructs is captured at the
  start of the call, so constructs added by a mixin will not be visited.
  Use multiple `with()` calls if subsequent mixins should apply to added
  constructs.
