You've already forked terraform-bunnynet
81 lines
2.1 KiB
HCL
81 lines
2.1 KiB
HCL
locals {
|
|
certificate = sensitive(
|
|
var.certificate != "" ? file(var.certificate) : (
|
|
var.certificate_vault ? data.vault_kv_secret_v2.ssl_cert[0].data["cert"] : null
|
|
)
|
|
)
|
|
|
|
certificate_key = sensitive(
|
|
var.certificate_key != "" ? file(var.certificate_key) : (
|
|
var.certificate_vault ? data.vault_kv_secret_v2.ssl_cert[0].data["key"] : null
|
|
)
|
|
)
|
|
}
|
|
|
|
data "vault_kv_secret_v2" "ssl_cert" {
|
|
count = var.certificate_vault ? 1 : 0
|
|
|
|
mount = "kv"
|
|
name = "cdn/ssl/${var.domain}"
|
|
}
|
|
|
|
resource "bunnynet_pullzone" "service" {
|
|
name = var.name
|
|
|
|
origin {
|
|
type = var.origin_type
|
|
url = var.origin
|
|
host_header = var.origin_host
|
|
verify_ssl = var.origin_verify_ssl
|
|
}
|
|
|
|
routing {
|
|
tier = var.routing_tier
|
|
zones = var.routing_zones
|
|
blocked_countries = var.routing_blocked_countries
|
|
filters = var.routing_filters
|
|
}
|
|
|
|
block_post_requests = var.block_post_requests
|
|
errorpage_whitelabel = var.errorpage_whitelabel
|
|
websockets_enabled = var.websockets_enabled
|
|
|
|
request_coalescing_enabled = var.request_coalescing
|
|
|
|
cache_vary = var.cache_vary
|
|
cache_stale = var.cache_stale
|
|
cache_chunked = var.cache_chunked
|
|
|
|
limit_bandwidth = var.limit_bandwidth
|
|
limit_download_speed = var.limit_download_speed
|
|
}
|
|
|
|
resource "bunnynet_pullzone_hostname" "service" {
|
|
pullzone = bunnynet_pullzone.service.id
|
|
name = var.domain
|
|
tls_enabled = true
|
|
force_ssl = false
|
|
certificate = local.certificate
|
|
certificate_key = local.certificate_key
|
|
}
|
|
|
|
output "pullzone_id" {
|
|
value = bunnynet_pullzone.service.id
|
|
description = "The ID of the created pullzone"
|
|
}
|
|
|
|
output "pullzone_hostname_id" {
|
|
value = bunnynet_pullzone_hostname.service.id
|
|
description = "The ID of the pullzone hostname"
|
|
}
|
|
|
|
output "pullzone_name" {
|
|
value = bunnynet_pullzone.service.name
|
|
description = "The name of the pullzone"
|
|
}
|
|
|
|
output "hostname" {
|
|
value = bunnynet_pullzone_hostname.service.name
|
|
description = "The hostname configured for the pullzone"
|
|
}
|