workload_web.tf 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # SPDX-License-Identifier: Apache-2.0
  2. # Optional workload web ports (issue #437). Empty by default, so nothing here
  3. # exists. Each listed port gets one Twingate resource on the droplet's private
  4. # address, built like the ssh and Portainer resources in main.tf, and one
  5. # firewall allowance from the connector tag; main.tf adds the rules from
  6. # local.workload_web_firewall_rules. Nothing is applied and the stage is not
  7. # approved: the master switch still gates everything.
  8. locals {
  9. # Empty unless the master switch is on, so the switch off means no resource.
  10. workload_web_ports = var.workload_enabled ? { for p in var.workload_web_ports : tostring(p) => p } : {}
  11. workload_web_firewall_rules = [
  12. for p in var.workload_web_ports : { protocol = "tcp", port_range = tostring(p), tag = var.connector_tag }
  13. ]
  14. }
  15. resource "twingate_resource" "workload_web" {
  16. for_each = local.workload_web_ports
  17. name = "cah-${local.resource_key}-workload-web-${each.key}"
  18. address = module.workload[0].private_ip
  19. remote_network_id = var.remote_network_id
  20. access_group {
  21. group_id = var.admin_group_id
  22. }
  23. protocols = {
  24. allow_icmp = false
  25. tcp = {
  26. policy = "RESTRICTED"
  27. ports = [each.key]
  28. }
  29. udp = {
  30. policy = "DENY_ALL"
  31. }
  32. }
  33. }