Commit 20fe60df authored by Mike Horwath's avatar Mike Horwath
Browse files

0.12 in the house

parent 5b15509a
Loading
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -2,6 +2,8 @@

[Terraform cloudflare_access_rule](https://www.terraform.io/docs/providers/cloudflare/r/access_rule.html)

> **Requires Terraform 0.12 or higher**

This module will create rules in Cloudflare.

Suggestion: you should use durable state storage.
+2 −3
Original line number Diff line number Diff line
output "whitelist_id" {
  value = ["${cloudflare_access_rule.whitelisted_ip.*.id}"]
  value = [cloudflare_access_rule.whitelisted_ip.*.id]
}

output "blacklist_id" {
  value = ["${cloudflare_access_rule.blacklisted_ip.*.id}"]
  value = [cloudflare_access_rule.blacklisted_ip.*.id]
}

# does not work
# output "whitelist_zone_id" {
#   value = ["${cloudflare_access_rule.whitelisted_ip.*.zone_id}"]
# }
+9 −8
Original line number Diff line number Diff line
# whitelist an IP
resource "cloudflare_access_rule" "whitelisted_ip" {
  count = "${length(var.whitelist_ips)}"
  notes = "${var.notes}"
  count = length(var.whitelist_ips)
  notes = var.notes
  mode  = "whitelist"

  configuration {
  configuration = {
    target = "ip_range"
    value  = "${element(var.whitelist_ips, count.index)}"
    value  = element(var.whitelist_ips, count.index)
  }
}

# blacklist an IP
resource "cloudflare_access_rule" "blacklisted_ip" {
  count = "${length(var.blacklist_ips)}"
  notes = "${var.notes}"
  count = length(var.blacklist_ips)
  notes = var.notes
  mode  = "block"

  configuration {
  configuration = {
    target = "ip_range"
    value  = "${element(var.blacklist_ips, count.index)}"
    value  = element(var.blacklist_ips, count.index)
  }
}
+3 −2
Original line number Diff line number Diff line
@@ -19,11 +19,12 @@ variable "zone" {
}

variable "whitelist_ips" {
  type    = "list"
  type    = list(string)
  default = []
}

variable "blacklist_ips" {
  type    = "list"
  type    = list(string)
  default = []
}

versions.tf

0 → 100644
+4 −0
Original line number Diff line number Diff line

terraform {
  required_version = ">= 0.12"
}