|
@@ -13,11 +13,17 @@ locals {
|
|
|
# allows, and inbound_from_tag_rules is empty by default. When it lists
|
|
# allows, and inbound_from_tag_rules is empty by default. When it lists
|
|
|
# something, each rule admits only droplets that carry this firewall's own tag
|
|
# something, each rule admits only droplets that carry this firewall's own tag
|
|
|
# (source_tags), never an address, so nothing outside the tagged group gets in.
|
|
# (source_tags), never an address, so nothing outside the tagged group gets in.
|
|
|
|
|
+# The sending side is the other half: DigitalOcean allows outbound traffic only
|
|
|
|
|
+# when an outbound rule permits it (replies to an admitted connection are
|
|
|
|
|
+# stateful, a new connection is not), so outbound_to_tag_rules opens the same
|
|
|
|
|
+# kind of rule outward, to droplets carrying this firewall's own tag
|
|
|
|
|
+# (destination_tags), never to an address.
|
|
|
#
|
|
#
|
|
|
-# Trivy DIG-0003 flags egress to any address. It is accepted here: outbound is
|
|
|
|
|
-# restricted to specific ports (never "all"), inbound is zero unless a rule
|
|
|
|
|
-# admits the firewall's own tag, and the hosts these droplets must reach
|
|
|
|
|
-# (Twingate relays, package mirrors, DNS and NTP servers) have no fixed
|
|
|
|
|
|
|
+# Trivy DIG-0003 flags egress to any address. It is accepted here: the
|
|
|
|
|
+# any-address outbound rules are restricted to specific ports (never "all"),
|
|
|
|
|
+# inbound is zero unless a rule admits the firewall's own tag, tag-scoped
|
|
|
|
|
+# outbound rules name no address at all, and the hosts these droplets must
|
|
|
|
|
+# reach (Twingate relays, package mirrors, DNS and NTP servers) have no fixed
|
|
|
# addresses, so there is no address list to pin.
|
|
# addresses, so there is no address list to pin.
|
|
|
#trivy:ignore:AVD-DIG-0003
|
|
#trivy:ignore:AVD-DIG-0003
|
|
|
resource "digitalocean_firewall" "this" {
|
|
resource "digitalocean_firewall" "this" {
|
|
@@ -41,4 +47,13 @@ resource "digitalocean_firewall" "this" {
|
|
|
destination_addresses = ["0.0.0.0/0", "::/0"]
|
|
destination_addresses = ["0.0.0.0/0", "::/0"]
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ dynamic "outbound_rule" {
|
|
|
|
|
+ for_each = var.outbound_to_tag_rules
|
|
|
|
|
+ content {
|
|
|
|
|
+ protocol = outbound_rule.value.protocol
|
|
|
|
|
+ port_range = outbound_rule.value.port_range
|
|
|
|
|
+ destination_tags = [var.tag]
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|