https://pulumi.com logo
Title
m

many-salesmen-89069

07/13/2021, 12:43 PM
Has anyone got a working AWS RDS read replica setup I could look at? I keep getting the following error when attempting to create a read replica:
Error creating DB Instance: InvalidDBInstanceState: Automated backups are not enabled for this database instance. To enable automated backups, use ModifyDBInstance to set the backup retention period to a non-zero value.
This is my code:
const replicaDbSubnets = new aws.rds.SubnetGroup("replica-db-subnets", {
    subnetIds: vpc.publicSubnetIds,
});
const isolatedDbReplica = new aws.rds.Instance(`${name}-isolated-db-replica`, {
    instanceClass: "db.t2.micro",
    allocatedStorage: 10,

    dbSubnetGroupName: replicaDbSubnets.name,
    vpcSecurityGroupIds: [isolatedReplicaSg.id],

    skipFinalSnapshot: true,
    publiclyAccessible: true,
    replicateSourceDb: isolatedDb.identifier,
    backupRetentionPeriod: 0
});
My understanding is that backups should be only enabled for the source db?
deleting and recreating the stack gave me the following error message that helped solve the problem:
DbSubnetGroupName should not be specified for read replicas that are created in the same region as the master
w

witty-candle-66007

07/13/2021, 3:30 PM
I suspect the original error was perhaps because a a non-zero
backup_retention_period
property was added to the source DB after the DB was initially deployed but the
apply_immediately
property was not set. So the adding of a backup retention period to the source DB was scheduled for your next maintenance window. And, so the read replica was failing due to the source not yet having backups set. Redeploying the stack avoided this since the source DB was deployed with the backups set and so then you saw the region error.
m

many-salesmen-89069

07/13/2021, 3:44 PM
Thanks @witty-candle-66007, that’s great insight!