-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathconsul.tf
72 lines (68 loc) · 1.52 KB
/
consul.tf
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
##
# Consul cluster setup
##
resource "aws_security_group" "consul" {
name = "consul"
description = "Consul internal traffic + maintenance."
vpc_id = "${aws_vpc.test.id}"
ingress {
from_port = 53
to_port = 53
protocol = "tcp"
self = true
}
ingress {
from_port = 53
to_port = 53
protocol = "udp"
self = true
}
ingress {
from_port = 8300
to_port = 8302
protocol = "tcp"
self = true
}
ingress {
from_port = 8301
to_port = 8302
protocol = "udp"
self = true
}
ingress {
from_port = 8400
to_port = 8400
protocol = "tcp"
self = true
}
ingress {
from_port = 8500
to_port = 8500
protocol = "tcp"
self = true
}
}
resource "aws_instance" "consul" {
depends_on = [ "aws_instance.bastion" ]
connection {
user = "ec2-user"
key_file = "${var.key_path}"
}
ami = "${lookup(var.amazon_amis, var.region)}"
instance_type = "t2.micro"
count = 3
key_name = "${var.key_name}"
security_groups = [
"${aws_security_group.allow_bastion.id}",
"${aws_security_group.consul.id}"
]
subnet_id = "${aws_subnet.private.id}"
private_ip = "10.0.1.1${count.index}"
tags = {
Name = "consul${count.index}"
subnet = "private"
role = "dns"
environment = "test"
}
user_data = "${file(\"files/consul/cloud-init.txt\")}"
}