-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.tf
29 lines (26 loc) · 1.01 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
data "http" "cloudflare_ipv4" {
url = "https://www.cloudflare.com/ips-v4"
}
data "http" "cloudflare_ipv6" {
url = "https://www.cloudflare.com/ips-v6"
}
resource "aws_security_group_rule" "cloudflare_to_http" {
count = "${var.enable_http ? 1 : 0}"
type = "ingress"
to_port = 80
from_port = 80
protocol = "-1"
cidr_blocks = ["${split("\n",trimspace(data.http.cloudflare_ipv4.body))}"]
ipv6_cidr_blocks = ["${split("\n",trimspace(data.http.cloudflare_ipv6.body))}"]
security_group_id = "${var.security_group_id}"
}
resource "aws_security_group_rule" "cloudflare_to_https" {
count = "${var.enable_https ? 1 : 0}"
type = "ingress"
to_port = 443
from_port = 443
protocol = "-1"
cidr_blocks = ["${split("\n",trimspace(data.http.cloudflare_ipv4.body))}"]
ipv6_cidr_blocks = ["${split("\n",trimspace(data.http.cloudflare_ipv6.body))}"]
security_group_id = "${var.security_group_id}"
}