Skip to content
This repository was archived by the owner on Mar 1, 2023. It is now read-only.

Commit e566ac9

Browse files
vvelikodnyVitaly Velikodny
andauthored
add new options to CDN rule: browser_cache_settings, cors, rewrite, webp (#74)
Co-authored-by: Vitaly Velikodny <[email protected]>
1 parent 057138d commit e566ac9

File tree

3 files changed

+112
-1
lines changed

3 files changed

+112
-1
lines changed

examples/resources/gcore_cdn_resource/resource.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ resource "gcore_cdn_resource" "cdn_example_com" {
1717
secondary_hostnames = ["cdn2.example.com"]
1818

1919
options {
20+
edge_cache_settings {
21+
default = "8d"
22+
}
2023
browser_cache_settings {
2124
value = "1d"
2225
}

examples/resources/gcore_cdn_rule/resource.tf

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,29 @@ resource "gcore_cdn_rule" "cdn_example_com_rule_1" {
1717

1818
options {
1919
edge_cache_settings {
20-
default = "4d"
20+
default = "14d"
21+
}
22+
browser_cache_settings {
23+
value = "14d"
2124
}
2225
redirect_http_to_https {
2326
value = true
2427
}
2528
gzip_on {
2629
value = true
2730
}
31+
cors {
32+
value = [
33+
"*"
34+
]
35+
}
36+
rewrite {
37+
body = "/(.*) /$1"
38+
}
39+
webp {
40+
jpg_quality = 55
41+
png_quality = 66
42+
}
2843
}
2944
}
3045

gcore/resource_gcore_cdn_rule.go

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,27 @@ func resourceCDNRule() *schema.Resource {
7676
},
7777
},
7878
},
79+
"browser_cache_settings": {
80+
Type: schema.TypeList,
81+
MaxItems: 1,
82+
Optional: true,
83+
Computed: true,
84+
Description: "",
85+
Elem: &schema.Resource{
86+
Schema: map[string]*schema.Schema{
87+
"enabled": {
88+
Type: schema.TypeBool,
89+
Optional: true,
90+
Default: true,
91+
},
92+
"value": {
93+
Type: schema.TypeString,
94+
Optional: true,
95+
Description: "",
96+
},
97+
},
98+
},
99+
},
79100
"host_header": {
80101
Type: schema.TypeList,
81102
MaxItems: 1,
@@ -132,6 +153,78 @@ func resourceCDNRule() *schema.Resource {
132153
},
133154
},
134155
},
156+
"cors": {
157+
Type: schema.TypeList,
158+
MaxItems: 1,
159+
Optional: true,
160+
Description: "",
161+
Elem: &schema.Resource{
162+
Schema: map[string]*schema.Schema{
163+
"enabled": {
164+
Type: schema.TypeBool,
165+
Optional: true,
166+
Default: true,
167+
},
168+
"value": {
169+
Type: schema.TypeSet,
170+
Elem: &schema.Schema{Type: schema.TypeString},
171+
Required: true,
172+
},
173+
},
174+
},
175+
},
176+
"rewrite": {
177+
Type: schema.TypeList,
178+
MaxItems: 1,
179+
Optional: true,
180+
Description: "",
181+
Elem: &schema.Resource{
182+
Schema: map[string]*schema.Schema{
183+
"enabled": {
184+
Type: schema.TypeBool,
185+
Optional: true,
186+
Default: true,
187+
},
188+
"body": {
189+
Type: schema.TypeString,
190+
Required: true,
191+
},
192+
"flag": {
193+
Type: schema.TypeString,
194+
Optional: true,
195+
Default: "break",
196+
},
197+
},
198+
},
199+
},
200+
"webp": {
201+
Type: schema.TypeList,
202+
MaxItems: 1,
203+
Optional: true,
204+
Description: "",
205+
Elem: &schema.Resource{
206+
Schema: map[string]*schema.Schema{
207+
"enabled": {
208+
Type: schema.TypeBool,
209+
Optional: true,
210+
Default: true,
211+
},
212+
"jpg_quality": {
213+
Type: schema.TypeInt,
214+
Required: true,
215+
},
216+
"png_quality": {
217+
Type: schema.TypeInt,
218+
Required: true,
219+
},
220+
"png_lossless": {
221+
Type: schema.TypeBool,
222+
Optional: true,
223+
Default: false,
224+
},
225+
},
226+
},
227+
},
135228
},
136229
},
137230
},

0 commit comments

Comments
 (0)