diff --git a/tencentcloud/services/vod/resource_tc_vod_sub_application.go b/tencentcloud/services/vod/resource_tc_vod_sub_application.go index 1771af4311..0db2e7a041 100644 --- a/tencentcloud/services/vod/resource_tc_vod_sub_application.go +++ b/tencentcloud/services/vod/resource_tc_vod_sub_application.go @@ -11,6 +11,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" vod "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vod/v20180717" + sdkErrors "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors" "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper" "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/ratelimit" ) @@ -96,8 +97,13 @@ func resourceTencentCloudVodSubApplicationCreate(d *schema.ResourceData, meta in ratelimit.Check(statusResquest.GetAction()) _, err := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseVodClient().ModifySubAppIdStatus(statusResquest) if err != nil { + if sdkError, ok := err.(*sdkErrors.TencentCloudSDKError); ok { + if sdkError.Code == "FailedOperation" && sdkError.Message == "invalid vod user" { + return resource.RetryableError(err) + } + } log.Printf("[CRITAL]%s api[%s] fail, reason:%s", logId, request.GetAction(), err.Error()) - return tccommon.RetryError(err) + return resource.NonRetryableError(err) } return nil }); err != nil { @@ -209,8 +215,13 @@ func resourceTencentCloudVodSubApplicationUpdate(d *schema.ResourceData, meta in ratelimit.Check(statusRequest.GetAction()) _, err = meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseVodClient().ModifySubAppIdStatus(statusRequest) if err != nil { + if sdkError, ok := err.(*sdkErrors.TencentCloudSDKError); ok { + if sdkError.Code == "FailedOperation" && sdkError.Message == "invalid vod user" { + return resource.RetryableError(err) + } + } log.Printf("[CRITAL]%s api[%s] fail, reason:%s", logId, statusRequest.GetAction(), err.Error()) - return tccommon.RetryError(err) + return resource.NonRetryableError(err) } return nil }) diff --git a/tencentcloud/services/vod/resource_tc_vod_sub_application_test.go b/tencentcloud/services/vod/resource_tc_vod_sub_application_test.go new file mode 100644 index 0000000000..a85f824e15 --- /dev/null +++ b/tencentcloud/services/vod/resource_tc_vod_sub_application_test.go @@ -0,0 +1,43 @@ +package vod_test + +import ( + "testing" + + tcacctest "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/acctest" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccTencentCloudVodSubApplicationResource(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { tcacctest.AccPreCheck(t) }, + Providers: tcacctest.AccProviders, + Steps: []resource.TestStep{ + { + Config: testAccVodSubApplication, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("tencentcloud_vod_sub_application.foo", "id"), + resource.TestCheckResourceAttr("tencentcloud_vod_sub_application.foo", "name", "foo"), + resource.TestCheckResourceAttr("tencentcloud_vod_sub_application.foo", "status", "On"), + resource.TestCheckResourceAttr("tencentcloud_vod_sub_application.foo", "description", "this is sub application"), + resource.TestCheckResourceAttrSet("tencentcloud_vod_sub_application.foo", "create_time"), + ), + }, + { + ResourceName: "tencentcloud_vod_sub_application.foo", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"status"}, + }, + }, + }) +} + +const testAccVodSubApplication = ` +resource "tencentcloud_vod_sub_application" "foo" { + name = "foo" + status = "On" + description = "this is sub application" + } +`