ArvanCloud CDN Page Rules Terraform Module
Terraform module to manage ArvanCloud CDN Page Rule resources.
module "cdn_page_rules" {
source = " git@github.com:terraform-r1c-modules/Terraform-R1C-CDN-Page-Rules.git?ref=main"
domain = " example.ir"
page_rules = {
# Enable caching for the main site
main = {
seq = 100
url = " example.ir/*"
cache_level = " query_string"
cache_200 = " 30d"
cache_browser = " 30d"
}
# Disable caching for admin area
admin = {
seq = 101
url = " example.ir/admin/*"
cache_level = " off"
}
# Disable caching for API endpoints
api = {
seq = 102
url = " api.example.ir/*"
cache_level = " off"
}
}
}
Advanced Example with All Features
module "cdn_page_rules" {
source = " git@github.com:terraform-r1c-modules/Terraform-R1C-CDN-Page-Rules.git?ref=main"
domain = var. domain
# Enable common security headers for cached content
common_security_headers = true
# Custom security headers (override defaults)
security_headers = [
{
name = " X-Frame-Options"
value = " SAMEORIGIN"
},
{
name = " Referrer-Policy"
value = " strict-origin"
},
{
name = " Permissions-Policy"
value = " fullscreen=(self), camera=()"
}
]
# Default cache settings for rules without explicit settings
default_cache_settings = {
cache_level = " query_string"
cache_200 = " 30d"
cache_browser = " 30d"
cache_args = true
cache_ignore_cc = true
cache_ignore_vary = true
cache_ignore_sc = false
}
page_rules = {
# Default rule with all features
default = {
seq = 0
url = " "
cache_200 = " 30d"
cache_any = " 0s"
cache_browser = " 30d"
cache_device_type = false
cache_ignore_cc = true
cache_ignore_vary = true
image_resize = {
status = " inherit"
mode = " freely"
height_by = " height"
width_by = " width"
}
upstream_timeout = {
connect_timeout = 15
read_timeout = 100
send_timeout = 300
}
slink_md5 = [" remote_addr" , " uri" , " expires" ]
}
# Rule with custom response headers
main_site = {
seq = 100
url = " example.ir/*"
cache_level = " query_string"
cache_200 = " 30d"
cache_browser = " 30d"
res_custom_headers = [
{
name = " X-Custom-Header"
value = " my-value"
}
]
}
# Rule with redirect
old_path = {
seq = 200
url = " example.ir/old-path/*"
redirect = {
enable = true
status_code = 301
url = " https://example.ir/new-path/"
}
}
# Rule with load balancer
api_gateway = {
seq = 300
url = " api.example.ir/*"
cache_level = " off"
load_balancer = " API-Load-Balancer"
}
}
}
Name
Description
Type
Default
Required
domain
The UUID or name of the domain to create page rules for
string
N/A
Yes
page_rules
A map of page rules to create. See Page Rule Object for details
map(object)
{}
No
default_cache_settings
Default cache settings applied to rules without explicit settings
object
See below
No
default_res_custom_headers
Default response headers applied to rules without explicit headers
list(object)
[]
No
common_security_headers
Enable common security headers for cached content
bool
false
No
security_headers
Security headers to add when common_security_headers is enabled
list(object)
See below
No
{
cache_level = " query_string"
cache_200 = " 30d"
cache_browser = " 30d"
cache_args = true
cache_ignore_sc = false
cache_ignore_vary = true
cache_ignore_cc = true
}
Default Security Headers
[
{
name = " X-Frame-Options"
value = " SAMEORIGIN"
},
{
name = " Referrer-Policy"
value = " strict-origin"
},
{
name = " X-Content-Type-Options"
value = " nosniff"
}
]
Attribute
Description
Type
Default
seq
Rule sequence/priority (lower = higher priority)
number
Required
url
URL pattern to match
string
Required
cache_level
Cache level: off, uri, query_string
string
null
cache_200
Cache duration for 200 responses
string
null
cache_any
Cache duration for any response
string
null
cache_browser
Browser cache duration
string
null
cache_cookie
Cookie to include in cache key
string
null
cache_arg
Argument to include in cache key
string
null
cache_args
Include all query arguments in cache key
bool
null
cache_device_type
Include device type in cache key
bool
null
cache_ignore_sc
Ignore Set-Cookie header
bool
null
cache_ignore_vary
Ignore Vary header
bool
null
cache_ignore_cc
Ignore Cache-Control header
bool
null
load_balancer
Name of load balancer to use
string
null
rewrite_url
URL to rewrite requests to
string
null
cors_header
CORS header value
string
null
custom_host_header
Custom Host header for upstream
string
null
image_resize
Image resize configuration
object
null
acceleration
Acceleration configuration
object
null
upstream_timeout
Upstream timeout configuration
object
null
req_custom_headers
Custom request headers
list(object)
null
res_custom_headers
Custom response headers
list(object)
null
req_hide_headers
Request headers to hide
list(string)
null
res_hide_headers
Response headers to hide
list(string)
null
redirect
Redirect configuration
object
null
slink_status
Enable secure link
bool
null
slink_secret
Secure link secret
string
null
slink_md5
Secure link MD5 components
list(string)
null
edge_compute_id
Edge compute function ID
string
null
is_protected
Rule protection status
bool
null
status
Rule enabled status
bool
true
Name
Description
page_rule_ids
Map of page rule names to their IDs
page_rules
Map of all page rule resources created
page_rule_urls
Map of page rule names to their URL patterns
cached_rules
List of page rule names with caching enabled
no_cache_rules
List of page rule names with caching disabled
rule_count
Total number of page rules created
Apache 2.0 Licensed. See LICENSE for full details