Skip to content

Commit f82e250

Browse files
committed
[opendistro] Rename to opensearch.
1 parent cb4371a commit f82e250

11 files changed

+378
-229
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
## Unreleased
33
### Changed
44
- [build] Clarify that a minimum of Go 1.13 is required to build the provider
5+
- [opendistro *] Rename elasticsearch_opendistro_* resources to opensearch_*. Test OpenSearch against 1.x.
56

67
### Added
78
- [provider] Output ES Client logs in JSON format, depending on TF_LOG_PROVIDER

es/data_source_elasticsearch_opendistro_destination.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,23 @@ var datasourceOpenDistroDestinationSchema = map[string]*schema.Schema{
2929
},
3030
}
3131

32-
func dataSourceElasticsearchOpenDistroDestination() *schema.Resource {
32+
func dataSourceOpenSearchDestination() *schema.Resource {
3333
return &schema.Resource{
34-
Description: "`elasticsearch_opendistro_destination` can be used to retrieve the destination object by name.",
34+
Description: "`opensearch_destination` can be used to retrieve the destination object by name.",
3535
Read: dataSourceElasticsearchOpenDistroDestinationRead,
3636
Schema: datasourceOpenDistroDestinationSchema,
3737
}
3838
}
3939

40+
func dataSourceElasticsearchOpenDistroDestination() *schema.Resource {
41+
return &schema.Resource{
42+
Description: "`elasticsearch_opendistro_destination` can be used to retrieve the destination object by name.",
43+
Read: dataSourceElasticsearchOpenDistroDestinationRead,
44+
Schema: datasourceOpenDistroDestinationSchema,
45+
DeprecationMessage: "elasticsearch_opendistro_destination is deprecated, please use opensearch_destination data source instead.",
46+
}
47+
}
48+
4049
func dataSourceElasticsearchOpenDistroDestinationRead(d *schema.ResourceData, m interface{}) error {
4150
destinationName := d.Get("name").(string)
4251

es/provider.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,21 @@ func Provider() *schema.Provider {
218218
"elasticsearch_kibana_object": resourceElasticsearchKibanaObject(),
219219
"elasticsearch_snapshot_repository": resourceElasticsearchSnapshotRepository(),
220220
"elasticsearch_opendistro_destination": resourceElasticsearchOpenDistroDestination(),
221+
"opensearch_destination": resourceOpenSearchDestination(),
221222
"elasticsearch_opendistro_ism_policy": resourceElasticsearchOpenDistroISMPolicy(),
223+
"opensearch_ism_policy": resourceOpenSearchISMPolicy(),
222224
"elasticsearch_opendistro_ism_policy_mapping": resourceElasticsearchOpenDistroISMPolicyMapping(),
225+
"opensearch_ism_policy_mapping": resourceOpenSearchISMPolicyMapping(),
223226
"elasticsearch_opendistro_monitor": resourceElasticsearchOpenDistroMonitor(),
227+
"opensearch_monitor": resourceOpenSearchMonitor(),
224228
"elasticsearch_opendistro_roles_mapping": resourceElasticsearchOpenDistroRolesMapping(),
229+
"opensearch_roles_mapping": resourceOpenSearchRolesMapping(),
225230
"elasticsearch_opendistro_role": resourceElasticsearchOpenDistroRole(),
231+
"opensearch_role": resourceOpenSearchRole(),
226232
"elasticsearch_opendistro_user": resourceElasticsearchOpenDistroUser(),
233+
"opensearch_user": resourceOpenSearchUser(),
227234
"elasticsearch_opendistro_kibana_tenant": resourceElasticsearchOpenDistroKibanaTenant(),
235+
"opensearch_kibana_tenant": resourceOpenSearchKibanaTenant(),
228236
"elasticsearch_xpack_index_lifecycle_policy": resourceElasticsearchXpackIndexLifecyclePolicy(),
229237
"elasticsearch_xpack_license": resourceElasticsearchXpackLicense(),
230238
"elasticsearch_xpack_role": resourceElasticsearchXpackRole(),
@@ -237,6 +245,7 @@ func Provider() *schema.Provider {
237245
DataSourcesMap: map[string]*schema.Resource{
238246
"elasticsearch_host": dataSourceElasticsearchHost(),
239247
"elasticsearch_opendistro_destination": dataSourceElasticsearchOpenDistroDestination(),
248+
"opensearch_destination": dataSourceOpenSearchDestination(),
240249
},
241250

242251
ConfigureContextFunc: providerConfigure,

es/resource_elasticsearch_opendistro_destination.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,20 @@ var openDistroDestinationSchema = map[string]*schema.Schema{
3333
},
3434
}
3535

36+
func resourceOpenSearchDestination() *schema.Resource {
37+
return &schema.Resource{
38+
Description: "Provides an OpenSearch destination, a reusable communication channel for an action, such as email, Slack, or a webhook URL. Please refer to the OpenDistro [destination documentation](https://opendistro.github.io/for-elasticsearch-docs/docs/alerting/monitors/#create-destinations) for details.",
39+
Create: resourceElasticsearchOpenDistroDestinationCreate,
40+
Read: resourceElasticsearchOpenDistroDestinationRead,
41+
Update: resourceElasticsearchOpenDistroDestinationUpdate,
42+
Delete: resourceElasticsearchOpenDistroDestinationDelete,
43+
Schema: openDistroDestinationSchema,
44+
Importer: &schema.ResourceImporter{
45+
StateContext: schema.ImportStatePassthroughContext,
46+
},
47+
}
48+
}
49+
3650
func resourceElasticsearchOpenDistroDestination() *schema.Resource {
3751
return &schema.Resource{
3852
Description: "Provides an Elasticsearch OpenDistro destination, a reusable communication channel for an action, such as email, Slack, or a webhook URL. Please refer to the OpenDistro [destination documentation](https://opendistro.github.io/for-elasticsearch-docs/docs/alerting/monitors/#create-destinations) for details.",
@@ -44,6 +58,7 @@ func resourceElasticsearchOpenDistroDestination() *schema.Resource {
4458
Importer: &schema.ResourceImporter{
4559
StateContext: schema.ImportStatePassthroughContext,
4660
},
61+
DeprecationMessage: "elasticsearch_opendistro_destination is deprecated, please use opensearch_destination resource instead.",
4762
}
4863
}
4964

es/resource_elasticsearch_opendistro_ism_policy.go

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,41 +19,57 @@ import (
1919
elastic6 "gopkg.in/olivere/elastic.v6"
2020
)
2121

22-
func resourceElasticsearchOpenDistroISMPolicy() *schema.Resource {
22+
var openDistroISMPolicySchema = map[string]*schema.Schema{
23+
"policy_id": {
24+
Type: schema.TypeString,
25+
Required: true,
26+
ForceNew: true,
27+
},
28+
"body": {
29+
Type: schema.TypeString,
30+
Required: true,
31+
DiffSuppressFunc: diffSuppressPolicy,
32+
StateFunc: func(v interface{}) string {
33+
json, _ := structure.NormalizeJsonString(v)
34+
return json
35+
},
36+
},
37+
"primary_term": {
38+
Type: schema.TypeInt,
39+
Optional: true,
40+
Computed: true,
41+
},
42+
"seq_no": {
43+
Type: schema.TypeInt,
44+
Optional: true,
45+
Computed: true,
46+
},
47+
}
48+
49+
func resourceOpenSearchISMPolicy() *schema.Resource {
2350
return &schema.Resource{
2451
Create: resourceElasticsearchOpenDistroISMPolicyCreate,
2552
Read: resourceElasticsearchOpenDistroISMPolicyRead,
2653
Update: resourceElasticsearchOpenDistroISMPolicyUpdate,
2754
Delete: resourceElasticsearchOpenDistroISMPolicyDelete,
28-
Schema: map[string]*schema.Schema{
29-
"policy_id": {
30-
Type: schema.TypeString,
31-
Required: true,
32-
ForceNew: true,
33-
},
34-
"body": {
35-
Type: schema.TypeString,
36-
Required: true,
37-
DiffSuppressFunc: diffSuppressPolicy,
38-
StateFunc: func(v interface{}) string {
39-
json, _ := structure.NormalizeJsonString(v)
40-
return json
41-
},
42-
},
43-
"primary_term": {
44-
Type: schema.TypeInt,
45-
Optional: true,
46-
Computed: true,
47-
},
48-
"seq_no": {
49-
Type: schema.TypeInt,
50-
Optional: true,
51-
Computed: true,
52-
},
55+
Schema: openDistroISMPolicySchema,
56+
Importer: &schema.ResourceImporter{
57+
StateContext: schema.ImportStatePassthroughContext,
5358
},
59+
}
60+
}
61+
62+
func resourceElasticsearchOpenDistroISMPolicy() *schema.Resource {
63+
return &schema.Resource{
64+
Create: resourceElasticsearchOpenDistroISMPolicyCreate,
65+
Read: resourceElasticsearchOpenDistroISMPolicyRead,
66+
Update: resourceElasticsearchOpenDistroISMPolicyUpdate,
67+
Delete: resourceElasticsearchOpenDistroISMPolicyDelete,
68+
Schema: openDistroISMPolicySchema,
5469
Importer: &schema.ResourceImporter{
5570
StateContext: schema.ImportStatePassthroughContext,
5671
},
72+
DeprecationMessage: "elasticsearch_opendistro_ism_policy is deprecated, please use opensearch_ism_policy resource instead.",
5773
}
5874
}
5975

es/resource_elasticsearch_opendistro_ism_policy_mapping.go

Lines changed: 57 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,49 +15,70 @@ import (
1515
elastic7 "github.com/olivere/elastic/v7"
1616
)
1717

18-
func resourceElasticsearchOpenDistroISMPolicyMapping() *schema.Resource {
18+
var openDistroISMPolicyMappingSchema = map[string]*schema.Schema{
19+
"policy_id": {
20+
Type: schema.TypeString,
21+
Required: true,
22+
Description: "The name of the policy.",
23+
},
24+
"indexes": {
25+
Type: schema.TypeString,
26+
Required: true,
27+
Description: "Name of the index to apply the policy to. You can use an index pattern to update multiple indices at once.",
28+
},
29+
"state": {
30+
Type: schema.TypeString,
31+
Optional: true,
32+
Default: "",
33+
Description: "After a change in policy takes place, specify the state for the index to transition to",
34+
},
35+
"include": {
36+
Type: schema.TypeSet,
37+
Optional: true,
38+
Elem: &schema.Schema{Type: schema.TypeMap},
39+
Description: "When updating multiple indices, you might want to include a state filter to only affect certain managed indices. The background process only applies the change if the index is currently in the state specified.",
40+
},
41+
"is_safe": {
42+
Type: schema.TypeBool,
43+
Optional: true,
44+
Default: false,
45+
Description: "",
46+
},
47+
"managed_indexes": {
48+
Type: schema.TypeSet,
49+
Optional: true,
50+
Computed: true,
51+
Elem: &schema.Schema{Type: schema.TypeString},
52+
},
53+
}
54+
55+
func resourceOpenSearchISMPolicyMapping() *schema.Resource {
1956
return &schema.Resource{
2057
Description: "Provides an Elasticsearch Open Distro Index State Management (ISM) policy. Please refer to the Open Distro [ISM documentation](https://opendistro.github.io/for-elasticsearch-docs/docs/ism/) for details.",
2158
Create: resourceElasticsearchOpenDistroISMPolicyMappingCreate,
2259
Read: resourceElasticsearchOpenDistroISMPolicyMappingRead,
2360
Update: resourceElasticsearchOpenDistroISMPolicyMappingUpdate,
2461
Delete: resourceElasticsearchOpenDistroISMPolicyMappingDelete,
25-
Schema: map[string]*schema.Schema{
26-
"policy_id": {
27-
Type: schema.TypeString,
28-
Required: true,
29-
Description: "The name of the policy.",
30-
},
31-
"indexes": {
32-
Type: schema.TypeString,
33-
Required: true,
34-
Description: "Name of the index to apply the policy to. You can use an index pattern to update multiple indices at once.",
35-
},
36-
"state": {
37-
Type: schema.TypeString,
38-
Optional: true,
39-
Default: "",
40-
Description: "After a change in policy takes place, specify the state for the index to transition to",
41-
},
42-
"include": {
43-
Type: schema.TypeSet,
44-
Optional: true,
45-
Elem: &schema.Schema{Type: schema.TypeMap},
46-
Description: "When updating multiple indices, you might want to include a state filter to only affect certain managed indices. The background process only applies the change if the index is currently in the state specified.",
47-
},
48-
"is_safe": {
49-
Type: schema.TypeBool,
50-
Optional: true,
51-
Default: false,
52-
Description: "",
53-
},
54-
"managed_indexes": {
55-
Type: schema.TypeSet,
56-
Optional: true,
57-
Computed: true,
58-
Elem: &schema.Schema{Type: schema.TypeString},
59-
},
62+
Schema: openDistroISMPolicyMappingSchema,
63+
Importer: &schema.ResourceImporter{
64+
StateContext: schema.ImportStatePassthroughContext,
6065
},
66+
Timeouts: &schema.ResourceTimeout{
67+
Create: schema.DefaultTimeout(5 * time.Minute),
68+
Update: schema.DefaultTimeout(5 * time.Minute),
69+
},
70+
DeprecationMessage: "opensearch_ism_policy_mapping is deprecated in Opensearch 1.x please use ism_template attribute in policies instead.",
71+
}
72+
}
73+
74+
func resourceElasticsearchOpenDistroISMPolicyMapping() *schema.Resource {
75+
return &schema.Resource{
76+
Description: "Provides an Elasticsearch Open Distro Index State Management (ISM) policy. Please refer to the Open Distro [ISM documentation](https://opendistro.github.io/for-elasticsearch-docs/docs/ism/) for details.",
77+
Create: resourceElasticsearchOpenDistroISMPolicyMappingCreate,
78+
Read: resourceElasticsearchOpenDistroISMPolicyMappingRead,
79+
Update: resourceElasticsearchOpenDistroISMPolicyMappingUpdate,
80+
Delete: resourceElasticsearchOpenDistroISMPolicyMappingDelete,
81+
Schema: openDistroISMPolicyMappingSchema,
6182
Importer: &schema.ResourceImporter{
6283
StateContext: schema.ImportStatePassthroughContext,
6384
},

es/resource_elasticsearch_opendistro_kibana_tenant.go

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,46 @@ import (
1717
elastic7 "github.com/olivere/elastic/v7"
1818
)
1919

20-
func resourceElasticsearchOpenDistroKibanaTenant() *schema.Resource {
20+
var openDistroKibanaTenantSchema = map[string]*schema.Schema{
21+
"tenant_name": {
22+
Type: schema.TypeString,
23+
Required: true,
24+
ForceNew: true,
25+
},
26+
"description": {
27+
Type: schema.TypeString,
28+
Optional: true,
29+
},
30+
"index": {
31+
Type: schema.TypeString,
32+
Computed: true,
33+
},
34+
}
35+
36+
func resourceOpenSearchKibanaTenant() *schema.Resource {
2137
return &schema.Resource{
2238
Create: resourceElasticsearchOpenDistroKibanaTenantCreate,
2339
Read: resourceElasticsearchOpenDistroKibanaTenantRead,
2440
Update: resourceElasticsearchOpenDistroKibanaTenantUpdate,
2541
Delete: resourceElasticsearchOpenDistroKibanaTenantDelete,
26-
Schema: map[string]*schema.Schema{
27-
"tenant_name": {
28-
Type: schema.TypeString,
29-
Required: true,
30-
ForceNew: true,
31-
},
32-
"description": {
33-
Type: schema.TypeString,
34-
Optional: true,
35-
},
36-
"index": {
37-
Type: schema.TypeString,
38-
Computed: true,
39-
},
42+
Schema: openDistroKibanaTenantSchema,
43+
Importer: &schema.ResourceImporter{
44+
StateContext: schema.ImportStatePassthroughContext,
4045
},
46+
}
47+
}
48+
49+
func resourceElasticsearchOpenDistroKibanaTenant() *schema.Resource {
50+
return &schema.Resource{
51+
Create: resourceElasticsearchOpenDistroKibanaTenantCreate,
52+
Read: resourceElasticsearchOpenDistroKibanaTenantRead,
53+
Update: resourceElasticsearchOpenDistroKibanaTenantUpdate,
54+
Delete: resourceElasticsearchOpenDistroKibanaTenantDelete,
55+
Schema: openDistroKibanaTenantSchema,
4156
Importer: &schema.ResourceImporter{
4257
StateContext: schema.ImportStatePassthroughContext,
4358
},
59+
DeprecationMessage: "elasticsearch_opendistro_kibana_tentant is deprecated, please use opensearch_kibana_tenant resource instead.",
4460
}
4561
}
4662

es/resource_elasticsearch_opendistro_monitor.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@ var openDistroMonitorSchema = map[string]*schema.Schema{
2929
},
3030
}
3131

32+
func resourceOpenSearchMonitor() *schema.Resource {
33+
return &schema.Resource{
34+
Create: resourceElasticsearchOpenDistroMonitorCreate,
35+
Read: resourceElasticsearchOpenDistroMonitorRead,
36+
Update: resourceElasticsearchOpenDistroMonitorUpdate,
37+
Delete: resourceElasticsearchOpenDistroMonitorDelete,
38+
Schema: openDistroMonitorSchema,
39+
Importer: &schema.ResourceImporter{
40+
StateContext: schema.ImportStatePassthroughContext,
41+
},
42+
}
43+
}
44+
3245
func resourceElasticsearchOpenDistroMonitor() *schema.Resource {
3346
return &schema.Resource{
3447
Create: resourceElasticsearchOpenDistroMonitorCreate,
@@ -39,6 +52,7 @@ func resourceElasticsearchOpenDistroMonitor() *schema.Resource {
3952
Importer: &schema.ResourceImporter{
4053
StateContext: schema.ImportStatePassthroughContext,
4154
},
55+
DeprecationMessage: "elasticsearch_opendistro_monitor is deprecated, please use opensearch_monitor resource instead.",
4256
}
4357
}
4458

0 commit comments

Comments
 (0)