github.com/emc-cmd/terraform@v0.7.8-0.20161101145618-f16309630e7c/examples/consul/main.tf (about) 1 # Setup the Consul provisioner to use the demo cluster 2 provider "consul" { 3 address = "demo.consul.io:80" 4 datacenter = "nyc1" 5 } 6 7 # Setup an AWS provider 8 provider "aws" { 9 region = "${var.aws_region}" 10 } 11 12 # Setup a key in Consul to provide inputs 13 resource "consul_keys" "input" { 14 key { 15 name = "size" 16 path = "tf_test/size" 17 default = "m1.small" 18 } 19 } 20 21 # Setup a new AWS instance using a dynamic ami and 22 # instance type 23 resource "aws_instance" "test" { 24 ami = "${lookup(var.aws_amis, var.aws_region)}" 25 instance_type = "${consul_keys.input.var.size}" 26 } 27 28 # Setup a key in Consul to store the instance id and 29 # the DNS name of the instance 30 resource "consul_keys" "test" { 31 key { 32 name = "id" 33 path = "tf_test/id" 34 value = "${aws_instance.test.id}" 35 delete = true 36 } 37 38 key { 39 name = "address" 40 path = "tf_test/public_dns" 41 value = "${aws_instance.test.public_dns}" 42 delete = true 43 } 44 }