I am having the following azure endpoint definition and I need to define several similar endpoints.
How can I reuse the delivery_rule definitions and global_delivery_rule so that I define them only once.
What is the best practice to achieve this?
Thank you in advance!
resource "azurerm_cdn_endpoint" "cdne1" {
name = "cdne1"
origin_host_header = "cdne1.z6.web.core.windows.net"
origin_path = "/applatest/"
profile_name = azurerm_cdn_profile.cdnp_clientapp_dev.name
resource_group_name = azurerm_resource_group.rg_dev.name
content_types_to_compress = local.cdne_content_types_to_compress
is_http_allowed = true
is_https_allowed = true
location = "global"
optimization_type = "GeneralWebDelivery"
querystring_caching_behaviour = "IgnoreQueryString"
tags = {
environment = "development"
}
origin {
host_name = "stclientappdevshoca1.z6.web.core.windows.net"
name = "stclientappdevshoca1-z6-web-core-windows-net"
}
delivery_rule {
name = "HTTPtoHTTPS"
order = 1
request_scheme_condition {
match_values = [
"HTTP",
]
negate_condition = false
operator = "Equal"
}
url_redirect_action {
protocol = "Https"
redirect_type = "Moved"
}
}
delivery_rule {
name = "redirectToIndex"
order = 2
url_file_extension_condition {
match_values = [
"0",
]
negate_condition = true
operator = "GreaterThan"
transforms = []
}
url_rewrite_action {
destination = "/index.html"
preserve_unmatched_path = false
source_pattern = "/"
}
}
delivery_rule {
name = "securityHeaders"
order = 3
modify_response_header_action {
action = "Append"
name = "Strict-Transport-Security"
value = "max-age=31536000; includeSubDomains"
}
modify_response_header_action {
action = "Append"
name = "Content-Security-Policy"
value = "script-src 'self'"
}
modify_response_header_action {
action = "Append"
name = "X-Frame-Options"
value = "SAMEORIGIN"
}
modify_response_header_action {
action = "Append"
name = "X-Content-Type-Options"
value = "nosniff"
}
modify_response_header_action {
action = "Append"
name = "Referrer-Policy"
value = "no-referrer"
}
request_uri_condition {
operator = "Any"
}
}
global_delivery_rule {
cache_expiration_action {
behavior = "BypassCache"
}
}
timeouts {}
}
