Skip to content

Commit e97b4cb

Browse files
authored
Merge branch 'master' into bundled_assets_metadata
2 parents bf075f8 + 9b2158b commit e97b4cb

13 files changed

Lines changed: 680 additions & 59 deletions

File tree

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
"fs-extra": "^9.1.0",
2121
"graceful-fs": "^4.2.8",
2222
"jest-junit": "^13.0.0",
23-
"jsii-diff": "^1.44.2",
24-
"jsii-pacmak": "^1.44.2",
25-
"jsii-reflect": "^1.44.2",
26-
"jsii-rosetta": "^1.44.2",
23+
"jsii-diff": "^1.45.0",
24+
"jsii-pacmak": "^1.45.0",
25+
"jsii-reflect": "^1.45.0",
26+
"jsii-rosetta": "^1.45.0",
2727
"lerna": "^4.0.0",
2828
"patch-package": "^6.4.7",
2929
"standard-version": "^9.3.2",

packages/@aws-cdk/aws-lambda-python/test/lambda-handler/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ urllib3==1.25.11
66
# Requests used by this lambda
77
requests==2.23.0
88
# Pillow 6.x so that python 2.7 and 3.x can both use this fixture
9-
pillow==6.2.2
9+
pillow==8.3.2

packages/@aws-cdk/aws-rds/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ new rds.DatabaseInstanceReadReplica(this, 'ReadReplica', {
129129
});
130130
```
131131

132+
Automatic backups of read replica instances are only supported for MySQL and MariaDB. By default,
133+
automatic backups are disabled for read replicas and can only be enabled (using `backupRetention`)
134+
if also enabled on the source instance.
135+
132136
Creating a "production" Oracle database instance with option and parameter groups:
133137

134138
[example of setting up a production oracle instance](test/integ.instance.lit.ts)

packages/@aws-cdk/aws-rds/lib/instance-engine.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ export interface IInstanceEngine extends IEngine {
100100
/** The application used by this engine to perform rotation for a multi-user scenario. */
101101
readonly multiUserRotationApplication: secretsmanager.SecretRotationApplication;
102102

103+
/**
104+
* Whether this engine supports automatic backups of a read replica instance.
105+
*
106+
* @default false
107+
*/
108+
readonly supportsReadReplicaBackups?: boolean;
109+
103110
/**
104111
* Method called when the engine is used to create a new instance.
105112
*/
@@ -123,6 +130,7 @@ abstract class InstanceEngineBase implements IInstanceEngine {
123130
public readonly singleUserRotationApplication: secretsmanager.SecretRotationApplication;
124131
public readonly multiUserRotationApplication: secretsmanager.SecretRotationApplication;
125132
public readonly engineFamily?: string;
133+
public readonly supportsReadReplicaBackups?: boolean;
126134

127135
private readonly features?: InstanceEngineFeatures;
128136

@@ -320,6 +328,8 @@ export interface MariaDbInstanceEngineProps {
320328
}
321329

322330
class MariaDbInstanceEngine extends InstanceEngineBase {
331+
public readonly supportsReadReplicaBackups = true;
332+
323333
constructor(version?: MariaDbEngineVersion) {
324334
super({
325335
engineType: 'mariadb',
@@ -533,6 +543,8 @@ export interface MySqlInstanceEngineProps {
533543
}
534544

535545
class MySqlInstanceEngine extends InstanceEngineBase {
546+
public readonly supportsReadReplicaBackups = true;
547+
536548
constructor(version?: MysqlEngineVersion) {
537549
super({
538550
engineType: 'mysql',

packages/@aws-cdk/aws-rds/lib/instance.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ export interface DatabaseInstanceNewProps {
380380
* When creating a read replica, you must enable automatic backups on the source
381381
* database instance by setting the backup retention to a value other than zero.
382382
*
383-
* @default Duration.days(1)
383+
* @default - Duration.days(1) for source instances, disabled for read replicas
384384
*/
385385
readonly backupRetention?: Duration;
386386

@@ -1143,6 +1143,12 @@ export class DatabaseInstanceReadReplica extends DatabaseInstanceNew implements
11431143
constructor(scope: Construct, id: string, props: DatabaseInstanceReadReplicaProps) {
11441144
super(scope, id, props);
11451145

1146+
if (props.sourceDatabaseInstance.engine
1147+
&& !props.sourceDatabaseInstance.engine.supportsReadReplicaBackups
1148+
&& props.backupRetention) {
1149+
throw new Error(`Cannot set 'backupRetention', as engine '${engineDescription(props.sourceDatabaseInstance.engine)}' does not support automatic backups for read replicas`);
1150+
}
1151+
11461152
const instance = new CfnDBInstance(this, 'Resource', {
11471153
...this.newCfnProps,
11481154
// this must be ARN, not ID, because of https://github.com/terraform-providers/terraform-provider-aws/issues/528#issuecomment-391169012

packages/@aws-cdk/aws-rds/test/instance.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,6 +1583,26 @@ describe('instance', () => {
15831583
});
15841584
});
15851585

1586+
test('throws with backupRetention on a read replica if engine does not support it', () => {
1587+
// GIVEN
1588+
const instanceType = ec2.InstanceType.of(ec2.InstanceClass.T3, ec2.InstanceSize.SMALL);
1589+
const backupRetention = cdk.Duration.days(5);
1590+
const source = new rds.DatabaseInstance(stack, 'Source', {
1591+
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_13 }),
1592+
backupRetention,
1593+
instanceType,
1594+
vpc,
1595+
});
1596+
1597+
expect(() => {
1598+
new rds.DatabaseInstanceReadReplica(stack, 'Replica', {
1599+
sourceDatabaseInstance: source,
1600+
backupRetention,
1601+
instanceType,
1602+
vpc,
1603+
});
1604+
}).toThrow(/Cannot set 'backupRetention', as engine 'postgres-13' does not support automatic backups for read replicas/);
1605+
});
15861606
});
15871607

15881608
test.each([

0 commit comments

Comments
 (0)