@@ -174,6 +174,11 @@ func DataSourceTencentCloudElasticsearchInstances() *schema.Resource {
174174 Computed : true ,
175175 Description : "Elasticsearch port." ,
176176 },
177+ "elasticsearch_public_url" : {
178+ Type : schema .TypeString ,
179+ Computed : true ,
180+ Description : "Elasticsearch public url." ,
181+ },
177182 "kibana_url" : {
178183 Type : schema .TypeString ,
179184 Computed : true ,
@@ -194,20 +199,22 @@ func DataSourceTencentCloudElasticsearchInstances() *schema.Resource {
194199func dataSourceTencentCloudElasticsearchInstancesRead (d * schema.ResourceData , meta interface {}) error {
195200 defer tccommon .LogElapsed ("data_source.tencentcloud_elasticsearch_instances.read" )()
196201
197- logId := tccommon .GetLogId (tccommon .ContextNil )
198- ctx := context .WithValue (context .TODO (), tccommon .LogIdKey , logId )
199- elasticsearchService := ElasticsearchService {
200- client : meta .(tccommon.ProviderMeta ).GetAPIV3Conn (),
201- }
202+ var (
203+ logId = tccommon .GetLogId (tccommon .ContextNil )
204+ ctx = context .WithValue (context .TODO (), tccommon .LogIdKey , logId )
205+ elasticsearchService = ElasticsearchService {client : meta .(tccommon.ProviderMeta ).GetAPIV3Conn ()}
206+ instanceId string
207+ instanceName string
208+ )
202209
203- instanceId := ""
204- instanceName := ""
205210 if v , ok := d .GetOk ("instance_id" ); ok {
206211 instanceId = v .(string )
207212 }
213+
208214 if v , ok := d .GetOk ("instance_name" ); ok {
209215 instanceName = v .(string )
210216 }
217+
211218 tags := helper .GetTags (d , "tags" )
212219 var instances []* es.InstanceInfo
213220 var errRet error
@@ -216,8 +223,10 @@ func dataSourceTencentCloudElasticsearchInstancesRead(d *schema.ResourceData, me
216223 if errRet != nil {
217224 return tccommon .RetryError (errRet , tccommon .InternalError )
218225 }
226+
219227 return nil
220228 })
229+
221230 if err != nil {
222231 return nil
223232 }
@@ -248,24 +257,33 @@ func dataSourceTencentCloudElasticsearchInstancesRead(d *schema.ResourceData, me
248257 "kibana_url" : instance .KibanaUrl ,
249258 "create_time" : instance .CreateTime ,
250259 }
260+
261+ if instance .EsPublicUrl != nil {
262+ mapping ["elasticsearch_public_url" ] = instance .EsPublicUrl
263+ }
264+
251265 if instance .MultiZoneInfo != nil && len (instance .MultiZoneInfo ) > 0 {
252266 infos := make ([]map [string ]interface {}, 0 , len (instance .MultiZoneInfo ))
253267 for _ , v := range instance .MultiZoneInfo {
254268 info := map [string ]interface {}{
255269 "availability_zone" : v .Zone ,
256270 "subnet_id" : v .SubnetId ,
257271 }
272+
258273 infos = append (infos , info )
259274 }
275+
260276 mapping ["multi_zone_infos" ] = infos
261277 }
278+
262279 if instance .NodeInfoList != nil && len (instance .NodeInfoList ) > 0 {
263280 infos := make ([]map [string ]interface {}, 0 , len (instance .NodeInfoList ))
264281 for _ , v := range instance .NodeInfoList {
265282 // this will not keep longer as long as cloud api response update
266283 if * v .Type == "kibana" {
267284 continue
268285 }
286+
269287 info := map [string ]interface {}{
270288 "node_num" : v .NodeNum ,
271289 "node_type" : v .NodeType ,
@@ -274,8 +292,10 @@ func dataSourceTencentCloudElasticsearchInstancesRead(d *schema.ResourceData, me
274292 "disk_size" : v .DiskSize ,
275293 "encrypt" : * v .DiskEncrypt > 0 ,
276294 }
295+
277296 infos = append (infos , info )
278297 }
298+
279299 mapping ["node_info_list" ] = infos
280300 }
281301
0 commit comments