forked from garutilorenzo/k3s-oci-cluster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnsg.tf
99 lines (80 loc) · 2.71 KB
/
nsg.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
resource "oci_core_network_security_group" "public_lb_nsg" {
compartment_id = var.compartment_ocid
vcn_id = oci_core_vcn.default_oci_core_vcn.id
display_name = "K3s public LB nsg"
freeform_tags = {
"provisioner" = "terraform"
"environment" = "${var.environment}"
"${var.unique_tag_key}" = "${var.unique_tag_value}"
}
}
resource "oci_core_network_security_group_security_rule" "allow_http_from_all" {
network_security_group_id = oci_core_network_security_group.public_lb_nsg.id
direction = "INGRESS"
protocol = 6 # tcp
description = "Allow HTTP from all"
source = "0.0.0.0/0"
source_type = "CIDR_BLOCK"
stateless = false
tcp_options {
destination_port_range {
max = var.http_lb_port
min = var.http_lb_port
}
}
}
resource "oci_core_network_security_group_security_rule" "allow_https_from_all" {
network_security_group_id = oci_core_network_security_group.public_lb_nsg.id
direction = "INGRESS"
protocol = 6 # tcp
description = "Allow HTTPS from all"
source = "0.0.0.0/0"
source_type = "CIDR_BLOCK"
stateless = false
tcp_options {
destination_port_range {
max = var.https_lb_port
min = var.https_lb_port
}
}
}
resource "oci_core_network_security_group" "lb_to_instances" {
compartment_id = var.compartment_ocid
vcn_id = oci_core_vcn.default_oci_core_vcn.id
display_name = "Public LB to Compute Instances NSG"
freeform_tags = {
"provisioner" = "terraform"
"environment" = "${var.environment}"
"${var.unique_tag_key}" = "${var.unique_tag_value}"
}
}
resource "oci_core_network_security_group_security_rule" "nsg_to_instances_http" {
network_security_group_id = oci_core_network_security_group.lb_to_instances.id
direction = "INGRESS"
protocol = 6 # tcp
description = "Allow HTTP from all"
source = oci_core_network_security_group.public_lb_nsg.id
source_type = "NETWORK_SECURITY_GROUP"
stateless = false
tcp_options {
destination_port_range {
max = var.http_lb_port
min = var.http_lb_port
}
}
}
resource "oci_core_network_security_group_security_rule" "nsg_to_instances_https" {
network_security_group_id = oci_core_network_security_group.lb_to_instances.id
direction = "INGRESS"
protocol = 6 # tcp
description = "Allow HTTPS from all"
source = oci_core_network_security_group.public_lb_nsg.id
source_type = "NETWORK_SECURITY_GROUP"
stateless = false
tcp_options {
destination_port_range {
max = var.https_lb_port
min = var.https_lb_port
}
}
}