I’ve tried using both the identifier and the id for the source db, but both fail with this error:
aws_db_instance.rds_instance: Still creating... [14m20s elapsed]
aws_db_instance.rds_instance: Creation complete after 14m25s [id=db-M3COF64VUY3YAPLEDHRCSBL2WQ]
╷
│ Error: creating RDS DB Instance (read replica) (terraform-20231231212917764100000001): DBInstanceNotFound: The source instance could not be found: rds-db
│ status code: 404, request id: 87ed0efb-32aa-4c38-9916-410927b412e4
│
│ with aws_db_instance.example_read_replica,
Here’s my code:
resource "aws_db_instance" "rds_instance" {
engine = "postgres"
engine_version = "15.4"
instance_class = "db.t3.micro"
identifier = "rds-db"
username = "rootuser"
password = "adminpwd"
parameter_group_name = "pg15"
backup_retention_period = 5
multi_az = true
publicly_accessible = true
vpc_security_group_ids = [aws_security_group.rds_sg.id]
db_subnet_group_name = aws_db_subnet_group.rds_db_subnet_group.name
allocated_storage = 20
skip_final_snapshot = true
tags = {
Name = "rds-db"
}
}
resource "aws_db_instance" "example_read_replica" {
replicate_source_db = "rds-db"
# replicate_source_db = aws_db_instance.rds_instance.id
# Set to false for read replica
multi_az = false
instance_class = "db.t3.micro"
}