Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Terraform based repositories
Cloudflare Access Rule Module
Commits
87295a58
Commit
87295a58
authored
May 23, 2019
by
Mike Horwath
Browse files
terraform 0.12
parent
c7c5e79e
Changes
3
Hide whitespace changes
Inline
Side-by-side
outputs.tf
View file @
87295a58
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}"]
# }
rule.tf
View file @
87295a58
# 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
)
}
}
variables.tf
View file @
87295a58
...
...
@@ -19,11 +19,12 @@ variable "zone" {
}
variable
"whitelist_ips"
{
type
=
"
list
"
type
=
list
(
string
)
default
=
[]
}
variable
"blacklist_ips"
{
type
=
"
list
"
type
=
list
(
string
)
default
=
[]
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment