Skip to content

Commit 1164c14

Browse files
authored
add insecure flag to provider (#10)
1 parent a2a63dc commit 1164c14

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

provider/provider.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package provider
22

33
import (
4+
"crypto/tls"
45
"fmt"
56
"net/http"
67

@@ -24,6 +25,12 @@ func Provider() *schema.Provider {
2425
DefaultFunc: schema.EnvDefaultFunc("ELASTICSEARCH_API_KEY", nil),
2526
Description: "The token for API authentication.",
2627
},
28+
"insecure": {
29+
Type: schema.TypeBool,
30+
Optional: true,
31+
Default: false,
32+
Description: "Skip server certificate verification",
33+
},
2734
},
2835
ResourcesMap: map[string]*schema.Resource{
2936
"elkaliases_index": resourceelkAliasesIndex(),
@@ -35,11 +42,15 @@ func Provider() *schema.Provider {
3542
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
3643
url := d.Get("url").(string)
3744
token := d.Get("token").(string)
45+
insecure := d.Get("insecure").(bool)
3846

3947
cfg := elasticsearch.Config{
4048
Addresses: []string{url},
4149
Transport: &http.Transport{
4250
Proxy: http.ProxyFromEnvironment,
51+
TLSClientConfig: &tls.Config{
52+
InsecureSkipVerify: insecure,
53+
},
4354
},
4455
Header: http.Header{
4556
"Authorization": []string{fmt.Sprintf("ApiKey %s", token)},

website/docs/index.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ The following arguments are supported:
3535

3636
* `url` - (Required) Url to the ElasticSsearch API
3737
* `token` - (Required) Authentication token to the ElasticSearch API
38+
* `insecure` - (Optional) Skip server certification verification

0 commit comments

Comments
 (0)