I am trying to create a read replica for existing aurora postgres cluster using terraform. This is the script I use.
resource "aws_rds_cluster" "test_db_cluster" {
cluster_identifier = "${var.base_name}-read-replica"
engine = "aurora-postgresql"
engine_mode = "provisioned"
engine_version = "16.1"
skip_final_snapshot = true
storage_encrypted = true
replication_source_identifier = "arn:aws:rds:us-east-1:<xxx>:cluster:testdev"
source_region = "us-east-1"
}
But it gives the following error.
InvalidParameterCombination: The DB engine aurora-postgresql doesn't support cross-region read replicas.
Original aurora cluster is in the same region us-east-1. I tried with and without source_region but it gives the same error.
Terraform version: ~> 4.0
Original cluster also created using a terraform script. This is it.
resource "aws_rds_cluster" "test_db_cluster" {
cluster_identifier = var.base_name
engine = "aurora-postgresql"
engine_mode = "provisioned"
engine_version = "16.1"
database_name = var.database_name
master_username = var.master_username
db_subnet_group_name = var.subnet_group
vpc_security_group_ids = [var.security_group_id]
availability_zones = [var.az]
skip_final_snapshot = true
storage_encrypted = true
manage_master_user_password = true
master_user_secret_kms_key_id = aws_kms_key.scopp_db_kms.key_id
serverlessv2_scaling_configuration {
max_capacity = var.max_capacity
min_capacity = var.min_capacity
}
}
resource "aws_rds_cluster_instance" "test_db_instance" {
identifier = "${var.base_name}-instance-1"
cluster_identifier = aws_rds_cluster.test_db_cluster.id
instance_class = "db.serverless"
engine = aws_rds_cluster.test_db_cluster.engine
engine_version = aws_rds_cluster.test_db_cluster.engine_version
performance_insights_enabled = true
}
resource "aws_kms_key" "test_db_kms" {
description = "Test DB KMS Key"
}
What is the issue here ?
I'm my case, (single region app) I was confused, double checking the API documentation I learned: be careful that-
replication_source_identifierrequires an global arn, not a regional db instance identifer argument.the cross region error means to complain that when it parsed (or falled to parse) this arn, the region specified in the Arn doesn't match the AWS region the API call is made against.