@@ -34,12 +34,12 @@ func dataSourceTencentCloudNatGateways() *schema.Resource {
34
34
"name" : {
35
35
Type : schema .TypeString ,
36
36
Optional : true ,
37
- Description : "Name of the nat gateway." ,
37
+ Description : "Name of the NAT gateway." ,
38
38
},
39
39
"id" : {
40
40
Type : schema .TypeString ,
41
41
Optional : true ,
42
- Description : "ID of the nat gateway." ,
42
+ Description : "ID of the NAT gateway." ,
43
43
},
44
44
"result_output_file" : {
45
45
Type : schema .TypeString ,
@@ -51,13 +51,13 @@ func dataSourceTencentCloudNatGateways() *schema.Resource {
51
51
"nats" : {
52
52
Type : schema .TypeList ,
53
53
Computed : true ,
54
- Description : "Information list of the dedicated tunnels ." ,
54
+ Description : "Information list of the dedicated nats ." ,
55
55
Elem : & schema.Resource {
56
56
Schema : map [string ]* schema.Schema {
57
57
"id" : {
58
58
Type : schema .TypeString ,
59
59
Computed : true ,
60
- Description : "ID of the nat gateway." ,
60
+ Description : "ID of the NAT gateway." ,
61
61
},
62
62
"vpc_id" : {
63
63
Type : schema .TypeString ,
@@ -67,22 +67,22 @@ func dataSourceTencentCloudNatGateways() *schema.Resource {
67
67
"name" : {
68
68
Type : schema .TypeString ,
69
69
Computed : true ,
70
- Description : "Name of the nat gateway." ,
70
+ Description : "Name of the NAT gateway." ,
71
71
},
72
72
"state" : {
73
73
Type : schema .TypeInt ,
74
74
Computed : true ,
75
- Description : "State of the nat gateway." ,
75
+ Description : "State of the NAT gateway." ,
76
76
},
77
77
"max_concurrent" : {
78
78
Type : schema .TypeInt ,
79
79
Computed : true ,
80
- Description : "The upper limit of concurrent connection of nat gateway, the available values include: 1000000,3000000,10000000. Default is 1000000." ,
80
+ Description : "The upper limit of concurrent connection of NAT gateway, the available values include: 1000000,3000000,10000000. Default is 1000000." ,
81
81
},
82
82
"bandwidth" : {
83
83
Type : schema .TypeInt ,
84
84
Computed : true ,
85
- Description : "The maximum public network output bandwidth of nat gateway (unit: Mbps), the available values include: 20,50,100,200,500,1000,2000,5000. Default is 100." ,
85
+ Description : "The maximum public network output bandwidth of NAT gateway (unit: Mbps), the available values include: 20,50,100,200,500,1000,2000,5000. Default is 100." ,
86
86
},
87
87
"assigned_eip_set" : {
88
88
Type : schema .TypeList ,
@@ -93,7 +93,7 @@ func dataSourceTencentCloudNatGateways() *schema.Resource {
93
93
"create_time" : {
94
94
Type : schema .TypeString ,
95
95
Computed : true ,
96
- Description : "Create time of the nat gateway." ,
96
+ Description : "Create time of the NAT gateway." ,
97
97
},
98
98
},
99
99
},
@@ -126,24 +126,38 @@ func dataSourceTencentCloudNatGatewaysRead(d *schema.ResourceData, meta interfac
126
126
}
127
127
request .Filters = append (request .Filters , filter )
128
128
}
129
- var response * vpc.DescribeNatGatewaysResponse
130
- err := resource .Retry (readRetryTimeout , func () * resource.RetryError {
131
- result , e := meta .(* TencentCloudClient ).apiV3Conn .UseVpcClient ().DescribeNatGateways (request )
132
- if e != nil {
133
- log .Printf ("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n " ,
134
- logId , request .GetAction (), request .ToJsonString (), e .Error ())
135
- return retryError (e )
129
+ offset := uint64 (0 )
130
+ request .Offset = & offset
131
+ result := make ([]* vpc.NatGateway , 0 )
132
+ limit := uint64 (NAT_DESCRIBE_LIMIT )
133
+ for {
134
+ var response * vpc.DescribeNatGatewaysResponse
135
+ err := resource .Retry (readRetryTimeout , func () * resource.RetryError {
136
+ result , e := meta .(* TencentCloudClient ).apiV3Conn .UseVpcClient ().DescribeNatGateways (request )
137
+ if e != nil {
138
+ log .Printf ("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n " ,
139
+ logId , request .GetAction (), request .ToJsonString (), e .Error ())
140
+ return retryError (e )
141
+ }
142
+ response = result
143
+ return nil
144
+ })
145
+ if err != nil {
146
+ log .Printf ("[CRITAL]%s read NAT gateway failed, reason:%s\n " , logId , err .Error ())
147
+ return err
148
+ } else {
149
+ result = append (result , response .Response .NatGatewaySet ... )
150
+ if len (response .Response .NatGatewaySet ) < NAT_DESCRIBE_LIMIT {
151
+ break
152
+ } else {
153
+ offset = offset + limit
154
+ request .Offset = & offset
155
+ }
136
156
}
137
- response = result
138
- return nil
139
- })
140
- if err != nil {
141
- log .Printf ("[CRITAL]%s read nat gateway failed, reason:%s\n " , logId , err .Error ())
142
- return err
143
157
}
144
- ids := make ([]string , 0 , len (response . Response . NatGatewaySet ))
145
- natList := make ([]map [string ]interface {}, 0 , len (response . Response . NatGatewaySet ))
146
- for _ , nat := range response . Response . NatGatewaySet {
158
+ ids := make ([]string , 0 , len (result ))
159
+ natList := make ([]map [string ]interface {}, 0 , len (result ))
160
+ for _ , nat := range result {
147
161
mapping := map [string ]interface {}{
148
162
"id" : * nat .NatGatewayId ,
149
163
"vpc_id" : * nat .VpcId ,
@@ -159,7 +173,7 @@ func dataSourceTencentCloudNatGatewaysRead(d *schema.ResourceData, meta interfac
159
173
}
160
174
d .SetId (dataResourceIdsHash (ids ))
161
175
if e := d .Set ("nats" , natList ); e != nil {
162
- log .Printf ("[CRITAL]%s provider set clb list fail, reason:%s\n " , logId , e .Error ())
176
+ log .Printf ("[CRITAL]%s provider set NAT list fail, reason:%s\n " , logId , e .Error ())
163
177
return e
164
178
}
165
179
0 commit comments