You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Migration to TF Framework.
A breaking schema change. Please see relevant NOTES in CHANGELOG for v0.6.0 and README for more info.
State upgrade is not supported, please use import instead.
---------
Co-authored-by: Pascal Hofmann <[email protected]>
Co-authored-by: Pascal Hofmann <[email protected]>
Co-authored-by: Toby Brain <[email protected]>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+27-1Lines changed: 27 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,37 @@
1
-
# 0.6.0 (Unreleased)
1
+
# 0.7.0 (Unreleased)
2
2
3
3
# 0.5.1 (Feb 15, 2023)
4
4
5
5
FEATURES:
6
6
7
7
* resource/deployment: Utilise the template migration API to build the base update request when changing `deployment_template_id`. This results in more reliable changes between deployment templates. ([#547](https://github.com/elastic/terraform-provider-ec/issues/547))
8
8
9
+
# 0.6.0 (Unreleased)
10
+
11
+
FEATURES:
12
+
13
+
Migration to [TF Plugin Framework](https://developer.hashicorp.com/terraform/plugin/framework)
14
+
15
+
**BREAKING CHANGES**:
16
+
17
+
New schema for `ec_deployment`. Existing resources should be imported. Please see NOTES below and README for more details.
* Older versions of terraform CLI can report errors with the provider 0.6.0 and higher. Please make sure to update Terraform CLI to the latest version.
28
+
* State upgrade is not implemented for `ec_deployment`.
29
+
The recommended way to proceed with existing TF resources is [state import](https://developer.hashicorp.com/terraform/cli/import#state-only).
30
+
However, this doesn't import user passwords and secret tokens.
31
+
* After import, the next plan command can output more elements that the actual configuration defines, e.g. plan command can output `cold` Elasticsearch tier with 0 size or empty `config` block for configuration that doesn't specify `cold` tier and `config` for `elasticsearch`.
32
+
It should not be a problem. You can eigher execute the plan (the only result should be updated Terraform state while the deployment should stay the same) or add empty `cold` tier and `confg` to the configuration.
33
+
* The migration is based on 0.4.1, so all changes from 0.5.0 are omitted.
After doing so, you can navigate to any of our examples in `./examples` and try one.
123
+
124
+
### Moving to TF Framework and schema change for `ec_deployment` resource.
125
+
126
+
v0.6.0 contains migration to [TF Plugin Framework](https://developer.hashicorp.com/terraform/plugin/framework) and intoduces new schema for `ec_deployment` resource:
127
+
128
+
- switching to attributes syntax instead of blocks for almost all definitions that used to be blocks. It means that, for example, a definition like `elasticsearch {...}` has to be changed to `elasticsearch = {...}`, e.g.
129
+
130
+
```hcl
131
+
resource "ec_deployment" "defaults" {
132
+
name = "example"
133
+
region = "us-east-1"
134
+
version = data.ec_stack.latest.version
135
+
deployment_template_id = "aws-io-optimized-v2"
136
+
137
+
elasticsearch = {
138
+
hot = {
139
+
autoscaling = {}
140
+
}
141
+
}
142
+
143
+
kibana = {
144
+
topology = {}
145
+
}
146
+
147
+
enterprise_search = {
148
+
zone_count = 1
149
+
}
150
+
}
151
+
```
152
+
153
+
-`topology` attribute of `elasticsearch` is replaced with a number of dedicated attributes, one per tier, e.g.
154
+
155
+
```
156
+
elasticsearch {
157
+
topology {
158
+
id = "hot_content"
159
+
size = "1g"
160
+
autoscaling {
161
+
max_size = "8g"
162
+
}
163
+
}
164
+
topology {
165
+
id = "warm"
166
+
size = "2g"
167
+
autoscaling {
168
+
max_size = "15g"
169
+
}
170
+
}
171
+
}
172
+
```
173
+
174
+
has to be converted to
175
+
176
+
```
177
+
elasticsearch = {
178
+
hot = {
179
+
size = "1g"
180
+
autoscaling = {
181
+
max_size = "8g"
182
+
}
183
+
}
184
+
185
+
warm = {
186
+
size = "2g"
187
+
autoscaling = {
188
+
max_size = "15g"
189
+
}
190
+
}
191
+
}
192
+
193
+
```
194
+
195
+
- due to some existing limitations of TF, nested attributes that are nested inside other nested attributes cannot be `Computed`. It means that all such attributes have to be mentioned in configurations even if they are empty. E.g., a definition of `elasticsearch` has to include all topology elements (tiers) that have non-zero size or can be scaled up (if autoscaling is enabled) in the corresponding template. For example, the simplest definition of `elasticsearch` for `aws-io-optimized-v2` template is
196
+
197
+
```hcl
198
+
resource "ec_deployment" "defaults" {
199
+
name = "example"
200
+
region = "us-east-1"
201
+
version = data.ec_stack.latest.version
202
+
deployment_template_id = "aws-io-optimized-v2"
203
+
204
+
elasticsearch = {
205
+
hot = {
206
+
autoscaling = {}
207
+
}
208
+
}
209
+
}
210
+
```
211
+
212
+
Please note that the snippet explicitly mentions `hot` tier with `autoscaling` attribute even despite the fact that they are empty.
213
+
214
+
- a lot of attributes that used to be collections (e.g. lists and sets) are converted to sigletons, e.g. `elasticsearch`, `apm`, `kibana`, `enterprise_search`, `observability`, `topology`, `autoscaling`, etc. Please note that, generally, users are not expected to make any change to their existing configuration to address this particular change (besides moving from block to attribute syntax). All these components used to exist in single instances, so the change is mostly syntactical, taking into account the switch to attributes instead of blocks (otherwise if we kept list for configs, `config {}` had to be rewritten in `config = [{}]` with the move to the attribute syntax). However this change is a breaking one from the schema perspective and requires state upgrade for existing resources that is performed by TF (by calling the provider's API).
215
+
216
+
-[`strategy` attribute](https://registry.terraform.io/providers/elastic/ec/latest/docs/resources/ec_deployment#strategy) is converted to string with the same set of values that was used for its `type` attribute previously;
217
+
218
+
- switching to TF protocol 6. From user perspective it should not require any change in their existing configurations.
219
+
220
+
#### Moving to the provider v0.6.0.
221
+
222
+
The schema modifications means that a current TF state cannot work as is with the provider version 0.6.0 and higher.
- state upgrade that is performed by TF by calling the provider's API so no action is required from users
228
+
229
+
Currently the state upgrade functionality is not implemented so importing existing resources is the recommended way to deal with existing TF states.
230
+
Please mind the fact that state import doesn't import user passwords and secret tokens that can be the case if your TF modules make use of them.
231
+
State upgrade doesn't have this limitation.
232
+
233
+
#### Known issues of moving to the provider v0.6.0
234
+
235
+
- Older versions of terraform CLI can report errors with the provider 0.6.0 and higher. Please make sure to update Terraform CLI to the latest version.
236
+
237
+
- Starting from the provider v0.6.0, `terraform plan` output can contain more changes comparing to the older versions of the provider (that use TF SDK v2).
238
+
This happens because TF Framework treats all `computed` attributes as `unknown` (known after apply) once configuration changes.
239
+
However, it doesn't mean that all attributes that marked as `unknown` in the plan will get new values after apply.
240
+
241
+
- After import, the next plan command can output more elements that the actual configuration defines, e.g. plan command can output `cold` Elasticsearch tier with 0 size or empty `config` block for configuration that doesn't specify `cold` tier and `config` for `elasticsearch`.
242
+
It should not be a problem. You can eigher execute the plan (the only result should be updated Terraform state while the deployment should stay the same) or add empty `cold` tier and `confg` to the configuration.
243
+
244
+
- The migration is based on 0.4.1, so all changes from 0.5.0 are omitted.
# The URL domain suffix that is used in this example is often different for other Elasticsearch Service regions. Please check the appropriate domain suffix for your used region.
@@ -71,7 +71,7 @@ You will configure the deployment alias field to be the same, so if the deployme
71
71
Then, by using a variable in the `es.yml` file and a terraform templating mechanism, you can generate your own `es.yml` file. Your variable is named kibana_url, as seen in the ec_deployment resource:
0 commit comments