Provides Lists (IPs, Redirects, Hostname, ASNs) to be used in Edge Rules Engine across all zones within the same account.
# IP list
resource "cloudflare_list" "example" {
account_id = "f037e56e89293a057740de681ac9abbe"
name = "example_list"
description = "example IPs for a list"
kind = "ip"
item {
value {
ip = "192.0.2.0"
}
comment = "one"
}
item {
value {
ip = "192.0.2.1"
}
comment = "two"
}
}
# Redirect list
resource "cloudflare_list" "example" {
account_id = "f037e56e89293a057740de681ac9abbe"
name = "example_list"
description = "example redirects for a list"
kind = "redirect"
item {
value {
redirect {
source_url = "example.com/blog"
target_url = "https://blog.example.com"
}
}
comment = "one"
}
item {
value {
redirect {
source_url = "example.com/foo"
target_url = "https://foo.example.com"
include_subdomains = "enabled"
subpath_matching = "enabled"
status_code = 301
preserve_query_string = "enabled"
preserve_path_suffix = "disabled"
}
}
comment = "two"
}
}
# ASN list
resource "cloudflare_list" "example" {
account_id = "f037e56e89293a057740de681ac9abbe"
name = "example_list"
description = "example ASNs for a list"
kind = "asn"
item {
value {
asn = 677
}
comment = "one"
}
item {
value {
asn = 989
}
comment = "two"
}
}
# Hostname list
resource "cloudflare_list" "example" {
account_id = "f037e56e89293a057740de681ac9abbe"
name = "example_list"
description = "example hostnames for a list"
kind = "hostname"
item {
value {
hostname {
url_hostname = "example.com"
}
}
comment = "one"
}
item {
value {
hostname {
url_hostname = "*.example.com"
}
}
comment = "two"
}
}
account_id
(String) The account identifier to target for the resource.kind
(String) The type of items the list will contain. Available values: ip
, redirect
, hostname
, asn
. Modifying this attribute will force creation of a new resource.name
(String) The name of the list. Modifying this attribute will force creation of a new resource.description
(String) An optional description of the list.item
(Block Set) (see below for nested schema)id
(String) The ID of this resource.item
Required:
value
(Block List, Min: 1, Max: 1) (see below for nested schema)Optional:
comment
(String) An optional comment for the item.item.value
Optional:
asn
(Number)hostname
(Block List) (see below for nested schema)ip
(String)redirect
(Block List) (see below for nested schema)item.value.hostname
Required:
url_hostname
(String) The FQDN to match on. Wildcard sub-domain matching is allowed. Eg. *.abc.com.item.value.redirect
Required:
source_url
(String) The source url of the redirect.target_url
(String) The target url of the redirect.Optional:
include_subdomains
(String) Whether the redirect also matches subdomains of the source url. Available values: disabled
, enabled
.preserve_path_suffix
(String) Whether to preserve the path suffix when doing subpath matching. Available values: disabled
, enabled
.preserve_query_string
(String) Whether the redirect target url should keep the query string of the request's url. Available values: disabled
, enabled
.status_code
(Number) The status code to be used when redirecting a request.subpath_matching
(String) Whether the redirect also matches subpaths of the source url. Available values: disabled
, enabled
.Import is supported using the following syntax:
$ terraform import cloudflare_list.example <account_id>/<list_id>