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?
Asked
Active
Viewed 8,323 times
3 Answers
3
You can retrieve security group from data source
variable "security_group_id" {}
data "aws_security_group" "selected" {
id = "${var.security_group_id}"
}
Vasiliy Shakhunov
- 359
- 1
- 10
0
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" ]
Daniel Johns
- 113
- 1
- 5
0
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
myron-semack
- 111
- 4