forked from hashicorp-modules/consul-server-ports-aws
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
57 lines (47 loc) · 2 KB
/
main.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
terraform {
required_version = ">= 0.11.6"
}
# https://www.consul.io/docs/agent/options.html#ports
module "consul_client_ports_aws" {
source = "github.com/Roviluca/consul-client-ports-aws"
create = "${var.create}"
name = "${var.name}"
vpc_id = "${var.vpc_id}"
cidr_blocks = "${var.cidr_blocks}"
tags = "${var.tags}"
}
# Server RPC (Default 8300) - TCP. This is used by servers to handle incoming requests from other agents on TCP only.
resource "aws_security_group_rule" "server_rpc_tcp" {
count = "${var.create ? 1 : 0}"
security_group_id = "${module.consul_client_ports_aws.consul_client_sg_id}"
type = "ingress"
protocol = "tcp"
from_port = 8300
to_port = 8300
cidr_blocks = ["${var.cidr_blocks}"]
}
# As of Consul 0.8, it is recommended to enable connection between servers through port 8302 for both
# TCP and UDP on the LAN interface as well for the WAN Join Flooding feature. See also: Consul 0.8.0
# CHANGELOG and GH-3058
# https://github.com/hashicorp/consul/blob/master/CHANGELOG.md#080-april-5-2017
# https://github.com/hashicorp/consul/issues/3058
# Serf WAN (Default 8302) - TCP. This is used by servers to gossip over the WAN to other servers on TCP and UDP.
resource "aws_security_group_rule" "serf_wan_tcp" {
count = "${var.create ? 1 : 0}"
security_group_id = "${module.consul_client_ports_aws.consul_client_sg_id}"
type = "ingress"
protocol = "tcp"
from_port = 8302
to_port = 8302
cidr_blocks = ["${var.cidr_blocks}"]
}
# Serf WAN (Default 8302) - UDP. This is used by servers to gossip over the WAN to other servers on TCP and UDP.
resource "aws_security_group_rule" "serf_wan_udp" {
count = "${var.create ? 1 : 0}"
security_group_id = "${module.consul_client_ports_aws.consul_client_sg_id}"
type = "ingress"
protocol = "udp"
from_port = 8302
to_port = 8302
cidr_blocks = ["${var.cidr_blocks}"]
}