@@ -52,6 +52,25 @@ func ResourceTencentCloudPostgresqlReadonlyGroup() *schema.Resource {
52
52
Required : true ,
53
53
Description : "VPC subnet ID." ,
54
54
},
55
+ "net_infos" : {
56
+ Type : schema .TypeList ,
57
+ Computed : true ,
58
+ Description : "List of db instance net info." ,
59
+ Elem : & schema.Resource {
60
+ Schema : map [string ]* schema.Schema {
61
+ "ip" : {
62
+ Type : schema .TypeString ,
63
+ Computed : true ,
64
+ Description : "Ip address of the net info." ,
65
+ },
66
+ "port" : {
67
+ Type : schema .TypeString ,
68
+ Computed : true ,
69
+ Description : "Port of the net info." ,
70
+ },
71
+ },
72
+ },
73
+ },
55
74
"replay_lag_eliminate" : {
56
75
Type : schema .TypeInt ,
57
76
Required : true ,
@@ -191,8 +210,7 @@ func resourceTencentCloudPostgresqlReadOnlyGroupCreate(d *schema.ResourceData, m
191
210
return err
192
211
}
193
212
194
- //return resourceTencentCloudPostgresqlReadOnlyGroupRead(d, meta)
195
- return nil
213
+ return resourceTencentCloudPostgresqlReadOnlyGroupRead (d , meta )
196
214
}
197
215
198
216
func resourceTencentCloudPostgresqlReadOnlyGroupRead (d * schema.ResourceData , meta interface {}) error {
@@ -202,17 +220,34 @@ func resourceTencentCloudPostgresqlReadOnlyGroupRead(d *schema.ResourceData, met
202
220
ctx := context .WithValue (context .TODO (), tccommon .LogIdKey , logId )
203
221
204
222
// for now, the id should be the master db instance id, cause the describe api only support this kind of filter.
205
- var id string
223
+ var masterInsId string
206
224
if v , ok := d .GetOk ("master_db_instance_id" ); ok {
207
- id = v .(string )
225
+ masterInsId = v .(string )
208
226
}
227
+ roGroupId := d .Id ()
209
228
210
229
postgresqlService := PostgresqlService {client : meta .(tccommon.ProviderMeta ).GetAPIV3Conn ()}
211
- _ , err := postgresqlService .DescribePostgresqlReadOnlyGroupById (ctx , id )
230
+ netInfos , err := postgresqlService .DescribePostgresqlReadonlyGroupNetInfosById (ctx , masterInsId , roGroupId )
212
231
if err != nil {
213
232
return err
214
233
}
215
234
235
+ if netInfos != nil {
236
+ netInfoList := []interface {}{}
237
+ for _ , netInfo := range netInfos {
238
+ netInfoMap := map [string ]interface {}{}
239
+
240
+ if netInfo .Ip != nil {
241
+ netInfoMap ["ip" ] = netInfo .Ip
242
+ }
243
+ if netInfo .Port != nil {
244
+ netInfoMap ["port" ] = netInfo .Port
245
+ }
246
+ netInfoList = append (netInfoList , netInfoMap )
247
+ }
248
+ _ = d .Set ("net_infos" , netInfoList )
249
+ }
250
+
216
251
return nil
217
252
}
218
253
@@ -362,7 +397,7 @@ func resourceTencentCloudPostgresqlReadOnlyGroupUpdate(d *schema.ResourceData, m
362
397
if err != nil {
363
398
return err
364
399
}
365
- return nil
400
+ return resourceTencentCloudPostgresqlReadOnlyGroupRead ( d , meta )
366
401
}
367
402
368
403
func resourceTencentCLoudPostgresqlReadOnlyGroupDelete (d * schema.ResourceData , meta interface {}) error {
0 commit comments