Is there a way I can associate existing security group to RDS that is going to be created or the only way is to recreate the security group so it can be added to the state file?
You can retrieve security group from data source
variable "security_group_id" {}
data "aws_security_group" "selected" {
id = "${var.security_group_id}"
}
I didn't use list square brackets, the functionality is there as documented, just list brackets and group id. e.g.: vpc_security_group_ids = [ "sg-dfe8e2bf" ]
You can use the terraform import command to import the security group so you can reference it as a created Terraform resource.
https://www.terraform.io/docs/providers/aws/r/security_group.html