Following is the terraform script.
variable "vpc_ids" {
default = [
"vpc-**********",
"vpc-**********",
"vpc-**********",
"vpc-**********",
]
type = "list"
}
data "aws_security_groups" "test" {
filter {
name = "vpc-id"
values = "${var.vpc_ids}"
}
}
data "aws_security_group" "selected" {
count = "${length(data.aws_security_groups.test.ids)}"
id = "${element(data.aws_security_groups.test.ids, count.index)}"
}
output "sec_groups" {
value = "${data.aws_security_group.selected.0.description}"
// value = "${join(",", data.aws_security_group.selected.*.description)}"
}
In the last, I am using description but it is not giving the inbound and outbound rules for the security group.
Is anyone know how to ge the inbound and outbound rules using datasource ?
value = "${data.aws_security_group.selected.0.description}"
in this line that index 0 will always fetch the description of the first group and that was intentional for testing purpose. Actually, the problem is that I am not getting the inbound and outbound rules for the security group. I think you got what I am trying to say... – RogerUma