github.com/ndarilek/terraform@v0.3.8-0.20150320140257-d3135c1b2bac/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 key { 38 name = "address" 39 path = "tf_test/public_dns" 40 value = "${aws_instance.test.public_dns}" 41 delete = true 42 } 43 }