forked from hashicorp/terraform
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tf
More file actions
44 lines (39 loc) · 954 Bytes
/
main.tf
File metadata and controls
44 lines (39 loc) · 954 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Setup the Consul provisioner to use the demo cluster
provider "consul" {
address = "demo.consul.io:80"
datacenter = "nyc1"
}
# Setup an AWS provider
provider "aws" {
region = "${var.aws_region}"
}
# Setup a key in Consul to provide inputs
resource "consul_keys" "input" {
key {
name = "size"
path = "tf_test/size"
default = "m1.small"
}
}
# Setup a new AWS instance using a dynamic ami and
# instance type
resource "aws_instance" "test" {
ami = "${lookup(var.aws_amis, var.aws_region)}"
instance_type = "${consul_keys.input.var.size}"
}
# Setup a key in Consul to store the instance id and
# the DNS name of the instance
resource "consul_keys" "test" {
key {
name = "id"
path = "tf_test/id"
value = "${aws_instance.test.id}"
delete = true
}
key {
name = "address"
path = "tf_test/public_dns"
value = "${aws_instance.test.public_dns}"
delete = true
}
}