Support for Instance creation across Availability Zones while using count. So for example specify what AZ's are in play and set count to 2. During instance creation terraform will evenly create distribute instance across AZ's
If you enumerate the list of AZs in a comma delimited list as a variable, you can use the count and the split/lookup feature to grab the "associated" AZ from there. In addition, the lookup function will roll over to the start if the count exceeds the length of the array which allows you to "round robin" between all of your AZs
Would you be able to provide an example? Thanks in advance.
On Apr 21, 2016, at 17:24, Justin Nauman [email protected] wrote:
If you enumerate the list of AZs in a comma delimited list as a variable, you can use the count and the split/lookup feature to grab the "associated" AZ from there. In addition, the lookup function will roll over to the start if the count exceeds the length of the array which allows you to "round robin" between all of your AZs
—
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
resource "aws_instance" "mongo" {
count = "${var.instance_count}"
ami = "${var.ami}"
instance_type = "${var.instance_type}"
key_name = "${var.key_name}"
iam_instance_profile = "${var.iam_instance_profile}"
user_data = "${template_file.userdata.rendered}"
subnet_id = "${element(split(",",var.data_subnet_ids),count.index)}"
vpc_security_group_ids = ["${aws_security_group.mongo.id}"]
}
Hi @davyt10! @jrnt30's example is correct - you can use element, count.index and a list of availability zones to distribute among here. Another way to achieve this is to use an autoscaling group. If you have any further questions here please feel free to reopen the issue!
I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment