/
schema.go
178 lines (175 loc) · 7.57 KB
/
schema.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package v2
import (
"github.com/elastic/terraform-provider-ec/ec/internal/planmodifiers"
"github.com/hashicorp/terraform-plugin-framework-validators/objectvalidator"
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/objectplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
)
func IntegrationsServerSchema() schema.Attribute {
return schema.SingleNestedAttribute{
Description: "Integrations Server cluster definition. Integrations Server replaces `apm` in Stack versions > 8.0",
Optional: true,
Validators: []validator.Object{
objectvalidator.AlsoRequires(path.MatchRoot("kibana")),
},
Attributes: map[string]schema.Attribute{
"elasticsearch_cluster_ref_id": schema.StringAttribute{
Optional: true,
Computed: true,
PlanModifiers: []planmodifier.String{
planmodifiers.StringDefaultValue("main-elasticsearch"),
},
},
"ref_id": schema.StringAttribute{
Optional: true,
Computed: true,
PlanModifiers: []planmodifier.String{
planmodifiers.StringDefaultValue("main-integrations_server"),
},
},
"resource_id": schema.StringAttribute{
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},
"region": schema.StringAttribute{
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},
"http_endpoint": schema.StringAttribute{
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},
"https_endpoint": schema.StringAttribute{
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},
"endpoints": schema.ObjectAttribute{
Optional: true,
Computed: true,
Description: "URLs for the accessing the Fleet and APM API's within this Integrations Server resource.",
AttributeTypes: map[string]attr.Type{
"apm": types.StringType,
"fleet": types.StringType,
"symbols": types.StringType,
"profiling": types.StringType,
},
PlanModifiers: []planmodifier.Object{
objectplanmodifier.UseStateForUnknown(),
},
},
"instance_configuration_id": schema.StringAttribute{
Optional: true,
Computed: true,
PlanModifiers: []planmodifier.String{
planmodifiers.UseStateForUnknownUnlessMigrationIsRequired("integrations_server", false),
},
},
"latest_instance_configuration_id": schema.StringAttribute{
Computed: true,
PlanModifiers: []planmodifier.String{
planmodifiers.UseStateForUnknownUnlessMigrationIsRequired("integrations_server", false),
},
},
"instance_configuration_version": schema.Int64Attribute{
Computed: true,
Optional: true,
PlanModifiers: []planmodifier.Int64{
planmodifiers.UseStateForUnknownUnlessMigrationIsRequired("integrations_server", true),
},
},
"latest_instance_configuration_version": schema.Int64Attribute{
Computed: true,
PlanModifiers: []planmodifier.Int64{
planmodifiers.UseStateForUnknownUnlessMigrationIsRequired("integrations_server", true),
},
},
"size": schema.StringAttribute{
Computed: true,
Optional: true,
PlanModifiers: []planmodifier.String{
planmodifiers.UseStateForUnknownUnlessMigrationIsRequired("integrations_server", false),
},
},
"size_resource": schema.StringAttribute{
Description: `Optional size type, defaults to "memory".`,
Optional: true,
Computed: true,
PlanModifiers: []planmodifier.String{
planmodifiers.StringDefaultValue("memory"),
},
},
"zone_count": schema.Int64Attribute{
Computed: true,
Optional: true,
PlanModifiers: []planmodifier.Int64{
int64planmodifier.UseStateForUnknown(),
},
},
"config": schema.SingleNestedAttribute{
Description: `Optionally define the Integrations Server configuration options for the IntegrationsServer Server`,
Optional: true,
Attributes: map[string]schema.Attribute{
"docker_image": schema.StringAttribute{
Description: "Optionally override the docker image the Integrations Server nodes will use. Note that this field will only work for internal users only.",
Optional: true,
},
"debug_enabled": schema.BoolAttribute{
Description: `Optionally enable debug mode for Integrations Server instances - defaults to false`,
Optional: true,
Computed: true,
PlanModifiers: []planmodifier.Bool{
planmodifiers.BoolDefaultValue(false),
},
},
"user_settings_json": schema.StringAttribute{
Description: `An arbitrary JSON object allowing (non-admin) cluster owners to set their parameters (only one of this and 'user_settings_yaml' is allowed), provided they are on the whitelist ('user_settings_whitelist') and not on the blacklist ('user_settings_blacklist'). (This field together with 'user_settings_override*' and 'system_settings' defines the total set of resource settings)`,
Optional: true,
},
"user_settings_override_json": schema.StringAttribute{
Description: `An arbitrary JSON object allowing ECE admins owners to set clusters' parameters (only one of this and 'user_settings_override_yaml' is allowed), ie in addition to the documented 'system_settings'. (This field together with 'system_settings' and 'user_settings*' defines the total set of resource settings)`,
Optional: true,
},
"user_settings_yaml": schema.StringAttribute{
Description: `An arbitrary YAML object allowing (non-admin) cluster owners to set their parameters (only one of this and 'user_settings_json' is allowed), provided they are on the whitelist ('user_settings_whitelist') and not on the blacklist ('user_settings_blacklist'). (These field together with 'user_settings_override*' and 'system_settings' defines the total set of resource settings)`,
Optional: true,
},
"user_settings_override_yaml": schema.StringAttribute{
Description: `An arbitrary YAML object allowing ECE admins owners to set clusters' parameters (only one of this and 'user_settings_override_json' is allowed), ie in addition to the documented 'system_settings'. (This field together with 'system_settings' and 'user_settings*' defines the total set of resource settings)`,
Optional: true,
},
},
},
},
}
}