Skip to content

Instantly share code, notes, and snippets.

@thegedge
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thegedge/7502644c03f69de7f21b to your computer and use it in GitHub Desktop.
Save thegedge/7502644c03f69de7f21b to your computer and use it in GitHub Desktop.
Terraform count on aws_instance resource
variable "instances" {}
variable "flavor" {}
variable "ami" {}
variable "ami_list" {}
resource "aws_instance" "default" {
count = "${var.instances}"
ami = "${var.ami}"
instance_type = "${var.flavor}"
}
resource "aws_instance" "varied" {
count = "${var.instances}"
ami = "${element(split(",", var.ami_list), count.index)}"
instance_type = "${var.flavor}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment