diff --git a/tencentcloud/common/cloud_common.go b/tencentcloud/common/cloud_common.go index f859bfa576..b3bf79c408 100644 --- a/tencentcloud/common/cloud_common.go +++ b/tencentcloud/common/cloud_common.go @@ -18,6 +18,8 @@ const ( DefaultSearchLogStartTimestamp = 1699346460000 DefaultTopicId = "aef50d54-b17d-4782-8618-a7873203ec29" + + QueryGrammarRule = " AND " ) // ResourceAccountInfo 资源账户信息 @@ -40,9 +42,11 @@ func GetResourceCreatorAccountInfo(client *connectivity.TencentCloudClient, reso request.From = helper.IntInt64(DefaultSearchLogStartTimestamp) request.To = helper.Int64(CurrentTimeMillisecond()) request.TopicId = helper.String(DefaultTopicId) - request.Query = helper.String(resourceCreateAction) for _, r := range resources { + query := resourceCreateAction + QueryGrammarRule + r.Id + request.Query = helper.String(query) + response, err := client.UseClsClient().SearchLog(request) if err != nil { log.Printf("[CRITAL] search resource[%v] log data error: %v", r.Id, err.Error()) diff --git a/tencentcloud/services/as/resource_tc_as_attachment_test.go b/tencentcloud/services/as/resource_tc_as_attachment_test.go index 09c827e4e4..80448174ad 100644 --- a/tencentcloud/services/as/resource_tc_as_attachment_test.go +++ b/tencentcloud/services/as/resource_tc_as_attachment_test.go @@ -51,7 +51,7 @@ func testSweepAsAttachment(r string) error { CreatTime: *v.CreatedTime, }) } - tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "") + tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateAutoScalingGroup") for _, v := range scalingGroups { scalingGroupId := *v.AutoScalingGroupId diff --git a/tencentcloud/services/cam/resource_tc_cam_group_test.go b/tencentcloud/services/cam/resource_tc_cam_group_test.go index 161b73da50..d06f62ba20 100644 --- a/tencentcloud/services/cam/resource_tc_cam_group_test.go +++ b/tencentcloud/services/cam/resource_tc_cam_group_test.go @@ -50,7 +50,7 @@ func init() { CreatTime: *v.CreateTime, }) } - tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "") + tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateGroup") for _, v := range groups { name := *v.GroupName diff --git a/tencentcloud/services/cbs/resource_tc_cbs_storage_test.go b/tencentcloud/services/cbs/resource_tc_cbs_storage_test.go index 1bee6c4b65..7840cedf5e 100644 --- a/tencentcloud/services/cbs/resource_tc_cbs_storage_test.go +++ b/tencentcloud/services/cbs/resource_tc_cbs_storage_test.go @@ -46,7 +46,7 @@ func init() { CreatTime: *v.CreateTime, }) } - tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "") + tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateDisks") for i := range disks { disk := disks[i] diff --git a/tencentcloud/services/ccn/resource_tc_ccn_test.go b/tencentcloud/services/ccn/resource_tc_ccn_test.go index 43ef67b53f..fae4f7c7ad 100644 --- a/tencentcloud/services/ccn/resource_tc_ccn_test.go +++ b/tencentcloud/services/ccn/resource_tc_ccn_test.go @@ -56,7 +56,7 @@ func testSweepCcnInstance(region string) error { CreatTime: v.CreateTime(), }) } - tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "") + tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateCcn") for _, v := range instances { instanceId := v.CcnId() diff --git a/tencentcloud/services/cdb/resource_tc_mysql_instance_test.go b/tencentcloud/services/cdb/resource_tc_mysql_instance_test.go index 3ac865af51..7aebc1cc3a 100644 --- a/tencentcloud/services/cdb/resource_tc_mysql_instance_test.go +++ b/tencentcloud/services/cdb/resource_tc_mysql_instance_test.go @@ -68,7 +68,7 @@ func testSweepMySQLInstance(region string) error { CreatTime: *v.CreateTime, }) } - tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "") + tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateDBInstance") for _, v := range items { id := *v.InstanceId diff --git a/tencentcloud/services/clb/resource_tc_clb_instance_test.go b/tencentcloud/services/clb/resource_tc_clb_instance_test.go index 0901293daa..94d71f4490 100644 --- a/tencentcloud/services/clb/resource_tc_clb_instance_test.go +++ b/tencentcloud/services/clb/resource_tc_clb_instance_test.go @@ -62,7 +62,7 @@ func testSweepClbInstance(region string) error { CreatTime: *v.CreateTime, }) } - tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "") + tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateLoadBalancer") if len(res) > 0 { for _, v := range res { diff --git a/tencentcloud/services/cls/resource_tc_cls_topic_test.go b/tencentcloud/services/cls/resource_tc_cls_topic_test.go index d1b43db982..f9c6b66023 100644 --- a/tencentcloud/services/cls/resource_tc_cls_topic_test.go +++ b/tencentcloud/services/cls/resource_tc_cls_topic_test.go @@ -55,7 +55,7 @@ func testSweepClsTopic(region string) error { CreatTime: *v.CreateTime, }) } - tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "") + tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateTopic") for _, v := range instances { instanceId := v.TopicId diff --git a/tencentcloud/services/cos/resource_tc_cos_bucket_test.go b/tencentcloud/services/cos/resource_tc_cos_bucket_test.go index 0f8a82c7eb..6f9e0ced2c 100644 --- a/tencentcloud/services/cos/resource_tc_cos_bucket_test.go +++ b/tencentcloud/services/cos/resource_tc_cos_bucket_test.go @@ -52,7 +52,7 @@ func testSweepCosBuckets(region string) error { CreatTime: v.CreationDate.Format("2006-01-02 15:04:05"), }) } - tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "") + tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "PutBucket") //prefix := regexp.MustCompile("^(tf|test)-") diff --git a/tencentcloud/services/scf/resource_tc_scf_function_test.go b/tencentcloud/services/scf/resource_tc_scf_function_test.go index 1b9a7df78e..405c7c1e66 100644 --- a/tencentcloud/services/scf/resource_tc_scf_function_test.go +++ b/tencentcloud/services/scf/resource_tc_scf_function_test.go @@ -60,7 +60,7 @@ func init() { CreatTime: *v.AddTime, }) } - tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "") + tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateFunction") for _, fun := range funs { createTime := tccommon.StringToTime(*fun.AddTime) diff --git a/tencentcloud/services/sqlserver/resource_tc_sqlserver_account_test.go b/tencentcloud/services/sqlserver/resource_tc_sqlserver_account_test.go index 4e613ece90..e17d039f9a 100644 --- a/tencentcloud/services/sqlserver/resource_tc_sqlserver_account_test.go +++ b/tencentcloud/services/sqlserver/resource_tc_sqlserver_account_test.go @@ -59,7 +59,7 @@ func init() { CreatTime: *v.CreateTime, }) } - tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "") + tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateAccount") for i := range accounts { account := accounts[i] diff --git a/tencentcloud/services/sqlserver/resource_tc_sqlserver_db_test.go b/tencentcloud/services/sqlserver/resource_tc_sqlserver_db_test.go index 02457a18b8..6c210b0527 100644 --- a/tencentcloud/services/sqlserver/resource_tc_sqlserver_db_test.go +++ b/tencentcloud/services/sqlserver/resource_tc_sqlserver_db_test.go @@ -68,7 +68,7 @@ func init() { CreatTime: *v.CreateTime, }) } - tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "") + tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateDB") for i := range dbs { db := dbs[i] diff --git a/tencentcloud/services/sqlserver/resource_tc_sqlserver_instance_test.go b/tencentcloud/services/sqlserver/resource_tc_sqlserver_instance_test.go index 62d9f9fe11..3d6b07f30b 100644 --- a/tencentcloud/services/sqlserver/resource_tc_sqlserver_instance_test.go +++ b/tencentcloud/services/sqlserver/resource_tc_sqlserver_instance_test.go @@ -51,7 +51,7 @@ func init() { CreatTime: *v.CreateTime, }) } - tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "") + tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateDBInstances") err = batchDeleteSQLServerInstances(ctx, service, instances) diff --git a/tencentcloud/services/tcr/resource_tc_tcr_customized_domain_test.go b/tencentcloud/services/tcr/resource_tc_tcr_customized_domain_test.go index 3d9196b0cc..b3b6c35f1b 100644 --- a/tencentcloud/services/tcr/resource_tc_tcr_customized_domain_test.go +++ b/tencentcloud/services/tcr/resource_tc_tcr_customized_domain_test.go @@ -50,7 +50,7 @@ func testSweepTcrCustomizedDomain(r string) error { Name: *v.DomainName, }) } - tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "") + tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateInstanceCustomizedDomain") for _, v := range domains { delName := *v.DomainName diff --git a/tencentcloud/services/tcr/resource_tc_tcr_immutable_tag_rule_test.go b/tencentcloud/services/tcr/resource_tc_tcr_immutable_tag_rule_test.go index 05af551e3e..744f075828 100644 --- a/tencentcloud/services/tcr/resource_tc_tcr_immutable_tag_rule_test.go +++ b/tencentcloud/services/tcr/resource_tc_tcr_immutable_tag_rule_test.go @@ -58,7 +58,7 @@ func testSweepTcrImmutableTagRule(r string) error { Id: helper.Int64ToStr(*v.RuleId), }) } - tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "") + tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateImmutableTagRules") for _, rule := range rules { ruleId := helper.Int64ToStr(*rule.RuleId) diff --git a/tencentcloud/services/tcr/resource_tc_tcr_instance_test.go b/tencentcloud/services/tcr/resource_tc_tcr_instance_test.go index f3191c663f..5f2f1e1486 100644 --- a/tencentcloud/services/tcr/resource_tc_tcr_instance_test.go +++ b/tencentcloud/services/tcr/resource_tc_tcr_instance_test.go @@ -51,7 +51,7 @@ func init() { CreatTime: *v.CreatedAt, }) } - tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "") + tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateInstance") for i := range instances { ins := instances[i] diff --git a/tencentcloud/services/tcr/resource_tc_tcr_namespace_test.go b/tencentcloud/services/tcr/resource_tc_tcr_namespace_test.go index 89df5fc2f3..af6e9c7261 100644 --- a/tencentcloud/services/tcr/resource_tc_tcr_namespace_test.go +++ b/tencentcloud/services/tcr/resource_tc_tcr_namespace_test.go @@ -68,7 +68,7 @@ func init() { CreatTime: *v.CreationTime, }) } - tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "") + tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateNamespace") for i := range namespaces { n := namespaces[i] diff --git a/tencentcloud/services/tcr/resource_tc_tcr_repository_test.go b/tencentcloud/services/tcr/resource_tc_tcr_repository_test.go index b5c0cb74e5..7ee81825f7 100644 --- a/tencentcloud/services/tcr/resource_tc_tcr_repository_test.go +++ b/tencentcloud/services/tcr/resource_tc_tcr_repository_test.go @@ -74,7 +74,7 @@ func testSweepTCRRepository(r string) error { CreatTime: *v.CreationTime, }) } - tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "") + tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateRepository") for i := range repos { n := repos[i] diff --git a/tencentcloud/services/tcr/resource_tc_tcr_token_test.go b/tencentcloud/services/tcr/resource_tc_tcr_token_test.go index e0f2acf6bc..4273892e08 100644 --- a/tencentcloud/services/tcr/resource_tc_tcr_token_test.go +++ b/tencentcloud/services/tcr/resource_tc_tcr_token_test.go @@ -67,7 +67,7 @@ func init() { CreatTime: *v.CreatedAt, }) } - tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "") + tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateInstanceToken") for i := range tokens { token := tokens[i] diff --git a/tencentcloud/services/tke/resource_tc_kubernetes_cluster_test.go b/tencentcloud/services/tke/resource_tc_kubernetes_cluster_test.go index 62ea08cb13..b8c996ad63 100644 --- a/tencentcloud/services/tke/resource_tc_kubernetes_cluster_test.go +++ b/tencentcloud/services/tke/resource_tc_kubernetes_cluster_test.go @@ -52,7 +52,7 @@ func init() { CreatTime: v.CreatedTime, }) } - tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "") + tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateCluster") for _, v := range clusters { id := v.ClusterId diff --git a/tencentcloud/services/tke/resource_tc_kubernetes_node_pool_test.go b/tencentcloud/services/tke/resource_tc_kubernetes_node_pool_test.go index 576b481a5f..f29d09a17f 100644 --- a/tencentcloud/services/tke/resource_tc_kubernetes_node_pool_test.go +++ b/tencentcloud/services/tke/resource_tc_kubernetes_node_pool_test.go @@ -79,7 +79,7 @@ func testNodePoolSweep(region string) error { Name: *v.Name, }) } - tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "") + tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateClusterNodePool") for i := range nodePools { poolId := *nodePools[i].NodePoolId diff --git a/tencentcloud/services/tke/resource_tc_kubernetes_scale_worker_test.go b/tencentcloud/services/tke/resource_tc_kubernetes_scale_worker_test.go index b2e1822d4a..17616415af 100644 --- a/tencentcloud/services/tke/resource_tc_kubernetes_scale_worker_test.go +++ b/tencentcloud/services/tke/resource_tc_kubernetes_scale_worker_test.go @@ -87,7 +87,7 @@ func init() { instanceIds = append(instanceIds, worker.InstanceId) } - tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "") + tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateClusterInstances") err = service.DeleteClusterInstances(ctx, clusterId, instanceIds) if err != nil { diff --git a/tencentcloud/services/vpc/resource_tc_eni_test.go b/tencentcloud/services/vpc/resource_tc_eni_test.go index bd60b9fc02..c00439748e 100644 --- a/tencentcloud/services/vpc/resource_tc_eni_test.go +++ b/tencentcloud/services/vpc/resource_tc_eni_test.go @@ -56,7 +56,7 @@ func testSweepEniInstance(region string) error { CreatTime: *v.CreatedTime, }) } - tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "") + tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateNetworkInterface") for _, v := range instances { instanceId := *v.NetworkInterfaceId diff --git a/tencentcloud/services/vpc/resource_tc_ha_vip_test.go b/tencentcloud/services/vpc/resource_tc_ha_vip_test.go index 4044d91b1a..f7bc3c95ae 100644 --- a/tencentcloud/services/vpc/resource_tc_ha_vip_test.go +++ b/tencentcloud/services/vpc/resource_tc_ha_vip_test.go @@ -58,7 +58,7 @@ func testSweepHaVipInstance(region string) error { CreatTime: *v.CreatedTime, }) } - tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "") + tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateHaVip") for _, v := range instances { instanceId := *v.HaVipId diff --git a/tencentcloud/services/vpc/resource_tc_nat_gateway_test.go b/tencentcloud/services/vpc/resource_tc_nat_gateway_test.go index 3663a0acbd..266e3f99f9 100644 --- a/tencentcloud/services/vpc/resource_tc_nat_gateway_test.go +++ b/tencentcloud/services/vpc/resource_tc_nat_gateway_test.go @@ -56,7 +56,7 @@ func testSweepNatInstance(region string) error { CreatTime: *v.CreatedTime, }) } - tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "") + tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateNatGateway") for _, v := range instances { instanceId := *v.NatGatewayId diff --git a/tencentcloud/services/vpc/resource_tc_security_group_test.go b/tencentcloud/services/vpc/resource_tc_security_group_test.go index 2523905241..e96628d9bd 100644 --- a/tencentcloud/services/vpc/resource_tc_security_group_test.go +++ b/tencentcloud/services/vpc/resource_tc_security_group_test.go @@ -54,7 +54,7 @@ func testSweepSecurityGroups(region string) error { CreatTime: *v.CreatedTime, }) } - tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "") + tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateSecurityGroup") for _, v := range sgs { name := *v.SecurityGroupName diff --git a/tencentcloud/services/vpc/resource_tc_subnet_test.go b/tencentcloud/services/vpc/resource_tc_subnet_test.go index f0798a246f..5a78902a2c 100644 --- a/tencentcloud/services/vpc/resource_tc_subnet_test.go +++ b/tencentcloud/services/vpc/resource_tc_subnet_test.go @@ -56,7 +56,7 @@ func testSweepSubnet(region string) error { CreatTime: v.CreateTime(), }) } - tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "") + tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateSubnet") for _, v := range instances { diff --git a/tencentcloud/services/vpn/resource_tc_vpn_gateway_test.go b/tencentcloud/services/vpn/resource_tc_vpn_gateway_test.go index de82d965f5..7bfeca6146 100644 --- a/tencentcloud/services/vpn/resource_tc_vpn_gateway_test.go +++ b/tencentcloud/services/vpn/resource_tc_vpn_gateway_test.go @@ -57,7 +57,7 @@ func testSweepVpnGateway(region string) error { CreatTime: *v.CreatedTime, }) } - tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "") + tccommon.ProcessScanCloudResources(client, resources, nonKeepResources, "CreateVpnGateway") for _, v := range instances {