I'm having a hard time setting up read replica for...
# aws
s
I'm having a hard time setting up read replica for a Postgres RDS server. My first attempt failed with
error modifying DB Instance (read-replicaf4d753f): InvalidParameterCombination: Cannot change master user password on an RDS postgres Read Replica because it uses physical replication and therefore cannot differ from its parent
even though the replica was created and visible in the console. Is there a trick I'm missing?
My code is:
Copy code
const readReplica = new aws.rds.Instance('read-replica', {
  engine: 'postgres',
  engineVersion: '13',
  instanceClass: instanceClass,
  allocatedStorage: 5,
  dbSubnetGroupName: dbSubnetGroup.id,
  vpcSecurityGroupIds: [dbSecurityGroup.id],
  name: dbName,
  username: dbUsername,
  password: dbPassword,
  allowMajorVersionUpgrade: false,
  autoMinorVersionUpgrade: true,
  storageEncrypted: true,
  maxAllocatedStorage: 500,
  deletionProtection: true,
  performanceInsightsEnabled: true,
  backupRetentionPeriod: 30,
  replicateSourceDb: db.arn,
});
b
it looks like the dbpassword isn't the same as your master instance?
s
That's almost exactly the same code that generates my main instance, so I don't know how that would happen
Copy code
username: dbUsername,
  password: dbPassword,
pulls from the same place
b
I don't think you need to set the master password and username on replicas, try removing those params
s
yeah, looking at https://github.com/terraform-aws-modules/terraform-aws-rds/issues/103 I was just about to try that
Yep, that worked. Thank you!
Hm, but oddly, if I run
pulumi up
a second time, it wants to change it again.
I created a read replica and it looks fine
but the second time I run pulumi up, I get
└─ aws:rds:Instance  read-replica  update     [diff: ~replicateSourceDb]
and I believe that will fail if I run it again
Yep,
Copy code
aws:rds:Instance (read-replica):
    error: 1 error occurred:
        * updating urn:pulumi:dev::core::aws:rds/instance:Instance::read-replica: 1 error occurred:
        * cannot elect new source database for replication
b
you'll need to see
ignoreChanges
perhaps?
s
huh, nifty. I've never used that before.
I wonder why I need that here
But adding
{ ignoreChanges: ['replicateSourceDb']  }
seems to work