0
votes

I am trying to create a read replica of an rds database in a different region via terraform. I am able to achieve via the AWS console, however when applying through Terraform (0.14.10) the apply fails with the following:

Error: Error creating DB Instance: InvalidParameterCombination: The DB instance and EC2 security group are in different VPCs. The DB instance is in vpc-xxx and the EC2 security group is in vpc-yyy

TF block:

resource "aws_db_instance" "replica" {
   count                  = var.enable_peering_read_replica ? 1 : 0
   name                   = db-replica
   identifier             = db-replica
   replicate_source_db    = source-db
   instance_class         = "db.t3.small"
   apply_immediately      = true
   publicly_accessible    = false
   skip_final_snapshot    = true
   vpc_security_group_ids = [aws_security_group.peering_sg.id]
}

For the replicate_source_db I have used the arn and the db name, but still get the same error.

1
What is the full resource code and the exact error message?Marcin
Updated with the TF source and full erroreinonsy
You Have to provide full code with vpc and your security groupsMarcin

1 Answers

0
votes

The error msg is clear: Your DB and the security group are in different VPCs. This means that you can't associate them. Your security group aws_security_group.peering_sg.id (definition not shown) must be in the same VPC as your DB.