Skip to content

Commit 1832f41

Browse files
author
Noel Dcosta
authored
Allow public ingress from anywhere to ports 80 and 443 (#205)
* Allow public ingress from anywhere to ports 80 and 443 Signed-off-by: Noel Dcosta <[email protected]> * Support to specify custom list of destination ports for public LB security list Signed-off-by: Noel Dcosta <[email protected]> * updated docs for public_lb_ports Signed-off-by: Noel Dcosta <[email protected]> * Updated order of variables Signed-off-by: Noel Dcosta <[email protected]> * Set variable type for public_lb_ports Signed-off-by: Noel Dcosta <[email protected]> * Updated terraform options doc Signed-off-by: Noel Dcosta <[email protected]>
1 parent 256a129 commit 1832f41

File tree

7 files changed

+38
-6
lines changed

7 files changed

+38
-6
lines changed

docs/configuration.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ The OKE Load Balancer parameters concern mainly the following:
195195

196196
. the preferred Availability Domain you want to place the load balancers
197197
. the type of load balancer (public/internal)
198+
. the list of destination ports to allow for public ingress
198199

199200
Even if you set the load balancer subnets to be internal, you still need to set the correct {uri-oci-loadbalancer-annotations}[annotations] when creating internal load balancers. Just setting the subnet to be private is *_not_* sufficient.
200201

docs/terraformoptions.adoc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ newbits = {
205205

206206
|`bastion_access`
207207
|CIDR block in the form of a string to which ssh access to the bastion must be restricted to. *_ANYWHERE_* is equivalent to 0.0.0.0/0 and allows ssh access from anywhere.
208-
|XXX.XXX.XXX.XXX/YY
208+
|XYZ.XYZ.XYZ.XYZ/YZ
209209
|ANYWHERE
210210

211211
|`bastion_enabled`
@@ -555,6 +555,11 @@ Refer to {uri-topology}[topology] for more thorough examples.
555555
|internal/public
556556
|public
557557

558+
|`public_lb_ports`
559+
|The list of destination ports to allow for public ingress.
560+
|`e.g.: [80,443,8080]`
561+
|`[80, 443]`
562+
558563
|`waf_enabled`
559564
|Whether to enable WAF monitoring and protection of public load balancers.
560565
|true/false

main.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,12 @@ module "network" {
6868
# oke load balancer network parameters
6969
lb_subnet_type = var.lb_subnet_type
7070

71+
# oke load balancer ports
72+
public_lb_ports = var.public_lb_ports
73+
7174
# waf integration
7275
waf_enabled = var.waf_enabled
76+
7377
}
7478

7579
# cluster creation for oke

modules/okenetwork/security.tf

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,20 @@ resource "oci_core_security_list" "pub_lb_seclist_wo_waf" {
233233
stateless = false
234234
}
235235

236-
ingress_security_rules {
237-
description = "allow public ingress from anywhere"
238-
protocol = local.tcp_protocol
239-
source = local.anywhere
240-
stateless = false
236+
dynamic "ingress_security_rules" {
237+
iterator = pub_lb_ingress_iterator
238+
for_each = var.public_lb_ports
239+
240+
content {
241+
description = "allow public ingress from anywhere on specified ports"
242+
protocol = local.tcp_protocol
243+
source = local.anywhere
244+
tcp_options {
245+
min = pub_lb_ingress_iterator.value
246+
max = pub_lb_ingress_iterator.value
247+
}
248+
stateless = false
249+
}
241250
}
242251

243252
count = ((var.lb_subnet_type == "public" || var.lb_subnet_type == "both") && var.waf_enabled == false) ? 1 : 0

modules/okenetwork/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ variable "lb_subnet_type" {
3535
type = string
3636
}
3737

38+
variable "public_lb_ports" {
39+
type = list(number)
40+
}
41+
3842
variable "waf_enabled" {
3943
type = bool
4044
}
45+

terraform.tfvars.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ lb_subnet_type = "public"
164164

165165
preferred_lb_subnets = "public"
166166

167+
public_lb_ports = [80, 443]
168+
167169
waf_enabled = false
168170

169171
# ocir

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,12 @@ variable "preferred_lb_subnets" {
367367
type = string
368368
}
369369

370+
variable "public_lb_ports" {
371+
default = [80, 443]
372+
description = "List of destination ports for public LB security list."
373+
type = list(number)
374+
}
375+
370376
# ocir
371377
variable "secret_id" {
372378
description = "OCID of Oracle Vault Secret"

0 commit comments

Comments
 (0)