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

0.12 in the house

parent 5b15509a
Pipeline #196 failed with stage
in 19 seconds
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
[Terraform cloudflare_access_rule](https://www.terraform.io/docs/providers/cloudflare/r/access_rule.html) [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. This module will create rules in Cloudflare.
Suggestion: you should use durable state storage. Suggestion: you should use durable state storage.
......
output "whitelist_id" { output "whitelist_id" {
value = ["${cloudflare_access_rule.whitelisted_ip.*.id}"] value = [cloudflare_access_rule.whitelisted_ip.*.id]
} }
output "blacklist_id" { output "blacklist_id" {
value = ["${cloudflare_access_rule.blacklisted_ip.*.id}"] value = [cloudflare_access_rule.blacklisted_ip.*.id]
} }
# does not work # does not work
# output "whitelist_zone_id" { # output "whitelist_zone_id" {
# value = ["${cloudflare_access_rule.whitelisted_ip.*.zone_id}"] # value = ["${cloudflare_access_rule.whitelisted_ip.*.zone_id}"]
# } # }
# whitelist an IP # whitelist an IP
resource "cloudflare_access_rule" "whitelisted_ip" { resource "cloudflare_access_rule" "whitelisted_ip" {
count = "${length(var.whitelist_ips)}" count = length(var.whitelist_ips)
notes = "${var.notes}" notes = var.notes
mode = "whitelist" mode = "whitelist"
configuration { configuration = {
target = "ip_range" target = "ip_range"
value = "${element(var.whitelist_ips, count.index)}" value = element(var.whitelist_ips, count.index)
} }
} }
# blacklist an IP # blacklist an IP
resource "cloudflare_access_rule" "blacklisted_ip" { resource "cloudflare_access_rule" "blacklisted_ip" {
count = "${length(var.blacklist_ips)}" count = length(var.blacklist_ips)
notes = "${var.notes}" notes = var.notes
mode = "block" mode = "block"
configuration { configuration = {
target = "ip_range" target = "ip_range"
value = "${element(var.blacklist_ips, count.index)}" value = element(var.blacklist_ips, count.index)
} }
} }
...@@ -19,11 +19,12 @@ variable "zone" { ...@@ -19,11 +19,12 @@ variable "zone" {
} }
variable "whitelist_ips" { variable "whitelist_ips" {
type = "list" type = list(string)
default = [] default = []
} }
variable "blacklist_ips" { variable "blacklist_ips" {
type = "list" type = list(string)
default = [] default = []
} }
terraform {
required_version = ">= 0.12"
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment