diff --git a/.changelog/1399.txt b/.changelog/1399.txt new file mode 100644 index 0000000000..7bcd4e865d --- /dev/null +++ b/.changelog/1399.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/tencentcloud_gaap_proxy: fix gaap proxy retry error `DuplicatedRequest` +``` \ No newline at end of file diff --git a/tencentcloud/resource_tc_gaap_proxy.go b/tencentcloud/resource_tc_gaap_proxy.go index b737af34f4..421a839d96 100644 --- a/tencentcloud/resource_tc_gaap_proxy.go +++ b/tencentcloud/resource_tc_gaap_proxy.go @@ -96,7 +96,7 @@ func resourceTencentCloudGaapProxy() *schema.Resource { "tags": { Type: schema.TypeMap, Optional: true, - Description: "Tags of the GAAP proxy.", + Description: "Tags of the GAAP proxy. Tags that do not exist are not created automatically.", }, // computed diff --git a/tencentcloud/service_tencentcloud_gaap.go b/tencentcloud/service_tencentcloud_gaap.go index 209a518a58..30446fc032 100644 --- a/tencentcloud/service_tencentcloud_gaap.go +++ b/tencentcloud/service_tencentcloud_gaap.go @@ -324,7 +324,6 @@ func (me *GaapService) CreateProxy( createRequest.Concurrent = helper.IntUint64(concurrent) createRequest.AccessRegion = &accessRegion createRequest.RealServerRegion = &realserverRegion - createRequest.ClientToken = helper.String(helper.BuildToken()) for k, v := range tags { createRequest.TagSet = append(createRequest.TagSet, &gaap.TagPair{ TagKey: helper.String(k), @@ -334,6 +333,7 @@ func (me *GaapService) CreateProxy( if err := resource.Retry(2*writeRetryTimeout, func() *resource.RetryError { ratelimit.Check(createRequest.GetAction()) + createRequest.ClientToken = helper.String(helper.BuildToken()) response, err := client.CreateProxy(createRequest) if err != nil { @@ -412,10 +412,10 @@ func (me *GaapService) EnableProxy(ctx context.Context, id string) error { enableRequest := gaap.NewOpenProxiesRequest() enableRequest.ProxyIds = []*string{&id} - enableRequest.ClientToken = helper.String(helper.BuildToken()) if err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { ratelimit.Check(enableRequest.GetAction()) + enableRequest.ClientToken = helper.String(helper.BuildToken()) response, err := client.OpenProxies(enableRequest) if err != nil { @@ -491,10 +491,10 @@ func (me *GaapService) DisableProxy(ctx context.Context, id string) error { disableRequest := gaap.NewCloseProxiesRequest() disableRequest.ProxyIds = []*string{&id} - disableRequest.ClientToken = helper.String(helper.BuildToken()) if err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { ratelimit.Check(disableRequest.GetAction()) + disableRequest.ClientToken = helper.String(helper.BuildToken()) response, err := client.CloseProxies(disableRequest) if err != nil { @@ -649,10 +649,10 @@ func (me *GaapService) ModifyProxyName(ctx context.Context, id, name string) err request := gaap.NewModifyProxiesAttributeRequest() request.ProxyIds = []*string{&id} request.ProxyName = &name - request.ClientToken = helper.String(helper.BuildToken()) if err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { ratelimit.Check(request.GetAction()) + request.ClientToken = helper.String(helper.BuildToken()) if _, err := me.client.UseGaapClient().ModifyProxiesAttribute(request); err != nil { log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]", @@ -674,10 +674,10 @@ func (me *GaapService) ModifyProxyProjectId(ctx context.Context, id string, proj request := gaap.NewModifyProxiesProjectRequest() request.ProxyIds = []*string{&id} request.ProjectId = helper.IntInt64(projectId) - request.ClientToken = helper.String(helper.BuildToken()) if err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { ratelimit.Check(request.GetAction()) + request.ClientToken = helper.String(helper.BuildToken()) if _, err := me.client.UseGaapClient().ModifyProxiesProject(request); err != nil { log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]", @@ -705,10 +705,10 @@ func (me *GaapService) ModifyProxyConfiguration(ctx context.Context, id string, if concurrent != nil { modifyRequest.Concurrent = helper.IntUint64(*concurrent) } - modifyRequest.ClientToken = helper.String(helper.BuildToken()) if err := resource.Retry(2*writeRetryTimeout, func() *resource.RetryError { ratelimit.Check(modifyRequest.GetAction()) + modifyRequest.ClientToken = helper.String(helper.BuildToken()) if _, err := client.ModifyProxyConfiguration(modifyRequest); err != nil { log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]", diff --git a/website/docs/r/gaap_proxy.html.markdown b/website/docs/r/gaap_proxy.html.markdown index 077f9c2d50..5cd50da59e 100644 --- a/website/docs/r/gaap_proxy.html.markdown +++ b/website/docs/r/gaap_proxy.html.markdown @@ -38,7 +38,7 @@ The following arguments are supported: * `realserver_region` - (Required, String, ForceNew) Region of the GAAP realserver. Valid value: `NorthChina`, `EastChina`, `SouthChina`, `SouthwestChina`, `Hongkong`, `SL_TAIWAN`, `SoutheastAsia`, `Korea`, `SL_India`, `SL_Australia`, `Europe`, `SL_UK`, `SL_SouthAmerica`, `NorthAmerica`, `SL_MiddleUSA`, `Canada`, `SL_VIET`, `WestIndia`, `Thailand`, `Virginia`, `Russia`, `Japan` and `SL_Indonesia`. * `enable` - (Optional, Bool) Indicates whether GAAP proxy is enabled, default value is `true`. * `project_id` - (Optional, Int) ID of the project within the GAAP proxy, `0` means is default project. -* `tags` - (Optional, Map) Tags of the GAAP proxy. +* `tags` - (Optional, Map) Tags of the GAAP proxy. Tags that do not exist are not created automatically. ## Attributes Reference