-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from terraform-modules/feature-custom-self-ports
v2.2.2: make ingress_self* work
- Loading branch information
Showing
16 changed files
with
258 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,37 +1,64 @@ | ||
| # ports = list of list of | ||
| # from_port | ||
| # to_port | ||
| # proto | ||
| # description | ||
| # cidr_block | ||
| # list of: all, external (more added as needed) | ||
|
|
||
| # example only. Use your own values as appropraite | ||
|
|
||
| locals { | ||
| n_all = ["0.0.0.0/0"] | ||
| n_census = ["148.129.0.0/16", "192.168.0.0/16", "172.16.0.0/12", "10.0.0.0/8"] | ||
| source_groups = ["all", "external"] | ||
| ports = [] | ||
|
|
||
| ports = [ | ||
| [80, 80, "tcp", "http", local.n_census, ["external"]], | ||
| [443, 443, "tcp", "https", local.n_census, ["external"]], | ||
| [8080, 8080, "tcp", "Tomcat-http", local.n_census, ["external"]], | ||
| [8443, 8443, "tcp", "Tomcat-https", local.n_census, ["external"]], | ||
| ] | ||
| ingress_networks = var.ingress_networks | ||
| egress_networks = var.egress_networks | ||
|
|
||
| # ingress_networks = var.ingress_networks | ||
| ingress_networks = [] | ||
| # egress_networks = var.egress_networks | ||
| egress_networks = local.n_all | ||
|
|
||
| # these are ignored | ||
| ingress_sg = var.ingress_security_groups | ||
| egress_sg = var.egress_security_groups | ||
|
|
||
| p_fields = ["from", "to", "proto", "description", "cidr", "source_group"] | ||
| p_map = [for p in local.ports : zipmap(local.p_fields, p)] | ||
| port_map = { for s in local.source_groups : | ||
| s => [for p in local.p_map : p if contains(p["source_group"], s)] | ||
| # ports | ||
| p_fields = ["from", "to", "proto", "description", "cidr"] | ||
| p_list1 = length(local.ports) > 0 ? [for p in local.ports : zipmap(local.p_fields, p)] : [] | ||
| p_list2 = length(var.ingress_port_list) > 0 ? [for p in var.ingress_port_list : zipmap(local.p_fields, p)] : [] | ||
| p_list3 = length(var.ingress_port_map) > 0 ? var.ingress_port_map : [] | ||
|
|
||
| port_map = { | ||
| "external" = [] | ||
| "module_ports" = local.p_list1 | ||
| "ingress_ports" = local.p_list2 | ||
| "ingress_map" = local.p_list3 | ||
| } | ||
|
|
||
| # self ports | ||
| p_self_fields = ["from", "to", "proto", "description"] | ||
| sp_list1 = length(var.ingress_self_port_list) > 0 ? [for p in var.ingress_self_port_list : zipmap(local.p_self_fields, p)] : [] | ||
| sp_list2 = length(var.ingress_self_port_map) > 0 ? var.ingress_self_port_map : [] | ||
| sp_list3 = length(var.ingress_self_port_list) == 0 && length(var.ingress_self_port_map) == 0 ? local._defaults["self_port_list"] : [] | ||
|
|
||
| self_port_map = { | ||
| "ingress_ports" = local.sp_list1 | ||
| "ingress_map" = local.sp_list2 | ||
| "default" = local.sp_list3 | ||
| } | ||
| } | ||
|
|
||
| # locals { | ||
| # n_all = ["0.0.0.0/0"] | ||
| # n_census = ["148.129.0.0/16", "192.168.0.0/16", "172.16.0.0/12", "10.0.0.0/8"] | ||
| # source_groups = ["all", "external"] | ||
| # | ||
| # ports = [ | ||
| # [80, 80, "tcp", "http", local.n_census, ["external"]], | ||
| # [443, 443, "tcp", "https", local.n_census, ["external"]], | ||
| # [8080, 8080, "tcp", "Tomcat-http", local.n_census, ["external"]], | ||
| # [8443, 8443, "tcp", "Tomcat-https", local.n_census, ["external"]], | ||
| # ] | ||
| # | ||
| # # ingress_networks = var.ingress_networks | ||
| # ingress_networks = [] | ||
| # # egress_networks = var.egress_networks | ||
| # egress_networks = local.n_all | ||
| # | ||
| # # these are ignored | ||
| # ingress_sg = var.ingress_security_groups | ||
| # egress_sg = var.egress_security_groups | ||
| # | ||
| # p_fields = ["from", "to", "proto", "description", "cidr", "source_group"] | ||
| # p_map = [for p in local.ports : zipmap(local.p_fields, p)] | ||
| # port_map = { for s in local.source_groups : | ||
| # s => [for p in local.p_map : p if contains(p["source_group"], s)] | ||
| # } | ||
| # } | ||
| # | ||
| # |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| variable "ingress_port_list" { | ||
| description = "Ingress port list of 5-tuple: from, to, proto, description, and cidr(list)" | ||
| # type = list(tuple([number, number, any, string, list])) | ||
| default = [[]] | ||
| } | ||
|
|
||
| variable "ingress_port_map" { | ||
| description = "Ingress port list of objects: from, to, proto, description and cidr(list)" | ||
| type = list(object({ | ||
| from = number | ||
| to = number | ||
| proto = any | ||
| description = string | ||
| cidr = list(string) | ||
| })) | ||
| default = [] | ||
| } | ||
|
|
||
| variable "ingress_self_port_list" { | ||
| description = "Ingress port list of 4-tuple: from, to, proto, description" | ||
| # type = list(tuple([number, number, any, string])) | ||
| default = [[]] | ||
| } | ||
|
|
||
| variable "ingress_self_port_map" { | ||
| description = "Ingress self access port list of objects: from, to, proto, description" | ||
| type = list(object({ | ||
| from = number | ||
| to = number | ||
| proto = any | ||
| description = string | ||
| })) | ||
| default = [] | ||
| } | ||
|
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| locals { | ||
| _module_version = "2.2.0" | ||
| _module_version = "2.2.2" | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.