aws / aws/aws-cdk

rds: cannot upgrade rds minor engine version with DatabaseInstanceReadReplica

Open
#26,755 4 comments 1 reaction 0 assignees View on GitHub
@aws-cdk/aws-rds effort/medium feature-request p3
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
1d 19h
Merged PRs (30d)
71

Description

### Describe the bug

I got an error when trying to upgrade a minor version of the RDS Postgres consisting of Primary and Replica instances.
```
6:27:42 PM | UPDATE_FAILED | AWS::RDS::DBInstance | rds
One or more of the DB Instance's read replicas need to be upgraded: rds-read (Service: Rds, Status Code: 400, Request ID: xxx)
```
It looks like CDK is trying to upgrade only the Primary instance (or trying to do it first)

### Expected Behavior

Automatically upgrade the Replicas along with the Primary with the right order or allow to specify engine version to `aws_rds.DatabaseInstanceReadReplica`.

```
rds = aws_rds.DatabaseInstance(
...
engine=aws_rds.DatabaseInstanceEngine.postgres(version=RDS_VERSION),
...
)

rds_read = aws_rds.DatabaseInstanceReadReplica(
...
source_database_instance=rds,
engine=aws_rds.DatabaseInstanceEngine.postgres(version=RDS_VERSION),
...
_
```

### Current Behavior

The error occurs.

### Reproduction Steps

Prepare and RDS stack with min. one replica, deploy, increase a minor version and deploy again

```
RDS_VERSION = aws_rds.PostgresEngineVersion.VER_11_19

rds = aws_rds.DatabaseInstance(
self,
"rds",
credentials=aws_rds.Credentials.from_generated_secret("postgres"),
engine=aws_rds.DatabaseInstanceEngine.postgres(version=RDS_VERSION),
instance_type=aws_ec2.InstanceType(instance_type),
multi_az=True,
vpc=vpc,
vpc_subnets=aws_ec2.SubnetSelection(
subnet_group_name=shared.SUBNETS_GENERAL_ISOLATED,
),
publicly_accessible=False,
security_groups=[rds_sg],
storage_encrypted=True,
allocated_storage=RDS_INITIAL_STORAGE,
max_allocated_storage=RDS_MAX_STORAGE,
performance_insight_retention=aws_rds.PerformanceInsightRetention.DEFAULT,
cloudwatch_logs_exports=["postgresql", "upgrade"],
backup_retention=Duration.days(RDS_BACKUP_RETENTION),
preferred_maintenance_window="sat:08:10-sat:10:10",
preferred_backup_window="03:10-04:10",
)

rds_read = aws_rds.DatabaseInstanceReadReplica(
self,
"rds-read",
source_database_instance=rds,
instance_type=aws_ec2.InstanceType(replica_instance_type),
publicly_accessible=False,
multi_az=False,
storage_encrypted=True,
vpc=vpc,
vpc_subnets=aws_ec2.SubnetSelection(
subnet_group_name=shared.SUBNETS_GENERAL_ISOLATED,
),
security_groups=[rds_sg],
performance_insight_retention=aws_rds.PerformanceInsightRetention.DEFAULT,
max_allocated_storage=RDS_MAX_STORAGE,
preferred_maintenance_window="sat:08:10-sat:10:10",
)
```

### Possible Solution

_No response_

### Additional Information/Context

_No response_

### CDK CLI Version

2.91.0

### Framework Version

_No response_

### Node.js Version

18

### OS

Ubuntu

### Language

Python

### Language Version

3.11.4

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start from the DatabaseInstance and DatabaseInstanceReadReplica entry points and reproduce the minor-version update with a primary and replica using the supplied Python example. Trace the generated resource update ordering and replica engine-version handling; done means the stack can upgrade the primary and replica without the RDS dependency error, with coverage for the reproduction.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, postgresql, python, typescript
Domain
cloud, databases, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.