Functions¶
element¶
element retrieves a single element from a list.
element(list, index)
> element(["a", "b", "c"], 1)
b
index¶
index finds the element index for a given value in a list.
> index(["a", "b", "c"], "b")
1
lookup¶
lookup retrieves the value of a single element from a map, given its key. If the given key does not exist, a the given default value is returned instead.
> lookup({a="ay", b="bee"}, "a", "what?")
ay
> lookup({a="ay", b="bee"}, "c", "what?")
what?
random_shuffle¶
data "aws_subnet_ids" "all" {
vpc_id = "${var.vpc_id}"
}
output "SubnetIDs" {
value = "${data.aws_subnet_ids.all.ids}"
}
resource "random_shuffle" "az" {
input = ["${data.aws_subnet_ids.all.ids}"]
result_count = 1
}
output "SubnetID" {
value = "${random_shuffle.az.result}"
}
output "SubnetID" {
value = "${element("${data.aws_subnet_ids.all.ids}", 4)}"
}