Network ACLs with the Return Rules They Need
Network ACLs are stateless, which is why most of them do not work: the reply to an allowed outbound connection is a new inbound packet nothing lets in. This generates the matching ephemeral-range rule for every TCP and UDP allow.
Verification
Static-verifiedPassed: validated and lint-clean (provider-schema-validated for AWS/Azure/GCP; Terraform-language lint elsewhere).
Conformance
- Static validation (fmt · validate · tflint)
- Security scan clean (Checkov)
- Plan tests (mocked: validation rules · outputs)
Provenance
- SHA-256 checksum
- Signature (pending)
Functional
- Live test pending (no cloud run yet)
Last verified 2026-09-12 · how we verify
Use it from the registry
terraform · opentofumodule "network_acl" {
source = "www.iac-bazaar.com/iac-bazaar/aws-network-acl/aws"
version = "1.0.0"
}Needs a registry token from /account/tokens. The module itself is free; the account is what identifies you. Full setup: registry docs.
Inputs & outputs
Create a free account to read this module's contract
The declared contract - every input name, type, default and description, plus every output - is shown to signed-in accounts, not to anonymous visitors.
A free account sees the contract of every module in the catalogue. There is no subscription and nothing to buy - the modules are free to download, and they run under Vizier.
Documentation
aws-network-acl
A network ACL, its rules, and the return-traffic rules a stateless filter
needs. Works with Terraform and OpenTofu (>= 1.6), AWS provider
>= 6.0, < 7.0.
Network ACLs are stateless, and that is the cause of essentially every one that "does not work". The reply to an allowed outbound connection is a new inbound packet - from the destination's port, to an ephemeral port on the client - and nothing lets it in unless a rule says so. Allow 443 outbound, forget ports 1024-65535 inbound, and the handshake completes in one direction and nothing ever comes back.
So this module generates the matching return rule for every TCP and UDP
allow rule: opposite direction, ephemeral range, same peer, at
number + return_rule_offset. return_traffic = false turns it off where you
mean strictly one-way, and denies and ICMP never get one. The
generated_return_rules output lists them by name - if it is empty and you
expected replies, nothing is letting them back in.
Attaching a custom ACL to a subnet is an instant outage if the rules are not
there yet. A custom ACL denies everything until told otherwise, unlike the
default one which allows everything. The subnet associations are their own
resource and depends_on the rules, so within a single apply the ACL is
populated before any subnet moves onto it.
Other things the module refuses rather than lets you discover:
- Two rules at the same number in the same direction - AWS keeps whichever was written last, and the plan shows no conflict at all
- A rule number of 32767, which is the implicit deny
- A rule with both or neither of
cidr_blockandipv6_cidr_block - A TCP or UDP rule with no ports
Rules are evaluated lowest number first and first match wins, so a broad allow at 100 makes a narrow deny at 200 unreachable. The example leaves gaps of 100 for that reason.
Verification
Static validation runs tofu fmt, init, validate, tflint and checkov.
This module has not yet had a live test, so it is published as statically
validated with its live test pending and does not carry the live-tested mark.
Usage code & full reference need an account
The complete copy-paste usage, the full input/output reference, and operational notes are free with an account - shown here and bundled in the download. Sign in and this section fills in.
- One suppressed policy, and why
- Usage
Related modules
aws-client-vpn
Remote-access VPN endpoint with certificate or SAML authentication, split tunnelling, per-group authorization rules and connection logging. There is no allow-all shortcut: an endpoint with no rule reaches nothing.
aws-cloud-map
Private DNS, public DNS or API-only namespaces and the services registered in them. Documents the health-check trap: a private namespace gets a custom check that something else must update, and one nobody updates reports healthy forever.
aws-cloud-wan
A global network whose segments, routing and attachment placement live in one policy document rather than per-region route tables. The policy VERSION is executed as a second step, so a change cannot report success while the network still runs the previous one.
aws-direct-connect
Gateway, connections, virtual interfaces and associations. A private circuit is a private path, not a private conversation: traffic crosses it in clear text unless MACsec is on, and should_encrypt quietly falls back to clear text.
aws-vpc
Battle-tested multi-AZ VPC with public/private/database subnets, NAT, endpoints, and flow logs.
aws-site-to-site-vpn
Customer gateway, IPsec connection and routes, attached to a VPN gateway or a Transit Gateway. IKEv2 only, DH group 14 and above, AES-256 and SHA-2 - the API still permits DH 2, AES-128 and SHA-1.