Skip to content

Commit 21dd383

Browse files
authored
Use state for unknown for computed attributes which won't change during plan application (#677)
* Use state for unknown for computed attributes which won't change during plan application These values may potentially change throughout a deployment lifecycle, but those changes will be picked up during the refresh phase, updating state prior to computing the plan These values, when unset, should be 'known' as they are provided in the API response * Config with empty plugins is empty * CloudID is unknown if name changes or if kibana is being enabled/disabled * Remove 1.3.9 control from CI acceptance tests * Set APM secret token to null if there is no apm/integrations_server resource * Traffic filter WIP * Use private state to track traffic filters previously managed by the deployment resource * Acceptance tests * Regenerate docs * TF 1.4 in unit tests * Acceptance tests * Fix tests * Lint * Code cleanup * Fix build * Fix build * Fix build * Changelog * Changelog
1 parent 118431e commit 21dd383

31 files changed

+996
-134
lines changed

.changelog/640.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
```release-note:feature
2-
resource/deployment: Adds endpoints integrations server resources. This allows consumers to explicitly capture service urls for dependent modules (e.g APM and Fleet).```
2+
resource/deployment: Adds endpoints integrations server resources. This allows consumers to explicitly capture service urls for dependent modules (e.g APM and Fleet).
3+
```

.changelog/642.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:feature
2+
resource/deployment: Add `reset_elasticsearch_password` attribute to the deployment resource. When true, this will reset the system password for the target deployment, updating the `elasticsearch_password` output as a result.
3+
```

.changelog/648.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug-fix
2+
resource/deployment: Fix validation and application of elasticsearch plan strategy
3+
```

.changelog/677.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug-fix
2+
provider: Fix incompatibilities causing infinite configuration drift when used with Terraform CLI 1.4 or higher
3+
```

