@@ -5,9 +5,9 @@ Example Usage
55
66```hcl
77data "tencentcloud_cynosdb_instances" "foo" {
8- instance_id = "cynosdbmysql-ins-0wln9u6w"
9- project_id = 0
10- db_type = "MYSQL"
8+ instance_id = "cynosdbmysql-ins-0wln9u6w"
9+ project_id = 0
10+ db_type = "MYSQL"
1111 instance_name = "test"
1212}
1313```
@@ -34,6 +34,11 @@ func dataSourceTencentCloudCynosdbInstances() *schema.Resource {
3434 Optional : true ,
3535 Description : "Type of CynosDB, and available values include `MYSQL`, `POSTGRESQL`." ,
3636 },
37+ "cluster_id" : {
38+ Type : schema .TypeString ,
39+ Optional : true ,
40+ Description : "ID of the cluster." ,
41+ },
3742 "instance_id" : {
3843 Type : schema .TypeString ,
3944 Optional : true ,
@@ -128,6 +133,10 @@ func dataSourceTencentCloudCynosdbInstancesRead(d *schema.ResourceData, meta int
128133 if v , ok := d .GetOkExists ("project_id" ); ok {
129134 params ["ProjectId" ] = fmt .Sprintf ("%d" , v .(int ))
130135 }
136+ var clusterId string
137+ if v , ok := d .GetOk ("cluster_id" ); ok {
138+ clusterId = v .(string )
139+ }
131140
132141 cynosdbService := CynosdbService {
133142 client : meta .(* TencentCloudClient ).apiV3Conn ,
@@ -141,6 +150,10 @@ func dataSourceTencentCloudCynosdbInstancesRead(d *schema.ResourceData, meta int
141150 ids := make ([]string , 0 , len (instances ))
142151 instanceList := make ([]map [string ]interface {}, 0 , len (instances ))
143152 for _ , instance := range instances {
153+ if clusterId != "" && * instance .ClusterId != clusterId {
154+ continue
155+ }
156+
144157 mapping := map [string ]interface {}{
145158 "cluster_id" : instance .ClusterId ,
146159 "instance_id" : instance .InstanceId ,
0 commit comments