rule.tf 504 Bytes
Newer Older
1
# whitelist an IP
Mike Horwath's avatar
Mike Horwath committed
2
resource "cloudflare_access_rule" "whitelisted_ip" {
Mike Horwath's avatar
Mike Horwath committed
3 4
  count = length(var.whitelist_ips)
  notes = var.notes
Mike Horwath's avatar
Mike Horwath committed
5 6
  mode  = "whitelist"

Mike Horwath's avatar
Mike Horwath committed
7
  configuration = {
Mike Horwath's avatar
Mike Horwath committed
8
    target = "ip_range"
Mike Horwath's avatar
Mike Horwath committed
9
    value  = element(var.whitelist_ips, count.index)
Mike Horwath's avatar
Mike Horwath committed
10 11
  }
}
12 13 14

# blacklist an IP
resource "cloudflare_access_rule" "blacklisted_ip" {
Mike Horwath's avatar
Mike Horwath committed
15 16
  count = length(var.blacklist_ips)
  notes = var.notes
17 18
  mode  = "block"

Mike Horwath's avatar
Mike Horwath committed
19
  configuration = {
20
    target = "ip_range"
Mike Horwath's avatar
Mike Horwath committed
21
    value  = element(var.blacklist_ips, count.index)
22 23
  }
}
Mike Horwath's avatar
Mike Horwath committed
24