Skip to content

Commit a246915

Browse files
authored
fix(monitor): [122814398] tencentcloud_monitor_tmp_exporter_integration Offline resources (#3290)
* add * add
1 parent 436c457 commit a246915

11 files changed

+617
-17
lines changed

.changelog/3290.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_monitor_tmp_exporter_integration: This resource has been deprecated in Terraform TencentCloud provider version `1.81.182`. Please use `tencentcloud_monitor_tmp_exporter_integration_v2` instead.
3+
```
4+
5+
```release-note:new-resource
6+
tencentcloud_monitor_tmp_exporter_integration_v2
7+
```

tencentcloud/provider.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1517,6 +1517,7 @@ func Provider() *schema.Provider {
15171517
"tencentcloud_monitor_tmp_cvm_agent": tmp.ResourceTencentCloudMonitorTmpCvmAgent(),
15181518
"tencentcloud_monitor_tmp_scrape_job": tmp.ResourceTencentCloudMonitorTmpScrapeJob(),
15191519
"tencentcloud_monitor_tmp_exporter_integration": tmp.ResourceTencentCloudMonitorTmpExporterIntegration(),
1520+
"tencentcloud_monitor_tmp_exporter_integration_v2": tmp.ResourceTencentCloudMonitorTmpExporterIntegrationV2(),
15201521
"tencentcloud_monitor_tmp_alert_rule": tmp.ResourceTencentCloudMonitorTmpAlertRule(),
15211522
"tencentcloud_monitor_tmp_recording_rule": tmp.ResourceTencentCloudMonitorTmpRecordingRule(),
15221523
"tencentcloud_monitor_tmp_multiple_writes": tmp.ResourceTencentCloudMonitorTmpMultipleWrites(),

tencentcloud/provider.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,7 @@ Resource
849849
tencentcloud_monitor_tmp_instance
850850
tencentcloud_monitor_tmp_alert_rule
851851
tencentcloud_monitor_tmp_exporter_integration
852+
tencentcloud_monitor_tmp_exporter_integration_v2
852853
tencentcloud_monitor_tmp_cvm_agent
853854
tencentcloud_monitor_tmp_scrape_job
854855
tencentcloud_monitor_tmp_recording_rule

tencentcloud/services/monitor/service_tencentcloud_monitor.go

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -544,14 +544,26 @@ func (me *MonitorService) DescribeMonitorTmpExporterIntegration(ctx context.Cont
544544
}()
545545

546546
ids := strings.Split(tmpExporterIntegrationId, tccommon.FILED_SP)
547-
if ids[0] != "" {
548-
request.Name = &ids[0]
547+
if len(ids) == 5 {
548+
if ids[0] != "" {
549+
request.Name = &ids[0]
550+
}
551+
552+
request.InstanceId = &ids[1]
553+
kubeType, _ := strconv.Atoi(ids[2])
554+
request.KubeType = helper.IntInt64(kubeType)
555+
request.ClusterId = &ids[3]
556+
request.Kind = &ids[4]
557+
} else if len(ids) == 3 {
558+
if ids[0] != "" {
559+
request.Name = &ids[0]
560+
}
561+
562+
request.InstanceId = &ids[1]
563+
request.Kind = &ids[2]
564+
} else {
565+
return nil, fmt.Errorf("id is broken, id is %s", tmpExporterIntegrationId)
549566
}
550-
request.InstanceId = &ids[1]
551-
kubeType, _ := strconv.Atoi(ids[2])
552-
request.KubeType = helper.IntInt64(kubeType)
553-
request.ClusterId = &ids[3]
554-
request.Kind = &ids[4]
555567

556568
response, err := me.client.UseMonitorClient().DescribeExporterIntegrations(request)
557569
if err != nil {
@@ -560,12 +572,14 @@ func (me *MonitorService) DescribeMonitorTmpExporterIntegration(ctx context.Cont
560572
errRet = err
561573
return
562574
}
575+
563576
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n",
564577
logId, request.GetAction(), request.ToJsonString(), response.ToJsonString())
565578

566579
if len(response.Response.IntegrationSet) < 1 {
567580
return
568581
}
582+
569583
tmpExporterIntegration = response.Response.IntegrationSet[0]
570584
return
571585
}
@@ -576,12 +590,26 @@ func (me *MonitorService) DeleteMonitorTmpExporterIntegrationById(ctx context.Co
576590
request := monitor.NewDeleteExporterIntegrationRequest()
577591
ids := strings.Split(tmpExporterIntegrationId, tccommon.FILED_SP)
578592

579-
request.Name = &ids[0]
580-
request.InstanceId = &ids[1]
581-
kubeType, _ := strconv.Atoi(ids[2])
582-
request.KubeType = helper.IntInt64(kubeType)
583-
request.ClusterId = &ids[3]
584-
request.Kind = &ids[4]
593+
if len(ids) == 5 {
594+
if ids[0] != "" {
595+
request.Name = &ids[0]
596+
}
597+
598+
request.InstanceId = &ids[1]
599+
kubeType, _ := strconv.Atoi(ids[2])
600+
request.KubeType = helper.IntInt64(kubeType)
601+
request.ClusterId = &ids[3]
602+
request.Kind = &ids[4]
603+
} else if len(ids) == 3 {
604+
if ids[0] != "" {
605+
request.Name = &ids[0]
606+
}
607+
608+
request.InstanceId = &ids[1]
609+
request.Kind = &ids[2]
610+
} else {
611+
return fmt.Errorf("id is broken, id is %s", tmpExporterIntegrationId)
612+
}
585613

586614
defer func() {
587615
if errRet != nil {
@@ -596,6 +624,7 @@ func (me *MonitorService) DeleteMonitorTmpExporterIntegrationById(ctx context.Co
596624
errRet = err
597625
return err
598626
}
627+
599628
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n",
600629
logId, request.GetAction(), request.ToJsonString(), response.ToJsonString())
601630

tencentcloud/services/tmp/resource_tc_monitor_tmp_exporter_integration.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ import (
1919

2020
func ResourceTencentCloudMonitorTmpExporterIntegration() *schema.Resource {
2121
return &schema.Resource{
22-
Read: resourceTencentCloudMonitorTmpExporterIntegrationRead,
23-
Create: resourceTencentCloudMonitorTmpExporterIntegrationCreate,
24-
Update: resourceTencentCloudMonitorTmpExporterIntegrationUpdate,
25-
Delete: resourceTencentCloudMonitorTmpExporterIntegrationDelete,
22+
DeprecationMessage: "This resource has been deprecated in Terraform TencentCloud provider version 1.81.182. Please use 'tencentcloud_monitor_tmp_exporter_integration_v2' instead.",
23+
Read: resourceTencentCloudMonitorTmpExporterIntegrationRead,
24+
Create: resourceTencentCloudMonitorTmpExporterIntegrationCreate,
25+
Update: resourceTencentCloudMonitorTmpExporterIntegrationUpdate,
26+
Delete: resourceTencentCloudMonitorTmpExporterIntegrationDelete,
2627
Schema: map[string]*schema.Schema{
2728
"instance_id": {
2829
Type: schema.TypeString,

tencentcloud/services/tmp/resource_tc_monitor_tmp_exporter_integration.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
Provides a resource to create a monitor tmpExporterIntegration
22

3+
~> **NOTE:** This resource has been deprecated in Terraform TencentCloud provider version `1.81.182`. Please use `tencentcloud_monitor_tmp_exporter_integration_v2` instead.
4+
35
~> **NOTE:** If you only want to upgrade the exporter version with same config, you can set `version` under `instanceSpec` with any value to trigger the change.
46

57
Example Usage

0 commit comments

Comments
 (0)