forked from elastic/terraform-provider-elasticstack
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprovider.go
85 lines (79 loc) · 3.13 KB
/
provider.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package provider
import (
"github.com./elastic/terraform-provider-elasticstack/internal/clients"
"github.com./elastic/terraform-provider-elasticstack/internal/elasticsearch/cluster"
"github.com./elastic/terraform-provider-elasticstack/internal/elasticsearch/index"
"github.com./elastic/terraform-provider-elasticstack/internal/elasticsearch/security"
"github.com./hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func init() {
// Set descriptions to support markdown syntax, this will be used in document generation
// and the language server.
schema.DescriptionKind = schema.StringMarkdown
}
func New(version string) func() *schema.Provider {
return func() *schema.Provider {
p := &schema.Provider{
Schema: map[string]*schema.Schema{
"elasticsearch": {
Description: "Default Elasticsearch connection configuration block.",
Type: schema.TypeList,
MaxItems: 1,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"username": {
Description: "Username to use for API authentication to Elasticsearch.",
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("ELASTICSEARCH_USERNAME", nil),
},
"password": {
Description: "Password to use for API authentication to Elasticsearch.",
Type: schema.TypeString,
Optional: true,
Sensitive: true,
DefaultFunc: schema.EnvDefaultFunc("ELASTICSEARCH_PASSWORD", nil),
},
"endpoints": {
Description: "A comma-separated list of endpoints where the terraform provider will point to, this must include the http(s) schema and port number.",
Type: schema.TypeList,
Optional: true,
Sensitive: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"insecure": {
Description: "Disable TLS certificate validation",
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"ca_file": {
Description: "Path to a custom Certificate Authority certificate",
Type: schema.TypeString,
Optional: true,
},
},
},
},
},
DataSourcesMap: map[string]*schema.Resource{
"elasticstack_elasticsearch_security_user": security.DataSourceUser(),
"elasticstack_elasticsearch_snapshot_repository": cluster.DataSourceSnapshotRespository(),
},
ResourcesMap: map[string]*schema.Resource{
"elasticstack_elasticsearch_cluster_settings": cluster.ResourceSettings(),
"elasticstack_elasticsearch_index_lifecycle": index.ResourceIlm(),
"elasticstack_elasticsearch_index_template": index.ResourceTemplate(),
"elasticstack_elasticsearch_security_role": security.ResourceRole(),
"elasticstack_elasticsearch_security_user": security.ResourceUser(),
"elasticstack_elasticsearch_snapshot_lifecycle": cluster.ResourceSlm(),
"elasticstack_elasticsearch_snapshot_repository": cluster.ResourceSnapshotRepository(),
},
}
p.ConfigureContextFunc = clients.NewApiClientFunc(version, p)
return p
}
}