Skip to content

(aws-rds): Can't create RDS instance of read replication from source RDS instance #16934

@zarr12steven

Description

@zarr12steven

General Issue

The Question

I want to create an RDS read replica from the source RDS instance, but it seems not working.
I follow the RDS of CDK documentation writes the code below...

Reproduction Steps

import * as cdk from '@aws-cdk/core';
import * as ec2 from '@aws-cdk/aws-ec2';
import * as rds from '@aws-cdk/aws-rds';
import { Duration } from '@aws-cdk/core'

export interface RdsStackProps extends cdk.StackProps {
    vpc: ec2.Vpc;
}

export class RdsStack extends cdk.Stack {
  private vpc: ec2.Vpc;
  constructor(scope: cdk.Construct, id: string, props: RdsStackProps ) {
    super(scope, id, props)

    // Make the vpc variable accessialbe
    const vpc = props.vpc

    // Create RDS
    const master = new rds.DatabaseInstance(this, 'Master', {
      instanceIdentifier: 'master',
      vpc,
      vpcSubnets: {
        subnetType: ec2.SubnetType.PRIVATE_WITH_NAT
      },
      engine,
      credentials: rds.Credentials.fromGeneratedSecret('pgadmin'),
      instanceType: ec2.InstanceType.of(ec2.InstanceClass.T3, ec2.InstanceSize.SMALL),
      multiAz: false,
      securityGroups: [ securitygroup2 ],
      availabilityZone: vpc.availabilityZones[0],
      deletionProtection: false,
      storageType: rds.StorageType.IO1,
      iops: 1000,
      maxAllocatedStorage: 1000,
      enablePerformanceInsights: true,
      performanceInsightRetention: rds.PerformanceInsightRetention.DEFAULT,
      backupRetention: Duration.days(7),
      storageEncrypted: true,
      copyTagsToSnapshot: true,
    });

    // Create minion RDS of reading replication from a master
    const minion = new rds.DatabaseInstanceReadReplica(this, 'ReadReplica', {
      instanceIdentifier: 'minion',
      vpc,
      vpcSubnets: {
        subnetType: ec2.SubnetType.PRIVATE_WITH_NAT
      },
      sourceDatabaseInstance: master,
      instanceType: ec2.InstanceType.of(ec2.InstanceClass.T3, ec2.InstanceSize.SMALL),
      multiAz: false,
      securityGroups: [ securitygroup2 ],
      availabilityZone: vpc.availabilityZones[1],
      deletionProtection: false,
      storageType: rds.StorageType.IO1,
      iops: 1000,
      maxAllocatedStorage: 1000,
      enablePerformanceInsights: true,
      performanceInsightRetention: rds.PerformanceInsightRetention.DEFAULT,
      backupRetention: Duration.days(7),
      storageEncrypted: true,
    });

  }
}

Error Log

10:52:41 AM | CREATE_FAILED        | AWS::RDS::DBInstance                        | ReadReplicaDA01B356
You must specify both the storage size and iops when modifying the storage size or iops on a DB instance that has iops. (Service: AmazonRDS; Status Code: 400; Error Code: Invali
dParameterCombination; Request ID: cd0ad978-1cce-4731-9291-8b2d1ae99693; Proxy: null)

	new DatabaseInstanceReadReplica (/work/aws_cdk/infra/node_modules/@aws-cdk/aws-rds/lib/instance.ts:737:22)
	\_ new RdsStack (/work/aws_cdk/infra/lib/rds-stack.ts:61:20)
	\_ Object.<anonymous> (/work/aws_cdk/infra/bin/infra.ts:13:1)
	\_ Module._compile (internal/modules/cjs/loader.js:1085:14)
	\_ Module.m._compile (/work/aws_cdk/infra/node_modules/ts-node/src/index.ts:1056:23)
	\_ Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
	\_ Object.require.extensions.<computed> [as .ts] (/work/aws_cdk/infra/node_modules/ts-node/src/index.ts:1059:12)
	\_ Module.load (internal/modules/cjs/loader.js:950:32)
	\_ Function.Module._load (internal/modules/cjs/loader.js:790:12)
	\_ Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
	\_ main (/work/aws_cdk/infra/node_modules/ts-node/src/bin.ts:198:14)
	\_ Object.<anonymous> (/work/aws_cdk/infra/node_modules/ts-node/src/bin.ts:288:3)
	\_ Module._compile (internal/modules/cjs/loader.js:1085:14)
	\_ Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
	\_ Module.load (internal/modules/cjs/loader.js:950:32)
	\_ Function.Module._load (internal/modules/cjs/loader.js:790:12)
	\_ Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
	\_ /usr/local/lib/nodejs/node-v14.18.0-linux-x64/lib/node_modules/npm/node_modules/libnpx/index.js:268:14


 ❌  RdsStack failed: Error: The stack named RdsStack failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE
    at Object.waitForStackDeploy (/usr/local/lib/nodejs/node-v14.18.0-linux-x64/lib/node_modules/aws-cdk/lib/api/util/cloudformation.ts:305:11)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at prepareAndExecuteChangeSet (/usr/local/lib/nodejs/node-v14.18.0-linux-x64/lib/node_modules/aws-cdk/lib/api/deploy-stack.ts:352:26)
    at CdkToolkit.deploy (/usr/local/lib/nodejs/node-v14.18.0-linux-x64/lib/node_modules/aws-cdk/lib/cdk-toolkit.ts:189:24)
    at initCommandLine (/usr/local/lib/nodejs/node-v14.18.0-linux-x64/lib/node_modules/aws-cdk/bin/cdk.ts:225:9)
The stack named RdsStack failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE

CDK CLI Version

1.127.0 (build 0ea309a)

Framework Version

1.127.0 (build 0ea309a)

Node.js Version

v14.18.0

OS

Ubuntu 20.04.3 LTS

Language

Typescript

Language Version

typescript@3.9.10

Other information

Even I try to drop these parameters by the minion server, like allocated storage, maxAllocatedStorage, and IOPS. but it seems still not working, the error message always told me that "You must specify both the storage size and iops when modifying the storage size or iops on a DB instance that has iops. (Service: AmazonRDS; Status Code: 400; Error Code: Invali dParameterCombination; Request ID: cd0ad978-1cce-4731-9291-8b2d1ae99693; Proxy: null)".

Metadata

Metadata

Labels

@aws-cdk/aws-rdsRelated to Amazon Relational DatabaseguidanceQuestion that needs advice or information.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions