I am trying to create a read-replica DR in a different region based on this resource in Terraform:
# Define the read replica
resource "aws_db_instance" "read_replica" {
identifier = "my-read-replica"
engine = data.aws_db_instance.existing.engine
instance_class = "db.t3.medium"
publicly_accessible = true
db_subnet_group_name = data.aws_db_instance.existing.db_subnet_group
availability_zone = data.aws_db_instance.existing.availability_zone
db_parameter_group_name = aws_db_parameter_group.custom.name
multi_az = false
storage_type = "gp2"
replicate_source_db = data.aws_db_instance.existing.identifier
}
I have the following db_paramater_group_name
:
resource "aws_db_parameter_group" "custom" {
name = var.custom_parameter_group
family = "postgres12" # Replace with the appropriate family for your PostgreSQL version
description = "Custom parameter group for PostgreSQL RDS instance"
parameter {
name = "max_connections"
value = "200"
}
parameter {
name = "log_statement"
value = "all"
}
}
However, when I terraform apply
i get this error:
│ Error: creating RDS DB Instance (read replica) (my-read-replica): InvalidParameterCombination: A parameter group can’t be specified during Read Replica creation for the following DB engine: postgres
Can I not specify db_parameter_group_name
for a read-replica in a different region?
2
Answers
The answer is no.
When creating a read replica in AWS RDS, you should not specify a parameter group regardless of it’s location. The read replica inherits the parameter group from the primary instance to ensure consistency in the replication process as this is essential for a seamless operation.
Regarding AWS Primary and Replica RDS instances:
Parameter Groups: These configure database engine settings that apply to one or more RDS instances. Since a read replica must remain consistent with the primary instance, it inherits the primary instance’s parameter group. This inheritance ensures that the settings are the same for both instances, facilitating proper replication.
Option Groups: These enable additional features for your RDS instances, such as MySQL, SQL Server Audit or Oracle Enterprise Manager. You can have different option groups for the primary and read replicas, as these features might be specific to the role of the instance (primary or replica) and do not directly impact the replication process. PostgreSQL does not use option groups. Instead, PostgreSQL relies on extensions to provide additional functionalities.
Extensions: For PostgreSQL, extensions add extra features to the database engine. Both the primary and replica instances should have the same extensions enabled to ensure consistency and proper functionality. These extensions are managed within the database and need to be consistent across primary and replica instances.
In summary, for your primary and replica RDS instances:
See below for your revised terraform:
The answer is no.
When creating a read replica in AWS RDS, you should not specify a parameter group regardless of it’s location. The read replica inherits the parameter group from the primary instance to ensure consistency in the replication process as this is essential for a seamless operation.
Regarding AWS Primary and Replica RDS instances:
Parameter Groups: These configure database engine settings that apply to one or more RDS instances. Since a read replica must remain consistent with the primary instance, it inherits the primary instance’s parameter group. This inheritance ensures that the settings are the same for both instances, facilitating proper replication.
Option Groups: These enable additional features for your RDS instances, such as MySQL, SQL Server Audit or Oracle Enterprise Manager. You can have different option groups for the primary and read replicas, as these features might be specific to the role of the instance (primary or replica) and do not directly impact the replication process.
Extensions: For PostgreSQL, extensions add extra features to the database engine. Both the primary and replica instances should have the same extensions enabled to ensure consistency and proper functionality. These extensions are managed within the database and need to be consistent across primary and replica instances.
In summary, for your primary and replica RDS instances:
See below for your revised terraform: