@@ -113,6 +113,12 @@ func Provider() terraform.ResourceProvider {
113
113
Default : true ,
114
114
Description : "Enable signing of AWS elasticsearch requests" ,
115
115
},
116
+ "elasticsearch_version" : {
117
+ Type : schema .TypeString ,
118
+ Optional : true ,
119
+ Default : "" ,
120
+ Description : "ElasticSearch Version" ,
121
+ },
116
122
},
117
123
118
124
ResourcesMap : map [string ]* schema.Resource {
@@ -154,6 +160,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
154
160
password := d .Get ("password" ).(string )
155
161
parsedUrl , err := url .Parse (rawUrl )
156
162
signAWSRequests := d .Get ("sign_aws_requests" ).(bool )
163
+ esVersion := d .Get ("elasticsearch_version" ).(string )
157
164
if err != nil {
158
165
return nil , err
159
166
}
@@ -187,13 +194,16 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
187
194
}
188
195
relevantClient = client
189
196
190
- // Use the v7 client to ping the cluster to determine the version
191
- info , _ , err := client .Ping (rawUrl ).Do (context .TODO ())
192
- if err != nil {
193
- return nil , err
197
+ // Use the v7 client to ping the cluster to determine the version if one was not provided
198
+ if esVersion == "" {
199
+ info , _ , err := client .Ping (rawUrl ).Do (context .TODO ())
200
+ if err != nil {
201
+ return nil , err
202
+ }
203
+ esVersion = info .Version .Number
194
204
}
195
205
196
- if info . Version . Number < "7.0.0" && info . Version . Number >= "6.0.0" {
206
+ if esVersion < "7.0.0" && esVersion >= "6.0.0" {
197
207
log .Printf ("[INFO] Using ES 6" )
198
208
opts := []elastic6.ClientOptionFunc {
199
209
elastic6 .SetURL (rawUrl ),
@@ -220,7 +230,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
220
230
if err != nil {
221
231
return nil , err
222
232
}
223
- } else if info . Version . Number < "6.0.0" && info . Version . Number >= "5.0.0" {
233
+ } else if esVersion < "6.0.0" && esVersion >= "5.0.0" {
224
234
log .Printf ("[INFO] Using ES 5" )
225
235
opts := []elastic5.ClientOptionFunc {
226
236
elastic5 .SetURL (rawUrl ),
@@ -246,7 +256,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
246
256
if err != nil {
247
257
return nil , err
248
258
}
249
- } else if info . Version . Number < "5.0.0" {
259
+ } else if esVersion < "5.0.0" {
250
260
return nil , errors .New ("ElasticSearch is older than 5.0.0!" )
251
261
}
252
262
0 commit comments