generated from dxw/terraform-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Creates a network ACL with ocnfigurable rules * If egress/ingress lockdown is enabled, all traffic will be blocked by default * The ACL is applied to all the subnets created in the infrastructure
- Loading branch information
Showing
4 changed files
with
118 additions
and
0 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
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,71 @@ | ||
resource "aws_network_acl" "infrastructure" { | ||
count = local.infrastructure_vpc ? 1 : 0 | ||
|
||
vpc_id = aws_vpc.infrastructure[0].id | ||
subnet_ids = concat( | ||
local.infrastructure_vpc_network_enable_public ? [for subnet in aws_subnet.infrastructure_public : subnet.id] : [], | ||
local.infrastructure_vpc_network_enable_private ? [for subnet in aws_subnet.infrastructure_private : subnet.id] : [] | ||
) | ||
|
||
dynamic "egress" { | ||
for_each = local.infrastructure_vpc_network_acl_egress_custom_rules | ||
|
||
content { | ||
protocol = egress.value["protocol"] | ||
from_port = egress.value["from_port"] | ||
to_port = egress.value["to_port"] | ||
action = egress.value["action"] | ||
cidr_block = egress.value["cidr_block"] | ||
ipv6_cidr_block = egress.value["ipv6_cidr_block"] | ||
icmp_type = egress.value["icmp_type"] | ||
icmp_code = egress.value["icmp_code"] | ||
rule_no = each.key + 1 | ||
} | ||
} | ||
|
||
dynamic "egress" { | ||
for_each = local.infrastructure_vpc_network_acl_egress_lockdown ? [] : [1] | ||
|
||
content { | ||
protocol = "all" | ||
from_port = 0 | ||
to_port = 0 | ||
action = "allow" | ||
cidr_block = "0.0.0.0/0" | ||
rule_no = length(local.infrastructure_vpc_network_acl_egress_custom_rules) + 1 | ||
} | ||
} | ||
|
||
dynamic "ingress" { | ||
for_each = local.infrastructure_vpc_network_acl_ingress_custom_rules | ||
|
||
content { | ||
protocol = ingress.value["protocol"] | ||
from_port = ingress.value["from_port"] | ||
to_port = ingress.value["to_port"] | ||
action = ingress.value["action"] | ||
cidr_block = ingress.value["cidr_block"] | ||
ipv6_cidr_block = ingress.value["ipv6_cidr_block"] | ||
icmp_type = ingress.value["icmp_type"] | ||
icmp_code = ingress.value["icmp_code"] | ||
rule_no = each.key + 1 | ||
} | ||
} | ||
|
||
dynamic "ingress" { | ||
for_each = local.infrastructure_vpc_network_acl_ingress_lockdown ? [] : [1] | ||
|
||
content { | ||
protocol = "all" | ||
from_port = 0 | ||
to_port = 0 | ||
action = "allow" | ||
cidr_block = "0.0.0.0/0" | ||
rule_no = length(local.infrastructure_vpc_network_acl_ingress_custom_rules) + 1 | ||
} | ||
} | ||
|
||
tags = { | ||
Name = "${local.resource_prefix}-infrastructure" | ||
} | ||
} |