Repository navigation
Expand file tree
/
Copy pathresource.tf
More file actions
102 lines (87 loc) · 3.18 KB
/
Copy pathresource.tf
File metadata and controls
102 lines (87 loc) · 3.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# ===================================================================
# CacheFly CDN - Service Setup Examples
# ===================================================================
terraform {
required_version = ">= 1.0"
required_providers {
cachefly = {
source = "cachefly/cachefly"
}
}
}
provider "cachefly" {
# Uses CACHEFLY_API_TOKEN if set; otherwise, set api_token here
# api_token = ""
}
# -------------------------------------------------------------------
# Data Sources: Delivery Regions (optional helper)
# -------------------------------------------------------------------
data "cachefly_delivery_regions" "available" {}
# -------------------------------------------------------------------
# Example 1: Basic Service
# -------------------------------------------------------------------
resource "cachefly_service" "basic" {
name = "example-dev-svc"
unique_name = "example-dev-svc-basic"
description = "Basic CDN service example"
auto_ssl = true
}
# -------------------------------------------------------------------
# Example 2: Service with Options and Delivery Region
# -------------------------------------------------------------------
resource "cachefly_service" "with_options" {
name = "example-dev-svc-opts"
unique_name = "example-dev-svc-opts"
description = "Service with advanced options enabled"
auto_ssl = true
# Optionally pin the service to a delivery region (pick first available)
delivery_region = data.cachefly_delivery_regions.available.regions[0].id
# Optionally set a TLS profile if you have a specific profile ID
# tls_profile = "<tls-profile-id>"
# Example options (see Service Options Reference in docs)
options = {
autoRedirect = true
reverseProxy = {
enabled = true
originScheme = "HTTP"
cacheByQueryParam = true
useRobotsTxt = true
ttl = 123
hostname = "example.com"
}
protectServeKeyEnabled = true
purgemode = {
enabled = true
value = {
exact = true
directory = true
extension = true
}
}
}
}
# -------------------------------------------------------------------
# Outputs
# -------------------------------------------------------------------
output "services" {
value = {
basic = {
id = cachefly_service.basic.id
name = cachefly_service.basic.name
unique_name = cachefly_service.basic.unique_name
status = cachefly_service.basic.status
created = cachefly_service.basic.created_at
updated = cachefly_service.basic.updated_at
}
with_options = {
id = cachefly_service.with_options.id
name = cachefly_service.with_options.name
unique_name = cachefly_service.with_options.unique_name
status = cachefly_service.with_options.status
configuration_mode = cachefly_service.with_options.configuration_mode
delivery_region = cachefly_service.with_options.delivery_region
created = cachefly_service.with_options.created_at
updated = cachefly_service.with_options.updated_at
}
}
}