Skip to content

Commit 56493b5

Browse files
committed
resource/alicloud_esa_site: Added the field paused.
1 parent 70691e5 commit 56493b5

File tree

3 files changed

+47
-49
lines changed

3 files changed

+47
-49
lines changed

alicloud/resource_alicloud_esa_site.go

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ func resourceAliCloudEsaSite() *schema.Resource {
2323
Timeouts: &schema.ResourceTimeout{
2424
Create: schema.DefaultTimeout(5 * time.Minute),
2525
Update: schema.DefaultTimeout(5 * time.Minute),
26-
Delete: schema.DefaultTimeout(5 * time.Minute),
26+
Delete: schema.DefaultTimeout(15 * time.Minute),
2727
},
2828
Schema: map[string]*schema.Schema{
2929
"access_type": {
3030
Type: schema.TypeString,
31-
Optional: true,
31+
Required: true,
3232
ForceNew: true,
3333
},
3434
"add_client_geolocation_header": {
@@ -91,6 +91,10 @@ func resourceAliCloudEsaSite() *schema.Resource {
9191
Optional: true,
9292
Computed: true,
9393
},
94+
"paused": {
95+
Type: schema.TypeBool,
96+
Optional: true,
97+
},
9498
"resource_group_id": {
9599
Type: schema.TypeString,
96100
Optional: true,
@@ -141,7 +145,6 @@ func resourceAliCloudEsaSiteCreate(d *schema.ResourceData, meta interface{}) err
141145
query := make(map[string]interface{})
142146
var err error
143147
request = make(map[string]interface{})
144-
request["RegionId"] = client.RegionId
145148

146149
request["Coverage"] = d.Get("coverage")
147150
if v, ok := d.GetOk("resource_group_id"); ok {
@@ -304,22 +307,19 @@ func resourceAliCloudEsaSiteUpdate(d *schema.ResourceData, meta interface{}) err
304307
update := false
305308
d.Partial(true)
306309

310+
esaServiceV2 := EsaServiceV2{client}
311+
objectRaw, _ := esaServiceV2.DescribeEsaSite(d.Id())
312+
307313
if d.HasChange("version_management") {
308314
var err error
309-
esaServiceV2 := EsaServiceV2{client}
310-
object, err := esaServiceV2.DescribeEsaSite(d.Id())
311-
if err != nil {
312-
return WrapError(err)
313-
}
314-
315315
target := d.Get("version_management").(bool)
316-
if object["VersionManagement"].(bool) != target {
316+
if objectRaw["VersionManagement"].(bool) != target {
317317
if target == true {
318318
action := "ActivateVersionManagement"
319319
request = make(map[string]interface{})
320320
query = make(map[string]interface{})
321321
request["SiteId"] = d.Id()
322-
request["RegionId"] = client.RegionId
322+
323323
wait := incrementalWait(3*time.Second, 5*time.Second)
324324
err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError {
325325
response, err = client.RpcPost("ESA", "2024-09-10", action, query, request, true)
@@ -343,7 +343,7 @@ func resourceAliCloudEsaSiteUpdate(d *schema.ResourceData, meta interface{}) err
343343
request = make(map[string]interface{})
344344
query = make(map[string]interface{})
345345
request["SiteId"] = d.Id()
346-
request["RegionId"] = client.RegionId
346+
347347
wait := incrementalWait(3*time.Second, 5*time.Second)
348348
err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError {
349349
response, err = client.RpcPost("ESA", "2024-09-10", action, query, request, true)
@@ -370,7 +370,7 @@ func resourceAliCloudEsaSiteUpdate(d *schema.ResourceData, meta interface{}) err
370370
request = make(map[string]interface{})
371371
query = make(map[string]interface{})
372372
request["SiteId"] = d.Id()
373-
request["RegionId"] = client.RegionId
373+
374374
if !d.IsNewResource() && d.HasChange("coverage") {
375375
update = true
376376
}
@@ -436,7 +436,7 @@ func resourceAliCloudEsaSiteUpdate(d *schema.ResourceData, meta interface{}) err
436436
request = make(map[string]interface{})
437437
query = make(map[string]interface{})
438438
request["SiteId"] = d.Id()
439-
request["RegionId"] = client.RegionId
439+
440440
if d.HasChange("cache_architecture_mode") {
441441
update = true
442442
}
@@ -464,7 +464,7 @@ func resourceAliCloudEsaSiteUpdate(d *schema.ResourceData, meta interface{}) err
464464
request = make(map[string]interface{})
465465
query = make(map[string]interface{})
466466
request["SiteId"] = d.Id()
467-
request["RegionId"] = client.RegionId
467+
468468
if d.HasChange("add_real_client_ip_header") {
469469
update = true
470470
request["AddRealClientIpHeader"] = d.Get("add_real_client_ip_header")
@@ -503,7 +503,7 @@ func resourceAliCloudEsaSiteUpdate(d *schema.ResourceData, meta interface{}) err
503503
request = make(map[string]interface{})
504504
query = make(map[string]interface{})
505505
request["SiteId"] = d.Id()
506-
request["RegionId"] = client.RegionId
506+
507507
if d.HasChange("cross_border_optimization") {
508508
update = true
509509
}
@@ -531,7 +531,7 @@ func resourceAliCloudEsaSiteUpdate(d *schema.ResourceData, meta interface{}) err
531531
request = make(map[string]interface{})
532532
query = make(map[string]interface{})
533533
request["SiteId"] = d.Id()
534-
request["RegionId"] = client.RegionId
534+
535535
if d.HasChange("site_name_exclusive") {
536536
update = true
537537
}
@@ -559,7 +559,7 @@ func resourceAliCloudEsaSiteUpdate(d *schema.ResourceData, meta interface{}) err
559559
request = make(map[string]interface{})
560560
query = make(map[string]interface{})
561561
request["SiteId"] = d.Id()
562-
request["RegionId"] = client.RegionId
562+
563563
if d.HasChange("flatten_mode") {
564564
update = true
565565
}
@@ -587,7 +587,7 @@ func resourceAliCloudEsaSiteUpdate(d *schema.ResourceData, meta interface{}) err
587587
request = make(map[string]interface{})
588588
query = make(map[string]interface{})
589589
request["SiteId"] = d.Id()
590-
request["RegionId"] = client.RegionId
590+
591591
if d.HasChange("seo_bypass") {
592592
update = true
593593
}
@@ -615,7 +615,7 @@ func resourceAliCloudEsaSiteUpdate(d *schema.ResourceData, meta interface{}) err
615615
request = make(map[string]interface{})
616616
query = make(map[string]interface{})
617617
request["SiteId"] = d.Id()
618-
request["RegionId"] = client.RegionId
618+
619619
if d.HasChange("case_insensitive") {
620620
update = true
621621
request["CaseInsensitive"] = d.Get("case_insensitive")
@@ -654,7 +654,7 @@ func resourceAliCloudEsaSiteUpdate(d *schema.ResourceData, meta interface{}) err
654654
request = make(map[string]interface{})
655655
query = make(map[string]interface{})
656656
request["SiteId"] = d.Id()
657-
request["RegionId"] = client.RegionId
657+
658658
if d.HasChange("development_mode") {
659659
update = true
660660
}
@@ -682,7 +682,7 @@ func resourceAliCloudEsaSiteUpdate(d *schema.ResourceData, meta interface{}) err
682682
request = make(map[string]interface{})
683683
query = make(map[string]interface{})
684684
request["SiteId"] = d.Id()
685-
request["RegionId"] = client.RegionId
685+
686686
if d.HasChange("paused") {
687687
update = true
688688
}
@@ -710,7 +710,7 @@ func resourceAliCloudEsaSiteUpdate(d *schema.ResourceData, meta interface{}) err
710710
request = make(map[string]interface{})
711711
query = make(map[string]interface{})
712712
request["SiteId"] = d.Id()
713-
request["RegionId"] = client.RegionId
713+
714714
if d.HasChange("cache_reserve_instance_id") {
715715
update = true
716716
request["CacheReserveInstanceId"] = d.Get("cache_reserve_instance_id")
@@ -764,7 +764,6 @@ func resourceAliCloudEsaSiteDelete(d *schema.ResourceData, meta interface{}) err
764764
wait := incrementalWait(3*time.Second, 5*time.Second)
765765
err = resource.Retry(d.Timeout(schema.TimeoutDelete), func() *resource.RetryError {
766766
response, err = client.RpcPost("ESA", "2024-09-10", action, query, request, true)
767-
768767
if err != nil {
769768
if IsExpectedErrors(err, []string{"Site.ServiceBusy"}) || NeedRetry(err) {
770769
wait()

alicloud/service_alicloud_esa_v2.go

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func (s *EsaServiceV2) DescribeEsaSite(id string) (object map[string]interface{}
2828
request = make(map[string]interface{})
2929
query = make(map[string]interface{})
3030
query["SiteId"] = id
31-
query["RegionId"] = client.RegionId
31+
3232
action := "GetSite"
3333

3434
wait := incrementalWait(3*time.Second, 5*time.Second)
@@ -102,7 +102,7 @@ func (s *EsaServiceV2) DescribeSiteGetManagedTransform(id string) (object map[st
102102
request = make(map[string]interface{})
103103
query = make(map[string]interface{})
104104
query["SiteId"] = id
105-
query["RegionId"] = client.RegionId
105+
106106
action := "GetManagedTransform"
107107

108108
wait := incrementalWait(3*time.Second, 5*time.Second)
@@ -136,7 +136,7 @@ func (s *EsaServiceV2) DescribeSiteGetCacheTag(id string) (object map[string]int
136136
request = make(map[string]interface{})
137137
query = make(map[string]interface{})
138138
query["SiteId"] = id
139-
query["RegionId"] = client.RegionId
139+
140140
action := "GetCacheTag"
141141

142142
wait := incrementalWait(3*time.Second, 5*time.Second)
@@ -204,7 +204,7 @@ func (s *EsaServiceV2) DescribeSiteGetCacheReserve(id string) (object map[string
204204
request = make(map[string]interface{})
205205
query = make(map[string]interface{})
206206
query["SiteId"] = id
207-
query["RegionId"] = client.RegionId
207+
208208
action := "GetCacheReserve"
209209

210210
wait := incrementalWait(3*time.Second, 5*time.Second)
@@ -238,7 +238,7 @@ func (s *EsaServiceV2) DescribeSiteGetTieredCache(id string) (object map[string]
238238
request = make(map[string]interface{})
239239
query = make(map[string]interface{})
240240
query["SiteId"] = id
241-
query["RegionId"] = client.RegionId
241+
242242
action := "GetTieredCache"
243243

244244
wait := incrementalWait(3*time.Second, 5*time.Second)
@@ -272,7 +272,7 @@ func (s *EsaServiceV2) DescribeSiteGetCrossBorderOptimization(id string) (object
272272
request = make(map[string]interface{})
273273
query = make(map[string]interface{})
274274
query["SiteId"] = id
275-
query["RegionId"] = client.RegionId
275+
276276
action := "GetCrossBorderOptimization"
277277

278278
wait := incrementalWait(3*time.Second, 5*time.Second)
@@ -306,7 +306,7 @@ func (s *EsaServiceV2) DescribeSiteGetSiteNameExclusive(id string) (object map[s
306306
request = make(map[string]interface{})
307307
query = make(map[string]interface{})
308308
query["SiteId"] = id
309-
query["RegionId"] = client.RegionId
309+
310310
action := "GetSiteNameExclusive"
311311

312312
wait := incrementalWait(3*time.Second, 5*time.Second)
@@ -340,7 +340,7 @@ func (s *EsaServiceV2) DescribeSiteGetCnameFlattening(id string) (object map[str
340340
request = make(map[string]interface{})
341341
query = make(map[string]interface{})
342342
query["SiteId"] = id
343-
query["RegionId"] = client.RegionId
343+
344344
action := "GetCnameFlattening"
345345

346346
wait := incrementalWait(3*time.Second, 5*time.Second)
@@ -374,7 +374,7 @@ func (s *EsaServiceV2) DescribeSiteGetSeoBypass(id string) (object map[string]in
374374
request = make(map[string]interface{})
375375
query = make(map[string]interface{})
376376
query["SiteId"] = id
377-
query["RegionId"] = client.RegionId
377+
378378
action := "GetSeoBypass"
379379

380380
wait := incrementalWait(3*time.Second, 5*time.Second)
@@ -408,7 +408,7 @@ func (s *EsaServiceV2) DescribeSiteGetDevelopmentMode(id string) (object map[str
408408
request = make(map[string]interface{})
409409
query = make(map[string]interface{})
410410
query["SiteId"] = id
411-
query["RegionId"] = client.RegionId
411+
412412
action := "GetDevelopmentMode"
413413

414414
wait := incrementalWait(3*time.Second, 5*time.Second)
@@ -442,7 +442,7 @@ func (s *EsaServiceV2) DescribeSiteGetSitePause(id string) (object map[string]in
442442
request = make(map[string]interface{})
443443
query = make(map[string]interface{})
444444
query["SiteId"] = id
445-
query["RegionId"] = client.RegionId
445+
446446
action := "GetSitePause"
447447

448448
wait := incrementalWait(3*time.Second, 5*time.Second)
@@ -470,15 +470,18 @@ func (s *EsaServiceV2) DescribeSiteGetSitePause(id string) (object map[string]in
470470
}
471471

472472
func (s *EsaServiceV2) EsaSiteStateRefreshFunc(id string, field string, failStates []string) resource.StateRefreshFunc {
473+
return s.EsaSiteStateRefreshFuncWithApi(id, field, failStates, s.DescribeEsaSite)
474+
}
475+
476+
func (s *EsaServiceV2) EsaSiteStateRefreshFuncWithApi(id string, field string, failStates []string, call func(id string) (map[string]interface{}, error)) resource.StateRefreshFunc {
473477
return func() (interface{}, string, error) {
474-
object, err := s.DescribeEsaSite(id)
478+
object, err := call(id)
475479
if err != nil {
476480
if NotFoundError(err) {
477481
return nil, "", nil
478482
}
479483
return nil, "", WrapError(err)
480484
}
481-
482485
v, err := jsonpath.Get(field, object)
483486
currentStatus := fmt.Sprint(v)
484487

@@ -506,7 +509,6 @@ func (s *EsaServiceV2) DescribeAsyncEsaSiteStateRefreshFunc(d *schema.ResourceDa
506509
return nil, "", nil
507510
}
508511
}
509-
510512
v, err := jsonpath.Get(field, object)
511513
currentStatus := fmt.Sprint(v)
512514

@@ -1303,7 +1305,7 @@ func (s *EsaServiceV2) DescribeAsyncGetSite(d *schema.ResourceData, res map[stri
13031305
request = make(map[string]interface{})
13041306
query = make(map[string]interface{})
13051307
query["SiteId"] = d.Id()
1306-
query["RegionId"] = client.RegionId
1308+
13071309
action := "GetSite"
13081310

13091311
wait := incrementalWait(3*time.Second, 5*time.Second)

website/docs/r/esa_site.html.markdown

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ For information about ESA Site and how to use it, see [What is Site](https://www
2020

2121
Basic Usage
2222

23-
<div style="display: block;margin-bottom: 40px;"><div class="oics-button" style="float: right;position: absolute;margin-bottom: 10px;">
24-
<a href="https://api.aliyun.com/terraform?resource=alicloud_esa_site&exampleId=526a6ad2-d747-8099-80fe-4adba67e465727294d3a&activeTab=example&spm=docs.r.esa_site.0.526a6ad2d7&intl_lang=EN_US" target="_blank">
25-
<img alt="Open in AliCloud" src="https://img.alicdn.com/imgextra/i1/O1CN01hjjqXv1uYUlY56FyX_!!6000000006049-55-tps-254-36.svg" style="max-height: 44px; max-width: 100%;">
26-
</a>
27-
</div></div>
28-
2923
```terraform
3024
variable "name" {
3125
default = "terraform-example"
@@ -65,7 +59,7 @@ resource "alicloud_esa_site" "default" {
6559
## Argument Reference
6660

6761
The following arguments are supported:
68-
* `access_type` - (Optional, ForceNew) The DNS setup. Valid values:
62+
* `access_type` - (Required, ForceNew) The DNS setup. Valid values:
6963
- `NS`
7064
- `CNAME`
7165
* `add_client_geolocation_header` - (Optional, Available since v1.244.0) Add visitor geolocation header. Value range:
@@ -103,9 +97,12 @@ The following arguments are supported:
10397
* `ipv6_enable` - (Optional, Computed, Available since v1.244.0) Specifies whether to enable IPv6. Valid values:
10498
- `on`
10599
- `off`
106-
* `ipv6_region` - (Optional, Available since v1.251.0) The region in which Ipv6 is enabled. The default value is x.x:
100+
* `ipv6_region` - (Optional, Computed, Available since v1.251.0) The region in which Ipv6 is enabled. The default value is x.x:
107101
- 'x.x': Global.
108102
- 'Cn.cn ': Mainland China.
103+
* `paused` - (Optional, Available since v1.262.0) Specifies whether to temporarily pause ESA on the website. If you set this parameter to true, all requests to the domains in your DNS records go directly to your origin server. Valid values:
104+
- `true`
105+
- `false`
109106
* `resource_group_id` - (Optional, ForceNew, Computed) The ID of the resource group
110107
* `seo_bypass` - (Optional, Available since v1.251.0) Release the search engine crawler configuration. Value:
111108
- `on`
@@ -117,7 +114,7 @@ The following arguments are supported:
117114
* `site_version` - (Optional, Int, Available since v1.244.0) The version number of the site. For sites with version management enabled, you can use this parameter to specify the site version for which the configuration will take effect, defaulting to version 0.
118115
* `tag_name` - (Optional, Available since v1.251.0) Custom CacheTag name.
119116
* `tags` - (Optional, Map) Resource tags
120-
* `version_management` - (Optional, Available since v1.251.0) Version management enabled. When true, version management is turned on for the table site.
117+
* `version_management` - (Optional) Version management enabled. When true, version management is turned on for the table site.
121118

122119
## Attributes Reference
123120

@@ -130,7 +127,7 @@ The following attributes are exported:
130127

131128
The `timeouts` block allows you to specify [timeouts](https://developer.hashicorp.com/terraform/language/resources/syntax#operation-timeouts) for certain actions:
132129
* `create` - (Defaults to 5 mins) Used when create the Site.
133-
* `delete` - (Defaults to 5 mins) Used when delete the Site.
130+
* `delete` - (Defaults to 15 mins) Used when delete the Site.
134131
* `update` - (Defaults to 5 mins) Used when update the Site.
135132

136133
## Import

0 commit comments

Comments
 (0)