-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rds: cannot upgrade rds minor engine version with DatabaseInstanceReadReplica #26755
Comments
According to the doc, the read replica has to be upgraded first before the primary and cloudformation just has no idea about that.
You probably have two options here:
Please note I haven't tested any of the options above. Make sure you test them in your testing environment. |
OK I ended up using the first option with escape hatches and it works for me. class DemoStack(Stack):
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
RDS_VERSION = rds.PostgresEngineVersion.VER_11_19
vpc = ec2.Vpc.from_lookup(self, 'Vpc', is_default=True);
primary = rds.DatabaseInstance(
self,
"rds",
credentials=rds.Credentials.from_generated_secret("postgres"),
engine=rds.DatabaseInstanceEngine.postgres(version=RDS_VERSION),
instance_type=ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE3, ec2.InstanceSize.SMALL),
multi_az=True,
vpc=vpc,
publicly_accessible=False,
)
replica = rds.DatabaseInstanceReadReplica(
self,
"rds-read",
source_database_instance=primary,
instance_type=ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE3, ec2.InstanceSize.SMALL),
publicly_accessible=False,
multi_az=False,
storage_encrypted=True,
vpc=vpc,
) Add this in the bottom of above which overrides the engine and engine version of the replica:
check the synth output $ npx cdk synth Make sure you see this in the replica instance: "Engine": "postgres",
"EngineVersion": "11.20", # make sure cdk diff only indicates the modify on the replica
$ npx cdk diff
# cdk deploy if everything looks great to you
$ npx cdk deploy Now go to RDS console, a new replica will be created. Initially the new created replica will be version 11.19 and after that you will see it's upgrading to 11.20. And then the old replica of version 11.19 will be removed. Your primary should remain Now update your primary engine version. class DemoStack(Stack):
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
RDS_VERSION = rds.PostgresEngineVersion.VER_11_20
vpc = ec2.Vpc.from_lookup(self, 'Vpc', is_default=True);
primary = rds.DatabaseInstance(
self,
"rds",
credentials=rds.Credentials.from_generated_secret("postgres"),
engine=rds.DatabaseInstanceEngine.postgres(version=RDS_VERSION),
instance_type=ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE3, ec2.InstanceSize.SMALL),
multi_az=True,
vpc=vpc,
publicly_accessible=False,
)
replica = rds.DatabaseInstanceReadReplica(
self,
"rds-read",
source_database_instance=primary,
instance_type=ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE3, ec2.InstanceSize.SMALL),
publicly_accessible=False,
multi_az=False,
storage_encrypted=True,
vpc=vpc,
) Run
Your primary should be in Now your primary and replica should all at Last but not least, remove the escape hatches block.
You are all set! Let me know if it works for you but please note I believe RDS encourages Automatic minor version upgrades for PostgreSQL whenever possible rather than manual upgrade. The approach above is just FYR and I only tested it once in my account, make sure you evaluate this in your testing environment if you really have to upgrade from CDK. |
Thank you @pahud for your time.
is sufficient just to upgrade the replica without re/creating the new one. |
@rafzei Do you mean to keep the |
Describe the bug
I got an error when trying to upgrade a minor version of the RDS Postgres consisting of Primary and Replica instances.
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
.Current Behavior
The error occurs.
Reproduction Steps
Prepare and RDS stack with min. one replica, deploy, increase a minor version and deploy again
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
The text was updated successfully, but these errors were encountered: