Skip to content

v1.1.0: enable ingress and egress networks to function #20

Merged
merged 3 commits into from
Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# v1.0.0 -- 20210604
- add module version, update tags

# v1.1.0 -- 20210915
- enable use of ingress_networks and egress_networks for pre-defined port list
6 changes: 4 additions & 2 deletions web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ module "web" {
vpc_id = var.vpc_id
## optional
# name = "m-web"
# ingress_networks = [ "1.2.3.0/24" ]
# egress_networks = [ "1.2.3.0/24" ]
## tags for Name, CostAllocation, and Environment are pre-set, but they can be overriden
# tags = { }
Expand Down Expand Up @@ -55,10 +57,10 @@ No modules.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_description"></a> [description](#input\_description) | Security Group Description | `string` | `"Web Security Group"` | no |
| <a name="input_egress_networks"></a> [egress\_networks](#input\_egress\_networks) | List of egress networks (all ports) | `list(string)` | <pre>[<br> "0.0.0.0/0"<br>]</pre> | no |
| <a name="input_egress_networks"></a> [egress\_networks](#input\_egress\_networks) | List of egress networks (with all pre-defined egress ports) | `list(string)` | `[]` | no |
| <a name="input_egress_security_groups"></a> [egress\_security\_groups](#input\_egress\_security\_groups) | List of egress security groups (all ports) | `list(string)` | `[]` | no |
| <a name="input_enable_self"></a> [enable\_self](#input\_enable\_self) | Enable\|Disable self full access | `bool` | `false` | no |
| <a name="input_ingress_networks"></a> [ingress\_networks](#input\_ingress\_networks) | List of ingress networks for external access (not all ports) | `list(string)` | <pre>[<br> "0.0.0.0/0"<br>]</pre> | no |
| <a name="input_ingress_networks"></a> [ingress\_networks](#input\_ingress\_networks) | List of ingress networks for access (with all pre-defined ingress ports) | `list(string)` | `[]` | no |
| <a name="input_ingress_security_groups"></a> [ingress\_security\_groups](#input\_ingress\_security\_groups) | List of ingress security groups for all ports | `list(string)` | `[]` | no |
| <a name="input_name"></a> [name](#input\_name) | Security Group Name | `string` | `"m-web"` | no |
| <a name="input_short_description"></a> [short\_description](#input\_short\_description) | Security Group Short Description | `string` | `"Web"` | no |
Expand Down
6 changes: 4 additions & 2 deletions web/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
* vpc_id = var.vpc_id
* ## optional
* # name = "m-web"
* # ingress_networks = [ "1.2.3.0/24" ]
* # egress_networks = [ "1.2.3.0/24" ]
*
* ## tags for Name, CostAllocation, and Environment are pre-set, but they can be overriden
* # tags = { }
Expand Down Expand Up @@ -65,7 +67,7 @@ resource "aws_security_group" "this_security_group" {
from_port = p.value["from"]
to_port = p.value["to"]
protocol = p.value["proto"]
cidr_blocks = length(p.value["cidr"]) == 0 ? local.external_ingress_networks : p.value["cidr"]
cidr_blocks = length(p.value["cidr"]) == 0 ? flatten(compact(concat(local.external_ingress_networks, var.ingress_networks))) : flatten(compact(concat(p.value["cidr"], var.ingress_networks)))
}
}

Expand Down Expand Up @@ -101,7 +103,7 @@ resource "aws_security_group" "this_security_group" {
from_port = 0
to_port = 0
protocol = -1
cidr_blocks = local.egress_networks
cidr_blocks = flatten(compact(concat(local.egress_networks, var.egress_networks)))
}

# egress security group ids (all)
Expand Down
1 change: 0 additions & 1 deletion web/ports.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ locals {
[8443, 8443, "tcp", "Tomcat-https", local.n_census, ["external"]],
]

# these are ignored
ingress_networks = var.ingress_networks
egress_networks = var.egress_networks

Expand Down
8 changes: 4 additions & 4 deletions web/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ variable "vpc_full_name" {
}

variable "ingress_networks" {
description = "List of ingress networks for external access (not all ports)"
description = "List of ingress networks for access (with all pre-defined ingress ports)"
type = list(string)
default = ["0.0.0.0/0"]
default = []
}

variable "egress_networks" {
description = "List of egress networks (all ports)"
description = "List of egress networks (with all pre-defined egress ports)"
type = list(string)
default = ["0.0.0.0/0"]
default = []
}

variable "ingress_security_groups" {
Expand Down
2 changes: 1 addition & 1 deletion web/version.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
locals {
_module_version = "1.0.0"
_module_version = "1.1.0"
}