Terraform + ec2 discovery (AWS) initial master s

I'd like to create a small ES cluster in AWS with Terraform.

Does anybody have prior experience/a working example where Terraform instantiates 3 master nodes that can connect to each other?

The problem is that for bootstrapping the cluster a list of initial master nodes has to be provided, but I'm not sure how this can be done in Terraform where the IPs or the hostnames of the soon-to-be master nodes are unknown,

Any help is appreciated, thank you!

Edit: I would prefer to use an own version instead of a high level ES module...