github.com/candidpartners/terraform@v0.9.5-0.20171005231213-29f5f88820f6/examples/aws-count/main.tf (about)

     1  # Specify the provider and access details
     2  provider "aws" {
     3    region = "${var.aws_region}"
     4  }
     5  
     6  resource "aws_elb" "web" {
     7    name = "terraform-example-elb"
     8  
     9    # The same availability zone as our instances
    10    availability_zones = ["${aws_instance.web.*.availability_zone}"]
    11  
    12    listener {
    13      instance_port     = 80
    14      instance_protocol = "http"
    15      lb_port           = 80
    16      lb_protocol       = "http"
    17    }
    18  
    19    # The instances are registered automatically
    20    instances = ["${aws_instance.web.*.id}"]
    21  }
    22  
    23  resource "aws_instance" "web" {
    24    instance_type = "m1.small"
    25    ami           = "${lookup(var.aws_amis, var.aws_region)}"
    26  
    27    # This will create 4 instances
    28    count = 4
    29  }