This is just an example of how to pull in buddy IP's, and then assign them to an aws_security_group using terraform.
The procedure is not specific to aws_security_group, and can be used for anything that needs CIDR blocks or multiple IPs
1. First pull in the IPs dynamically using the provided buddy DNS record
data "dns_a_record_set" "buddy_ips" {
host = "workers.buddy.works"
}
2. Inject that into the CIDR blocks, but format the output
resource "aws_security_group" "buddy_works" {
name = "buddy-security-group"
description = "Buddy Security Group"
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = formatlist("%s/32", data.dns_a_record_set.buddy_ips.addrs)
}
}