Skip to content

Commit 170cf11

Browse files
gitmknanonymous
andauthored
Feat/tse support (#1736)
* feat: support mariadb * feat: add changelog * fix: modfiy operation * fix: modify datasource * fix: mdoify encrypt_attributes * feat: support tse * fix: update doc * fix: modify tse * fix: modify tse * fix: modify tse * fix: modify tse * fix: modify tse * fix: modify tse * feat: add changelog --------- Co-authored-by: anonymous <anonymous@mail.org>
1 parent ace4733 commit 170cf11

28 files changed

+4797
-0
lines changed

.changelog/1736.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
```release-note:new-resource
2+
tencentcloud_tse_instance
3+
```
4+
5+
```release-note:new-data-source
6+
tencentcloud_tse_access_address
7+
```
8+
9+
```release-note:new-data-source
10+
tencentcloud_tse_nacos_replicas
11+
```
12+
13+
```release-note:new-data-source
14+
tencentcloud_tse_zookeeper_replicas
15+
```
16+
17+
```release-note:new-data-source
18+
tencentcloud_tse_zookeeper_server_interfaces
19+
```

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ require (
8282
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tem v1.0.578
8383
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo v1.0.529
8484
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.644
85+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tse v1.0.650
8586
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.648
8687
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vod v1.0.199
8788
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.0.648

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,6 +1842,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.638/go.mod
18421842
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.644/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y=
18431843
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.648 h1:6vfUm7HHwPZxdQ5FQaG0vNdvb89KSnF/n+TjvM8XxcQ=
18441844
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.648/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y=
1845+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.650 h1:oP2OB41u5pfwKWCxWihl/OVWHEPlO6NLZILvZIifU4c=
1846+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.650/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y=
18451847
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.652 h1:BQzWuLoLd6Fp8swG5XXidQn7Wnp40Nm2xthobeZ/eRg=
18461848
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.652/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y=
18471849
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.624 h1:nEZqsoqt1pEoaP9JjkHQy3/H00suCfzlHW1qOm2nYD8=
@@ -1935,6 +1937,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo v1.0.529 h1:vWUgseU
19351937
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo v1.0.529/go.mod h1:vOd23iOVeQqm5LSEXUmE8773kiUCwGuoJnTO0po5D+Q=
19361938
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.644 h1:iyS55TcFRybmnn1SHR7HgLcdaSsxFmY+T1WORE0Znww=
19371939
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.644/go.mod h1:xJIrKYqmsIFTUovx1cwuH8GGu2arW5CDFvM6eqQGf7Q=
1940+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tse v1.0.650 h1:gQFdOULR78GKaUwPkHnupLTZO5Z3STZ1xSp/83xZMnA=
1941+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tse v1.0.650/go.mod h1:cNgQjHihEHq9Z2n6sSe/l7gG6pf7nhWue7e+Iu+wQCc=
19381942
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.648 h1:2W0dqmFYuJNdNcBgRSoRVeLl6I34kqQQeIuDeJHZAyY=
19391943
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.648/go.mod h1:Motj98jn34I9Wr5ZINwz6WIe+Wuf75+Otf3NEoO66HE=
19401944
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vod v1.0.199 h1:6Yt74l4pA5QtzhwMNIEUt0spXdSBKH744DDqTHJOCP0=

tencentcloud/basic_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,3 +1013,12 @@ variable "lighthouse_snapshot_id" {
10131013
default = "` + defaultLighthouseSnapshotId + `"
10141014
}
10151015
`
1016+
1017+
// TSE
1018+
const (
1019+
defaultEngineResourceSpec = "spec-qvj6k7t4q"
1020+
defaultTseVpcId = "vpc-4owdpnwr"
1021+
defaultTseSubnetId = "subnet-dwj7ipnc"
1022+
)
1023+
1024+
// End of TSE

tencentcloud/connectivity/client.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ import (
7878
tem "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tem/v20210701"
7979
teo "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo/v20220901"
8080
tke "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525"
81+
tse "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tse/v20201207"
8182
tsf "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf/v20180326"
8283
vod "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vod/v20180717"
8384
vpc "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc/v20170312"
@@ -163,6 +164,7 @@ type TencentCloudClient struct {
163164
chdfsConn *chdfs.Client
164165
mdlConn *mdl.Client
165166
apmConn *apm.Client
167+
tseConn *tse.Client
166168
}
167169

168170
// NewClientProfile returns a new ClientProfile
@@ -1136,6 +1138,20 @@ func (me *TencentCloudClient) UseApmClient() *apm.Client {
11361138
return me.apmConn
11371139
}
11381140

1141+
// UseTseClient returns tse client for service
1142+
func (me *TencentCloudClient) UseTseClient() *tse.Client {
1143+
if me.tseConn != nil {
1144+
return me.tseConn
1145+
}
1146+
1147+
cpf := me.NewClientProfile(300)
1148+
cpf.Language = "zh-CN"
1149+
me.tseConn, _ = tse.NewClient(me.Credential, me.Region, cpf)
1150+
me.tseConn.WithHttpTransport(&LogRoundTripper{})
1151+
1152+
return me.tseConn
1153+
}
1154+
11391155
func getEnvDefault(key string, defVal int) int {
11401156
val, ex := os.LookupEnv(key)
11411157
if !ex {
Lines changed: 288 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,288 @@
1+
/*
2+
Use this data source to query detailed information of tse access_address
3+
4+
Example Usage
5+
6+
```hcl
7+
data "tencentcloud_tse_access_address" "access_address" {
8+
instance_id = "ins-7eb7eea7"
9+
# vpc_id = "vpc-xxxxxx"
10+
# subnet_id = "subnet-xxxxxx"
11+
# workload = "pushgateway"
12+
engine_region = "ap-guangzhou"
13+
}
14+
```
15+
*/
16+
package tencentcloud
17+
18+
import (
19+
"context"
20+
21+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
22+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
23+
tse "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tse/v20201207"
24+
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
25+
)
26+
27+
func dataSourceTencentCloudTseAccessAddress() *schema.Resource {
28+
return &schema.Resource{
29+
Read: dataSourceTencentCloudTseAccessAddressRead,
30+
Schema: map[string]*schema.Schema{
31+
"instance_id": {
32+
Required: true,
33+
Type: schema.TypeString,
34+
Description: "engine instance Id.",
35+
},
36+
37+
"vpc_id": {
38+
Optional: true,
39+
Type: schema.TypeString,
40+
Description: "VPC ID, Zookeeper does not need to pass vpcid and subnetid; nacos and Polaris need to pass vpcid and subnetid.",
41+
},
42+
43+
"subnet_id": {
44+
Optional: true,
45+
Type: schema.TypeString,
46+
Description: "Subnet ID, Zookeeper does not need to pass vpcid and subnetid; nacos and Polaris need to pass vpcid and subnetid.",
47+
},
48+
49+
"workload": {
50+
Optional: true,
51+
Type: schema.TypeString,
52+
Description: "Name of other engine components(pushgateway, polaris-limiter).",
53+
},
54+
55+
"engine_region": {
56+
Optional: true,
57+
Type: schema.TypeString,
58+
Description: "Deploy region.",
59+
},
60+
61+
"intranet_address": {
62+
Computed: true,
63+
Type: schema.TypeString,
64+
Description: "Intranet access address.",
65+
},
66+
67+
"internet_address": {
68+
Computed: true,
69+
Type: schema.TypeString,
70+
Description: "Public access address.",
71+
},
72+
73+
"env_address_infos": {
74+
Computed: true,
75+
Type: schema.TypeList,
76+
Description: "Apollo Multi-environment public ip address.",
77+
Elem: &schema.Resource{
78+
Schema: map[string]*schema.Schema{
79+
"env_name": {
80+
Type: schema.TypeString,
81+
Computed: true,
82+
Description: "env name.",
83+
},
84+
"enable_config_internet": {
85+
Type: schema.TypeBool,
86+
Computed: true,
87+
Description: "Whether to enable the config public network.",
88+
},
89+
"config_internet_service_ip": {
90+
Type: schema.TypeString,
91+
Computed: true,
92+
Description: "config public network ip.",
93+
},
94+
"config_intranet_address": {
95+
Type: schema.TypeString,
96+
Computed: true,
97+
Description: "config Intranet access addressNote: This field may return null, indicating that a valid value is not available.",
98+
},
99+
"enable_config_intranet": {
100+
Type: schema.TypeBool,
101+
Computed: true,
102+
Description: "Whether to enable the config Intranet clbNote: This field may return null, indicating that a valid value is not available.",
103+
},
104+
"internet_band_width": {
105+
Type: schema.TypeInt,
106+
Computed: true,
107+
Description: "Client public network bandwidthNote: This field may return null, indicating that a valid value is not available.",
108+
},
109+
},
110+
},
111+
},
112+
113+
"console_internet_address": {
114+
Computed: true,
115+
Type: schema.TypeString,
116+
Description: "Console public network access addressNote: This field may return null, indicating that a valid value is not available.",
117+
},
118+
119+
"console_intranet_address": {
120+
Computed: true,
121+
Type: schema.TypeString,
122+
Description: "Console Intranet access addressNote: This field may return null, indicating that a valid value is not available.",
123+
},
124+
125+
"internet_band_width": {
126+
Computed: true,
127+
Type: schema.TypeInt,
128+
Description: "Client public network bandwidthNote: This field may return null, indicating that a valid value is not available.",
129+
},
130+
131+
"console_internet_band_width": {
132+
Computed: true,
133+
Type: schema.TypeInt,
134+
Description: "Console public network bandwidthNote: This field may return null, indicating that a valid value is not available.",
135+
},
136+
137+
"limiter_address_infos": {
138+
Computed: true,
139+
Type: schema.TypeList,
140+
Description: "Access IP address of the Polaris traffic limiting server nodeNote: This field may return null, indicating that a valid value is not available.",
141+
Elem: &schema.Resource{
142+
Schema: map[string]*schema.Schema{
143+
"intranet_address": {
144+
Type: schema.TypeString,
145+
Computed: true,
146+
Description: "VPC access IP address listNote: This field may return null, indicating that a valid value is not available.",
147+
},
148+
},
149+
},
150+
},
151+
152+
"result_output_file": {
153+
Type: schema.TypeString,
154+
Optional: true,
155+
Description: "Used to save results.",
156+
},
157+
},
158+
}
159+
}
160+
161+
func dataSourceTencentCloudTseAccessAddressRead(d *schema.ResourceData, meta interface{}) error {
162+
defer logElapsed("data_source.tencentcloud_tse_access_address.read")()
163+
defer inconsistentCheck(d, meta)()
164+
165+
logId := getLogId(contextNil)
166+
167+
ctx := context.WithValue(context.TODO(), logIdKey, logId)
168+
169+
paramMap := make(map[string]interface{})
170+
if v, ok := d.GetOk("instance_id"); ok {
171+
paramMap["InstanceId"] = helper.String(v.(string))
172+
}
173+
174+
if v, ok := d.GetOk("vpc_id"); ok {
175+
paramMap["VpcId"] = helper.String(v.(string))
176+
}
177+
178+
if v, ok := d.GetOk("subnet_id"); ok {
179+
paramMap["SubnetId"] = helper.String(v.(string))
180+
}
181+
182+
if v, ok := d.GetOk("workload"); ok {
183+
paramMap["Workload"] = helper.String(v.(string))
184+
}
185+
186+
if v, ok := d.GetOk("engine_region"); ok {
187+
paramMap["EngineRegion"] = helper.String(v.(string))
188+
}
189+
190+
service := TseService{client: meta.(*TencentCloudClient).apiV3Conn}
191+
var accessAddress *tse.DescribeSREInstanceAccessAddressResponseParams
192+
err := resource.Retry(readRetryTimeout, func() *resource.RetryError {
193+
result, e := service.DescribeTseAccessAddressByFilter(ctx, paramMap)
194+
if e != nil {
195+
return retryError(e)
196+
}
197+
accessAddress = result
198+
return nil
199+
})
200+
if err != nil {
201+
return err
202+
}
203+
204+
ids := []string{""}
205+
if accessAddress.IntranetAddress != nil {
206+
ids = append(ids, *accessAddress.IntranetAddress)
207+
_ = d.Set("intranet_address", accessAddress.IntranetAddress)
208+
}
209+
210+
if accessAddress.InternetAddress != nil {
211+
_ = d.Set("internet_address", accessAddress.InternetAddress)
212+
}
213+
214+
if accessAddress.EnvAddressInfos != nil {
215+
tmpList := make([]map[string]interface{}, 0, len(accessAddress.EnvAddressInfos))
216+
for _, envAddressInfo := range accessAddress.EnvAddressInfos {
217+
envAddressInfoMap := map[string]interface{}{}
218+
219+
if envAddressInfo.EnvName != nil {
220+
envAddressInfoMap["env_name"] = envAddressInfo.EnvName
221+
}
222+
223+
if envAddressInfo.EnableConfigInternet != nil {
224+
envAddressInfoMap["enable_config_internet"] = envAddressInfo.EnableConfigInternet
225+
}
226+
227+
if envAddressInfo.ConfigInternetServiceIp != nil {
228+
envAddressInfoMap["config_internet_service_ip"] = envAddressInfo.ConfigInternetServiceIp
229+
}
230+
231+
if envAddressInfo.ConfigIntranetAddress != nil {
232+
envAddressInfoMap["config_intranet_address"] = envAddressInfo.ConfigIntranetAddress
233+
}
234+
235+
if envAddressInfo.EnableConfigIntranet != nil {
236+
envAddressInfoMap["enable_config_intranet"] = envAddressInfo.EnableConfigIntranet
237+
}
238+
239+
if envAddressInfo.InternetBandWidth != nil {
240+
envAddressInfoMap["internet_band_width"] = envAddressInfo.InternetBandWidth
241+
}
242+
243+
tmpList = append(tmpList, envAddressInfoMap)
244+
}
245+
246+
_ = d.Set("env_address_infos", tmpList)
247+
}
248+
249+
if accessAddress.ConsoleInternetAddress != nil {
250+
_ = d.Set("console_internet_address", accessAddress.ConsoleInternetAddress)
251+
}
252+
253+
if accessAddress.ConsoleIntranetAddress != nil {
254+
_ = d.Set("console_intranet_address", accessAddress.ConsoleIntranetAddress)
255+
}
256+
257+
if accessAddress.InternetBandWidth != nil {
258+
_ = d.Set("internet_band_width", accessAddress.InternetBandWidth)
259+
}
260+
261+
if accessAddress.ConsoleInternetBandWidth != nil {
262+
_ = d.Set("console_internet_band_width", accessAddress.ConsoleInternetBandWidth)
263+
}
264+
265+
if accessAddress.LimiterAddressInfos != nil {
266+
tmpList := make([]map[string]interface{}, 0, len(accessAddress.LimiterAddressInfos))
267+
for _, polarisLimiterAddress := range accessAddress.LimiterAddressInfos {
268+
polarisLimiterAddressMap := map[string]interface{}{}
269+
270+
if polarisLimiterAddress.IntranetAddress != nil {
271+
polarisLimiterAddressMap["intranet_address"] = polarisLimiterAddress.IntranetAddress
272+
}
273+
274+
tmpList = append(tmpList, polarisLimiterAddressMap)
275+
}
276+
277+
_ = d.Set("limiter_address_infos", tmpList)
278+
}
279+
280+
d.SetId(helper.DataResourceIdsHash(ids))
281+
output, ok := d.GetOk("result_output_file")
282+
if ok && output.(string) != "" {
283+
if e := writeToFile(output.(string), d); e != nil {
284+
return e
285+
}
286+
}
287+
return nil
288+
}

0 commit comments

Comments
 (0)