Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions alicloud/resource_alicloud_esa_cache_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ func resourceAliCloudEsaCacheRule() *schema.Resource {
},
Schema: map[string]*schema.Schema{
"additional_cacheable_ports": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: StringInSlice([]string{"8880", "2052", "2082", "2086", "2095", "2053", "2083", "2087", "2096"}, false),
Type: schema.TypeString,
Optional: true,
},
"browser_cache_mode": {
Type: schema.TypeString,
Expand Down
38 changes: 22 additions & 16 deletions alicloud/resource_alicloud_esa_cache_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestAccAliCloudESACacheRuleresource_cacherule_test(t *testing.T) {
"edge_cache_ttl": "300",
"site_id": "${data.alicloud_esa_sites.default.sites.0.id}",
"edge_cache_mode": "follow_origin",
"edge_status_code_cache_ttl": "300",
"edge_status_code_cache_ttl": "4xx=30",
"browser_cache_mode": "no_cache",
"user_geo": "off",
"browser_cache_ttl": "300",
Expand All @@ -53,7 +53,6 @@ func TestAccAliCloudESACacheRuleresource_cacherule_test(t *testing.T) {
"check_presence_cookie": "cookiename",
"user_device_type": "off",
"cache_reserve_eligibility": "bypass_cache_reserve",
"additional_cacheable_ports": "2053",
"rule": "http.host eq \\\"video.example.com\\\"",
"user_language": "off",
"serve_stale": "off",
Expand All @@ -66,7 +65,7 @@ func TestAccAliCloudESACacheRuleresource_cacherule_test(t *testing.T) {
"edge_cache_ttl": "300",
"site_id": CHECKSET,
"edge_cache_mode": "follow_origin",
"edge_status_code_cache_ttl": "300",
"edge_status_code_cache_ttl": "4xx=30",
"browser_cache_mode": "no_cache",
"user_geo": "off",
"browser_cache_ttl": "300",
Expand All @@ -81,7 +80,6 @@ func TestAccAliCloudESACacheRuleresource_cacherule_test(t *testing.T) {
"check_presence_cookie": "cookiename",
"user_device_type": "off",
"cache_reserve_eligibility": "bypass_cache_reserve",
"additional_cacheable_ports": "2053",
"rule": CHECKSET,
"user_language": "off",
"serve_stale": "off",
Expand Down Expand Up @@ -153,11 +151,11 @@ func TestAccAliCloudESACacheRuleresource_cacherule_test(t *testing.T) {
},
{
Config: testAccConfig(map[string]interface{}{
"edge_status_code_cache_ttl": "400",
"edge_status_code_cache_ttl": "500=30",
}),
Check: resource.ComposeTestCheckFunc(
testAccCheck(map[string]string{
"edge_status_code_cache_ttl": "400",
"edge_status_code_cache_ttl": "500=30",
}),
),
},
Expand Down Expand Up @@ -253,11 +251,21 @@ func TestAccAliCloudESACacheRuleresource_cacherule_test(t *testing.T) {
},
{
Config: testAccConfig(map[string]interface{}{
"additional_cacheable_ports": "2052",
"additional_cacheable_ports": "8880,2052,2082,2086,2095,2053,2083,2087,2096,8443",
}),
Check: resource.ComposeTestCheckFunc(
testAccCheck(map[string]string{
"additional_cacheable_ports": "2052",
"additional_cacheable_ports": "8880,2052,2082,2086,2095,2053,2083,2087,2096,8443",
}),
),
},
{
Config: testAccConfig(map[string]interface{}{
"additional_cacheable_ports": "8880",
}),
Check: resource.ComposeTestCheckFunc(
testAccCheck(map[string]string{
"additional_cacheable_ports": CHECKSET,
}),
),
},
Expand Down Expand Up @@ -407,7 +415,7 @@ func TestAccAliCloudEsaCacheRule_basic12002(t *testing.T) {
"edge_cache_ttl": "300",
"site_id": "${data.alicloud_esa_sites.default.sites.0.id}",
"edge_cache_mode": "follow_origin",
"edge_status_code_cache_ttl": "300",
"edge_status_code_cache_ttl": "500=30",
"browser_cache_mode": "no_cache",
"user_geo": "off",
"browser_cache_ttl": "300",
Expand All @@ -422,7 +430,6 @@ func TestAccAliCloudEsaCacheRule_basic12002(t *testing.T) {
"check_presence_cookie": "cookiename",
"user_device_type": "off",
"cache_reserve_eligibility": "bypass_cache_reserve",
"additional_cacheable_ports": "2053",
"rule": "http.host eq \\\"video.example.com\\\"",
"user_language": "off",
"serve_stale": "off",
Expand All @@ -438,7 +445,7 @@ func TestAccAliCloudEsaCacheRule_basic12002(t *testing.T) {
"edge_cache_ttl": CHECKSET,
"site_id": CHECKSET,
"edge_cache_mode": "follow_origin",
"edge_status_code_cache_ttl": CHECKSET,
"edge_status_code_cache_ttl": "500=30",
"browser_cache_mode": "no_cache",
"user_geo": "off",
"browser_cache_ttl": CHECKSET,
Expand All @@ -453,7 +460,6 @@ func TestAccAliCloudEsaCacheRule_basic12002(t *testing.T) {
"check_presence_cookie": "cookiename",
"user_device_type": "off",
"cache_reserve_eligibility": "bypass_cache_reserve",
"additional_cacheable_ports": CHECKSET,
"rule": "http.host eq \"video.example.com\"",
"user_language": "off",
"serve_stale": "off",
Expand All @@ -470,7 +476,7 @@ func TestAccAliCloudEsaCacheRule_basic12002(t *testing.T) {
Config: testAccConfig(map[string]interface{}{
"edge_cache_ttl": "400",
"edge_cache_mode": "no_cache",
"edge_status_code_cache_ttl": "400",
"edge_status_code_cache_ttl": "4xx=30",
"browser_cache_mode": "follow_origin",
"user_geo": "on",
"browser_cache_ttl": "400",
Expand All @@ -485,7 +491,7 @@ func TestAccAliCloudEsaCacheRule_basic12002(t *testing.T) {
"check_presence_cookie": "cookienamee",
"user_device_type": "on",
"cache_reserve_eligibility": "eligible_for_cache_reserve",
"additional_cacheable_ports": "2052",
"additional_cacheable_ports": "8880,2052,2082,2086,2095,2053,2083,2087,2096,8443",
"rule": "http.host eq \\\"videoo.example.com\\\"",
"user_language": "on",
"serve_stale": "on",
Expand All @@ -496,7 +502,7 @@ func TestAccAliCloudEsaCacheRule_basic12002(t *testing.T) {
testAccCheck(map[string]string{
"edge_cache_ttl": CHECKSET,
"edge_cache_mode": "no_cache",
"edge_status_code_cache_ttl": CHECKSET,
"edge_status_code_cache_ttl": "4xx=30",
"browser_cache_mode": "follow_origin",
"user_geo": "on",
"browser_cache_ttl": CHECKSET,
Expand All @@ -511,7 +517,7 @@ func TestAccAliCloudEsaCacheRule_basic12002(t *testing.T) {
"check_presence_cookie": "cookienamee",
"user_device_type": "on",
"cache_reserve_eligibility": "eligible_for_cache_reserve",
"additional_cacheable_ports": CHECKSET,
"additional_cacheable_ports": "8880,2052,2082,2086,2095,2053,2083,2087,2096,8443",
"rule": "http.host eq \"videoo.example.com\"",
"user_language": "on",
"serve_stale": "on",
Expand Down
11 changes: 7 additions & 4 deletions website/docs/r/esa_cache_rule.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ resource "alicloud_esa_cache_rule" "default" {
check_presence_header = "headername"
include_cookie = "cookie_exapmle"
edge_cache_mode = "follow_origin"
additional_cacheable_ports = "2053"
additional_cacheable_ports = "8880,2052"
rule_name = "rule_example"
edge_status_code_cache_ttl = "300"
edge_status_code_cache_ttl = "4xx=30"
browser_cache_ttl = "300"
query_string = "example"
user_geo = "off"
Expand All @@ -66,7 +66,7 @@ resource "alicloud_esa_cache_rule" "default" {
## Argument Reference

The following arguments are supported:
* `additional_cacheable_ports` - (Optional) Enable caching on specified ports. Value range: 8880, 2052, 2082, 2086, 2095, 2053, 2083, 2087, 2096
* `additional_cacheable_ports` - (Optional) Specifies additional ports on which caching is enabled. You can specify multiple ports, separated by commas (,). Value range: 8880, 2052, 2082, 2086, 2095, 2053, 2083, 2087, 2096.
* `browser_cache_mode` - (Optional) Browser cache mode. Possible values:
- `no_cache`no_cache: Do not cache.
- `follow_origin`: Follow the origin server's cache policy.
Expand All @@ -90,7 +90,10 @@ The following arguments are supported:
- `follow_origin_bypass`: Follow the origin server's cache policy (if it exists), otherwise do not cache.
- `follow_origin_override `: Follow the origin server's cache policy (if it exists), otherwise use custom cache TTL.
* `edge_cache_ttl` - (Optional) Edge cache expiration time in seconds.
* `edge_status_code_cache_ttl` - (Optional) Status code cache expiration time in seconds.
* `edge_status_code_cache_ttl` - (Optional) The status code cache TTL, in seconds.
- You can set the cache TTL for a specific status code. For example, 404=10 caches responses with a 404 status code for 10 seconds.
- You can set the cache TTL for a series of status codes, such as 4xx or 5xx. For example, 4xx=10 caches all responses that have a status code in the 4xx series for 10 seconds.
- You can specify multiple status code TTLs, separated by commas (,).
* `include_cookie` - (Optional) When generating the cache key, add the specified cookie names and their values. Multiple values are supported, separated by spaces.
* `include_header` - (Optional) When generating the cache key, add the specified header names and their values. Multiple values are supported, separated by spaces.
* `post_body_cache_key` - (Optional, Available since v1.274.0) Processing pattern for the cache key.
Expand Down
Loading