.changelog/682.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug-fix
2+
resource/deployment: Fix bugs related to transitioning to/from deployment topologies which include dedicated master nodes
3+
```

build/Makefile.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ _report_path:
2020
.PHONY: unit
2121
unit: _report_path
2222
@ echo "-> Running unit tests for $(BINARY)..."
23-
@ TF_ACC_TERRAFORM_VERSION=1.3.9 go test $(TEST) $(TESTARGS) $(TESTUNITARGS)
23+
@ go test $(TEST) $(TESTARGS) $(TESTUNITARGS)
2424

2525
## Alias to "unit".
2626
tests: unit
@@ -42,7 +42,7 @@ endif
4242

4343
.PHONY: testacc-ci
4444
testacc-ci:
45-
@ TF_ACC_TERRAFORM_VERSION=1.3.9 EC_API_KEY=$(shell cat .ci/.apikey) $(MAKE) testacc
45+
@ EC_API_KEY=$(shell cat .ci/.apikey) $(MAKE) testacc
4646

4747
.PHONY: sweep-ci
4848
sweep-ci:

docs/resources/deployment.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ resource "ec_deployment" "ccs" {
268268
- `request_id` (String) Request ID to set when you create the deployment. Use it only when previous attempts return an error and `request_id` is returned as part of the error.
269269
- `reset_elasticsearch_password` (Boolean) Explicitly resets the elasticsearch_password when true
270270
- `tags` (Map of String) Optional map of deployment tags
271-
- `traffic_filter` (Set of String) List of traffic filters rule identifiers that will be applied to the deployment. Removing this attribute entirely *will not* remove managed traffic filters, instead first set it to an empty list (e.g `traffic_filter = []`) to remove the managed traffic filters.
271+
- `traffic_filter` (Set of String) List of traffic filters rule identifiers that will be applied to the deployment.
272272

273273
### Read-Only
274274

@@ -765,6 +765,7 @@ Optional:
765765

766766
- `config` (Attributes) Optionally define the Integrations Server configuration options for the IntegrationsServer Server (see [below for nested schema](#nestedatt--integrations_server--config))
767767
- `elasticsearch_cluster_ref_id` (String)
768+
- `endpoints` (Object) URLs for the accessing the Fleet and APM API's within this Integrations Server resource. (see [below for nested schema](#nestedatt--integrations_server--endpoints))
768769
- `instance_configuration_id` (String)
769770
- `ref_id` (String)
770771
- `size` (String)
@@ -773,7 +774,6 @@ Optional:
773774

774775
Read-Only:
775776

776-
- `endpoints` (Attributes) URLs for the accessing the Fleet and APM API's within this Integrations Server resource. (see [below for nested schema](#nestedatt--integrations_server--endpoints))
777777
- `http_endpoint` (String)
778778
- `https_endpoint` (String)
779779
- `region` (String)
@@ -795,10 +795,10 @@ Optional:
795795
<a id="nestedatt--integrations_server--endpoints"></a>
796796
### Nested Schema for `integrations_server.endpoints`
797797

798-
Read-Only:
798+
Optional:
799799

800-
- `apm` (String) URL to access the APM server instance for this Integrations Server resource
801-
- `fleet` (String) URL to access the Fleet server instance for this Integrations Server resource
800+
- `apm` (String)
801+
- `fleet` (String)
802802

803803

804804

ec/acc/deployment_basic_test.go

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,10 @@ func TestAccDeployment_basic_tf(t *testing.T) {
3535
randomAlias := "alias" + acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)
3636
trafficFilterCfg := "testdata/deployment_basic_with_traffic_filter_2.tf"
3737
trafficFilterUpdateCfg := "testdata/deployment_basic_with_traffic_filter_3.tf"
38-
emptyTrafficFilterCfg := "testdata/deployment_basic_with_empty_traffic_filter.tf"
3938
resetPasswordCfg := "testdata/deployment_basic_reset_password.tf"
4039
cfg := fixtureAccDeploymentResourceBasicWithAppsAlias(t, startCfg, randomAlias, randomName, getRegion(), defaultTemplate)
4140
cfgWithTrafficFilter := fixtureAccDeploymentResourceBasicWithTF(t, trafficFilterCfg, randomName, getRegion(), defaultTemplate)
4241
cfgWithTrafficFilterUpdate := fixtureAccDeploymentResourceBasicWithTF(t, trafficFilterUpdateCfg, randomName, getRegion(), defaultTemplate)
43-
cfgWithEmptyTrafficFilter := fixtureAccDeploymentResourceBasicWithAppsAlias(t, emptyTrafficFilterCfg, randomAlias, randomName, getRegion(), defaultTemplate)
4442
cfgResetPassword := fixtureAccDeploymentResourceBasicWithAppsAlias(t, resetPasswordCfg, randomAlias, randomName, getRegion(), defaultTemplate)
4543
deploymentVersion, err := latestStackVersion()
4644
if err != nil {
@@ -59,7 +57,7 @@ func TestAccDeployment_basic_tf(t *testing.T) {
5957
resource.TestCheckResourceAttr(resName, "alias", randomAlias),
6058
resource.TestCheckNoResourceAttr(resName, "apm.config"),
6159
resource.TestCheckNoResourceAttr(resName, "enterprise_search.config"),
62-
resource.TestCheckNoResourceAttr(resName, "traffic_filter"),
60+
resource.TestCheckResourceAttr(resName, "traffic_filter.#", "0"),
6361
// Ensure at least 1 account is trusted (self).
6462
resource.TestCheckResourceAttr(resName, "elasticsearch.trust_account.#", "1"),
6563
),
@@ -78,16 +76,9 @@ func TestAccDeployment_basic_tf(t *testing.T) {
7876
resource.TestCheckResourceAttr(resName, "traffic_filter.#", "1"),
7977
),
8078
},
81-
// Unset the traffic filter (this should not remove the traffic filter)
79+
// Unset the traffic filter to remove the traffic filter
8280
{
8381
Config: cfg,
84-
Check: checkBasicDeploymentResource(resName, randomName, deploymentVersion,
85-
resource.TestCheckResourceAttr(resName, "traffic_filter.#", "1"),
86-
),
87-
},
88-
// Explicitly set the traffic filter to an empty list to remove the traffic filter
89-
{
90-
Config: cfgWithEmptyTrafficFilter,
9182
Check: checkBasicDeploymentResource(resName, randomName, deploymentVersion,
9283
resource.TestCheckResourceAttr(resName, "traffic_filter.#", "0"),
9384
func(s *terraform.State) error {

ec/acc/deployment_ccs_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ func TestAccDeployment_ccs(t *testing.T) {
5050
{
5151
// Create a CCS deployment with the default settings.
5252
Config: cfg,
53+
// The legacy CCS DT does not support autoscaling, which leads to autoscaling being 'unknown'.
54+
// Ideally we would set autoscaling to null if the deployment template does not support autoscaling,
55+
// but that would require's refactoring our schema and this template is no longer part of the public offering.
56+
//
57+
// We can revisit this if there's demand for clean plans when the template does not support autoscaling.
58+
ExpectNonEmptyPlan: true,
5359
Check: resource.ComposeAggregateTestCheckFunc(
5460

5561
// CCS Checks
@@ -94,7 +100,8 @@ func TestAccDeployment_ccs(t *testing.T) {
94100
},
95101
{
96102
// Change the Elasticsearch topology size and node count.
97-
Config: secondConfigCfg,
103+
Config: secondConfigCfg,
104+
ExpectNonEmptyPlan: true,
98105
Check: resource.ComposeAggregateTestCheckFunc(
99106
// Changes.
100107
resource.TestCheckResourceAttrSet(ccsResName, "elasticsearch.hot.instance_configuration_id"),

ec/acc/deployment_pre_node_role_migration_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ func TestAccDeployment_pre_node_roles(t *testing.T) {
6262
},
6363
{
6464
Config: cfgF(upgradeVersionCfg),
65+
// Expect a non-empty plan here. We explicitly avoid migrating node_roles when the version changes
66+
// however will the migrate the deployment to node_roles on the next TF application.
67+
ExpectNonEmptyPlan: true,
6568
Check: resource.ComposeAggregateTestCheckFunc(
6669
resource.TestCheckResourceAttrSet(resName, "elasticsearch.hot.instance_configuration_id"),
6770
resource.TestCheckResourceAttr(resName, "elasticsearch.hot.size", "1g"),

0 commit comments

Comments
 (0)