Skip to content

Commit f4ef8e8

Browse files
committed
add
1 parent 04f5525 commit f4ef8e8

18 files changed

+1114
-2
lines changed

tencentcloud/provider.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,6 +1300,7 @@ func Provider() *schema.Provider {
13001300
"tencentcloud_mqtt_instance_detail": mqtt.DataSourceTencentCloudMqttInstanceDetail(),
13011301
"tencentcloud_mqtt_topics": mqtt.DataSourceTencentCloudMqttTopics(),
13021302
"tencentcloud_billing_budget_operation_log": billing.DataSourceTencentCloudBillingBudgetOperationLog(),
1303+
"tencentcloud_igtm_instance_list": igtm.DataSourceTencentCloudIgtmInstanceList(),
13031304
"tencentcloud_igtm_address_pool_list": igtm.DataSourceTencentCloudIgtmAddressPoolList(),
13041305
"tencentcloud_igtm_monitors": igtm.DataSourceTencentCloudIgtmMonitors(),
13051306
"tencentcloud_igtm_detectors": igtm.DataSourceTencentCloudIgtmDetectors(),
@@ -2475,6 +2476,7 @@ func Provider() *schema.Provider {
24752476
"tencentcloud_mqtt_http_authenticator": mqtt.ResourceTencentCloudMqttHttpAuthenticator(),
24762477
"tencentcloud_billing_allocation_tag": billing.ResourceTencentCloudBillingAllocationTag(),
24772478
"tencentcloud_billing_budget": billing.ResourceTencentCloudBillingBudget(),
2479+
"tencentcloud_igtm_instance": igtm.ResourceTencentCloudIgtmInstance(),
24782480
"tencentcloud_igtm_address_pool": igtm.ResourceTencentCloudIgtmAddressPool(),
24792481
"tencentcloud_igtm_monitor": igtm.ResourceTencentCloudIgtmMonitor(),
24802482
"tencentcloud_igtm_strategy": igtm.ResourceTencentCloudIgtmStrategy(),

tencentcloud/provider.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2447,11 +2447,13 @@ tencentcloud_tcss_refresh_task_operation
24472447

24482448
Intelligent Global Traffic Manager(IGTM)
24492449
Data Source
2450+
tencentcloud_igtm_instance_list
24502451
tencentcloud_igtm_address_pool_list
24512452
tencentcloud_igtm_monitors
24522453
tencentcloud_igtm_detectors
24532454
tencentcloud_igtm_strategy_list
24542455
Resource
2456+
tencentcloud_igtm_instance
24552457
tencentcloud_igtm_address_pool
24562458
tencentcloud_igtm_monitor
24572459
tencentcloud_igtm_strategy
Lines changed: 331 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,331 @@
1+
package igtm
2+
3+
import (
4+
"context"
5+
6+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
7+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
8+
igtmv20231024 "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/igtm/v20231024"
9+
10+
tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common"
11+
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
12+
)
13+
14+
func DataSourceTencentCloudIgtmInstanceList() *schema.Resource {
15+
return &schema.Resource{
16+
Read: dataSourceTencentCloudIgtmInstanceListRead,
17+
Schema: map[string]*schema.Schema{
18+
"filters": {
19+
Type: schema.TypeList,
20+
Optional: true,
21+
Description: "Filter conditions.",
22+
Elem: &schema.Resource{
23+
Schema: map[string]*schema.Schema{
24+
"name": {
25+
Type: schema.TypeString,
26+
Required: true,
27+
Description: "Filter field name, supported list as follows:\n- InstanceId: IGTM instance ID.\n- Domain: IGTM instance domain.\n- MonitorId: Monitor ID.\n- PoolId: Pool ID. This is a required parameter, not passing it will cause interface query failure.",
28+
},
29+
"value": {
30+
Type: schema.TypeSet,
31+
Required: true,
32+
Description: "Filter field value.",
33+
Elem: &schema.Schema{
34+
Type: schema.TypeString,
35+
},
36+
},
37+
"fuzzy": {
38+
Type: schema.TypeBool,
39+
Optional: true,
40+
Description: "Whether to enable fuzzy query, only supports filter field name as domain.\nWhen fuzzy query is enabled, maximum Value length is 1, otherwise maximum Value length is 5. (Reserved field, not currently used).",
41+
},
42+
},
43+
},
44+
},
45+
46+
"instance_set": {
47+
Type: schema.TypeList,
48+
Computed: true,
49+
Description: "Instance list.",
50+
Elem: &schema.Resource{
51+
Schema: map[string]*schema.Schema{
52+
"instance_id": {
53+
Type: schema.TypeString,
54+
Computed: true,
55+
Description: "Instance ID.",
56+
},
57+
"instance_name": {
58+
Type: schema.TypeString,
59+
Computed: true,
60+
Description: "Instance name.",
61+
},
62+
"resource_id": {
63+
Type: schema.TypeString,
64+
Computed: true,
65+
Description: "Resource ID.",
66+
},
67+
"domain": {
68+
Type: schema.TypeString,
69+
Computed: true,
70+
Description: "Business domain.",
71+
},
72+
"access_type": {
73+
Type: schema.TypeString,
74+
Computed: true,
75+
Description: "Cname domain access method\nCUSTOM: Custom access domain\nSYSTEM: System access domain.",
76+
},
77+
"access_domain": {
78+
Type: schema.TypeString,
79+
Computed: true,
80+
Description: "Access domain.",
81+
},
82+
"access_sub_domain": {
83+
Type: schema.TypeString,
84+
Computed: true,
85+
Description: "Access subdomain.",
86+
},
87+
"global_ttl": {
88+
Type: schema.TypeInt,
89+
Computed: true,
90+
Description: "Global record expiration time.",
91+
},
92+
"package_type": {
93+
Type: schema.TypeString,
94+
Computed: true,
95+
Description: "Package type\nFREE: Free version\nSTANDARD: Standard version\nULTIMATE: Ultimate version.",
96+
},
97+
"working_status": {
98+
Type: schema.TypeString,
99+
Computed: true,
100+
Description: "Instance running status\nNORMAL: Healthy\nFAULTY: At risk\nDOWN: Down\nUNKNOWN: Unknown.",
101+
},
102+
"status": {
103+
Type: schema.TypeString,
104+
Computed: true,
105+
Description: "Instance status, ENABLED: Normal, DISABLED: Disabled.",
106+
},
107+
"is_cname_configured": {
108+
Type: schema.TypeBool,
109+
Computed: true,
110+
Description: "Whether cname access: true accessed; false not accessed.",
111+
},
112+
"remark": {
113+
Type: schema.TypeString,
114+
Computed: true,
115+
Description: "Remark.",
116+
},
117+
"strategy_num": {
118+
Type: schema.TypeInt,
119+
Computed: true,
120+
Description: "Strategy count.",
121+
},
122+
"address_pool_num": {
123+
Type: schema.TypeInt,
124+
Computed: true,
125+
Description: "Bound address pool count.",
126+
},
127+
"monitor_num": {
128+
Type: schema.TypeInt,
129+
Computed: true,
130+
Description: "Bound monitor count.",
131+
},
132+
"pool_id": {
133+
Type: schema.TypeInt,
134+
Computed: true,
135+
Description: "Address pool ID.",
136+
},
137+
"pool_name": {
138+
Type: schema.TypeString,
139+
Computed: true,
140+
Description: "Address pool name.",
141+
},
142+
"created_on": {
143+
Type: schema.TypeString,
144+
Computed: true,
145+
Description: "Instance creation time.",
146+
},
147+
"updated_on": {
148+
Type: schema.TypeString,
149+
Computed: true,
150+
Description: "Instance update time.",
151+
},
152+
},
153+
},
154+
},
155+
156+
"system_access_enabled": {
157+
Type: schema.TypeBool,
158+
Computed: true,
159+
Description: "Whether system domain access is supported: true supported; false not supported.",
160+
},
161+
162+
"result_output_file": {
163+
Type: schema.TypeString,
164+
Optional: true,
165+
Description: "Used to save results.",
166+
},
167+
},
168+
}
169+
}
170+
171+
func dataSourceTencentCloudIgtmInstanceListRead(d *schema.ResourceData, meta interface{}) error {
172+
defer tccommon.LogElapsed("data_source.tencentcloud_igtm_instance_list.read")()
173+
defer tccommon.InconsistentCheck(d, meta)()
174+
175+
var (
176+
logId = tccommon.GetLogId(nil)
177+
ctx = tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta)
178+
service = IgtmService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()}
179+
)
180+
181+
paramMap := make(map[string]interface{})
182+
if v, ok := d.GetOk("filters"); ok {
183+
filtersSet := v.([]interface{})
184+
tmpSet := make([]*igtmv20231024.ResourceFilter, 0, len(filtersSet))
185+
for _, item := range filtersSet {
186+
filtersMap := item.(map[string]interface{})
187+
resourceFilter := igtmv20231024.ResourceFilter{}
188+
if v, ok := filtersMap["name"].(string); ok && v != "" {
189+
resourceFilter.Name = helper.String(v)
190+
}
191+
192+
if v, ok := filtersMap["value"]; ok {
193+
valueSet := v.(*schema.Set).List()
194+
for i := range valueSet {
195+
value := valueSet[i].(string)
196+
resourceFilter.Value = append(resourceFilter.Value, helper.String(value))
197+
}
198+
}
199+
200+
if v, ok := filtersMap["fuzzy"].(bool); ok {
201+
resourceFilter.Fuzzy = helper.Bool(v)
202+
}
203+
tmpSet = append(tmpSet, &resourceFilter)
204+
}
205+
206+
paramMap["Filters"] = tmpSet
207+
}
208+
209+
var (
210+
respData []*igtmv20231024.Instance
211+
systemAccessEnabled *bool
212+
)
213+
reqErr := resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError {
214+
result, saEnabled, e := service.DescribeIgtmInstanceListByFilter(ctx, paramMap)
215+
if e != nil {
216+
return tccommon.RetryError(e)
217+
}
218+
219+
respData = result
220+
systemAccessEnabled = saEnabled
221+
return nil
222+
})
223+
224+
if reqErr != nil {
225+
return reqErr
226+
}
227+
228+
instanceSetList := make([]map[string]interface{}, 0, len(respData))
229+
if respData != nil {
230+
for _, instanceSet := range respData {
231+
instanceSetMap := map[string]interface{}{}
232+
if instanceSet.InstanceId != nil {
233+
instanceSetMap["instance_id"] = instanceSet.InstanceId
234+
}
235+
236+
if instanceSet.InstanceName != nil {
237+
instanceSetMap["instance_name"] = instanceSet.InstanceName
238+
}
239+
240+
if instanceSet.ResourceId != nil {
241+
instanceSetMap["resource_id"] = instanceSet.ResourceId
242+
}
243+
244+
if instanceSet.Domain != nil {
245+
instanceSetMap["domain"] = instanceSet.Domain
246+
}
247+
248+
if instanceSet.AccessType != nil {
249+
instanceSetMap["access_type"] = instanceSet.AccessType
250+
}
251+
252+
if instanceSet.AccessDomain != nil {
253+
instanceSetMap["access_domain"] = instanceSet.AccessDomain
254+
}
255+
256+
if instanceSet.AccessSubDomain != nil {
257+
instanceSetMap["access_sub_domain"] = instanceSet.AccessSubDomain
258+
}
259+
260+
if instanceSet.GlobalTtl != nil {
261+
instanceSetMap["global_ttl"] = instanceSet.GlobalTtl
262+
}
263+
264+
if instanceSet.PackageType != nil {
265+
instanceSetMap["package_type"] = instanceSet.PackageType
266+
}
267+
268+
if instanceSet.WorkingStatus != nil {
269+
instanceSetMap["working_status"] = instanceSet.WorkingStatus
270+
}
271+
272+
if instanceSet.Status != nil {
273+
instanceSetMap["status"] = instanceSet.Status
274+
}
275+
276+
if instanceSet.IsCnameConfigured != nil {
277+
instanceSetMap["is_cname_configured"] = instanceSet.IsCnameConfigured
278+
}
279+
280+
if instanceSet.Remark != nil {
281+
instanceSetMap["remark"] = instanceSet.Remark
282+
}
283+
284+
if instanceSet.StrategyNum != nil {
285+
instanceSetMap["strategy_num"] = instanceSet.StrategyNum
286+
}
287+
288+
if instanceSet.AddressPoolNum != nil {
289+
instanceSetMap["address_pool_num"] = instanceSet.AddressPoolNum
290+
}
291+
292+
if instanceSet.MonitorNum != nil {
293+
instanceSetMap["monitor_num"] = instanceSet.MonitorNum
294+
}
295+
296+
if instanceSet.PoolId != nil {
297+
instanceSetMap["pool_id"] = instanceSet.PoolId
298+
}
299+
300+
if instanceSet.PoolName != nil {
301+
instanceSetMap["pool_name"] = instanceSet.PoolName
302+
}
303+
304+
if instanceSet.CreatedOn != nil {
305+
instanceSetMap["created_on"] = instanceSet.CreatedOn
306+
}
307+
308+
if instanceSet.UpdatedOn != nil {
309+
instanceSetMap["updated_on"] = instanceSet.UpdatedOn
310+
}
311+
312+
instanceSetList = append(instanceSetList, instanceSetMap)
313+
}
314+
315+
_ = d.Set("instance_set", instanceSetList)
316+
}
317+
318+
if systemAccessEnabled != nil {
319+
_ = d.Set("system_access_enabled", systemAccessEnabled)
320+
}
321+
322+
d.SetId(helper.BuildToken())
323+
output, ok := d.GetOk("result_output_file")
324+
if ok && output.(string) != "" {
325+
if e := tccommon.WriteToFile(output.(string), d); e != nil {
326+
return e
327+
}
328+
}
329+
330+
return nil
331+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Use this data source to query detailed information of IGTM instance list
2+
3+
Example Usage
4+
5+
Query all igtm instance list
6+
7+
```hcl
8+
data "tencentcloud_igtm_instance_list" "example" {}
9+
```
10+
11+
Query igtm instance list by filters
12+
13+
```hcl
14+
data "tencentcloud_igtm_instance_list" "example" {
15+
filters {
16+
name = "InstanceId"
17+
value = ["gtm-uukztqtoaru"]
18+
fuzzy = true
19+
}
20+
}
21+
```

0 commit comments

Comments
 (0)