Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into 0.5
Browse files Browse the repository at this point in the history
* upstream/master: (28 commits)
  Update CHANGELOG.md and NOTICE
  Fix incorrect private link data for Azure eastus (#583)
  Update CHANGELOG.md and NOTICE
  Fix typo in GCP PSC datasource documentation (#571)
  Update CHANGELOG.md and NOTICE
  fix(deps): update module github.com/go-openapi/runtime to v0.25.0 (#564)
  Update CHANGELOG.md and NOTICE
  Utilise the migrate template API when applying changes to the deployment template id  (#547)
  Update CHANGELOG.md and NOTICE
  fix(deps): update module github.com/hashicorp/terraform-plugin-sdk/v2 to v2.24.1 (#559)
  Update CHANGELOG.md and NOTICE
  docs: Add GCP PSC to Traffic Filter argument reference for type (#557)
  Update CHANGELOG.md and NOTICE
  chore(deps): update peterjgrainger/action-create-branch action to v2.3.0 (#560)
  Update CHANGELOG.md and NOTICE
  fix: remove strategy DiffSuppressFunc (#539)
  Update CHANGELOG.md and NOTICE
  fix(deps): update module github.com/stretchr/testify to v1.8.1 (#554)
  Update CHANGELOG.md and NOTICE
  Revert "Run acceptance tests in CI against 1.2.9 (#542)" (#553)
  ...
  • Loading branch information
tobio committed Feb 15, 2023
2 parents 33fb728 + baf44b8 commit 9d1dba5
Show file tree
Hide file tree
Showing 25 changed files with 449 additions and 199 deletions.
3 changes: 3 additions & 0 deletions .changelog/547.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:feature
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.
```
2 changes: 1 addition & 1 deletion .github/workflows/branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
echo ::set-output name=BRANCH::$(echo ${BRANCH} | cut -d '.' -f1-2 | tr -d 'v')
- name: Create a github branch
uses: peterjgrainger/action-create-branch@v2.2.0
uses: peterjgrainger/action-create-branch@v2.3.0
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# 0.5.1 (Unreleased)

FEATURES:

* 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))

# 0.5.0 (Oct 12, 2022)

FEATURES:
Expand Down
24 changes: 14 additions & 10 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform-provider-ec
Copyright 2022 Elasticsearch B.V.
Copyright 2023 Elasticsearch B.V.

This product includes software developed at Elasticsearch B.V. and
third-party software developed by the licenses listed below.
Expand All @@ -10,6 +10,8 @@ github.com/davecgh/go-spew 0BSD
github.com/agext/levenshtein Apache-2.0
github.com/apparentlymart/go-textseg/v13 Apache-2.0
github.com/elastic/cloud-sdk-go Apache-2.0
github.com/go-logr/logr Apache-2.0
github.com/go-logr/stdr Apache-2.0
github.com/go-openapi/analysis Apache-2.0
github.com/go-openapi/errors Apache-2.0
github.com/go-openapi/jsonpointer Apache-2.0
Expand All @@ -24,6 +26,8 @@ github.com/oklog/run Apache-2.0
github.com/oklog/ulid Apache-2.0
github.com/opentracing/opentracing-go Apache-2.0
go.mongodb.org/mongo-driver Apache-2.0
go.opentelemetry.io/otel/trace Apache-2.0
go.opentelemetry.io/otel Apache-2.0
google.golang.org/appengine Apache-2.0
google.golang.org/genproto Apache-2.0
google.golang.org/grpc Apache-2.0
Expand Down Expand Up @@ -59,23 +63,23 @@ github.com/mitchellh/mapstructure MIT
github.com/mitchellh/reflectwalk MIT
github.com/stretchr/testify MIT
github.com/zclconf/go-cty MIT
github.com/hashicorp/go-checkpoint MPL-2.0
github.com/hashicorp/errwrap MPL-2.0
github.com/hashicorp/go-cleanhttp MPL-2.0
github.com/hashicorp/go-uuid MPL-2.0
github.com/hashicorp/hc-install MPL-2.0
github.com/hashicorp/go-version MPL-2.0
github.com/hashicorp/logutils MPL-2.0
github.com/hashicorp/terraform-exec MPL-2.0
github.com/hashicorp/terraform-plugin-log MPL-2.0
github.com/hashicorp/terraform-plugin-sdk/v2 MPL-2.0
github.com/hashicorp/terraform-svchost MPL-2.0
github.com/hashicorp/yamux MPL-2.0
github.com/hashicorp/errwrap MPL-2.0-no-copyleft-exception
github.com/hashicorp/go-cleanhttp MPL-2.0-no-copyleft-exception
github.com/hashicorp/go-checkpoint MPL-2.0-no-copyleft-exception
github.com/hashicorp/go-multierror MPL-2.0-no-copyleft-exception
github.com/hashicorp/go-plugin MPL-2.0-no-copyleft-exception
github.com/hashicorp/go-version MPL-2.0-no-copyleft-exception
github.com/hashicorp/hcl/v2 MPL-2.0-no-copyleft-exception
github.com/hashicorp/terraform-exec MPL-2.0-no-copyleft-exception
github.com/hashicorp/terraform-json MPL-2.0-no-copyleft-exception
github.com/hashicorp/terraform-plugin-go MPL-2.0-no-copyleft-exception
github.com/hashicorp/terraform-plugin-log MPL-2.0-no-copyleft-exception
github.com/hashicorp/terraform-plugin-sdk/v2 MPL-2.0-no-copyleft-exception
github.com/hashicorp/terraform-registry-address MPL-2.0-no-copyleft-exception
github.com/hashicorp/terraform-svchost MPL-2.0-no-copyleft-exception
github.com/hashicorp/yamux MPL-2.0-no-copyleft-exception

=========================================================================
2 changes: 1 addition & 1 deletion build/Makefile.test
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ endif

.PHONY: testacc-ci
testacc-ci:
@ EC_API_KEY=$(shell cat .ci/.apikey) TF_ACC_TERRAFORM_VERSION=1.2.9 $(MAKE) testacc
@ EC_API_KEY=$(shell cat .ci/.apikey) $(MAKE) testacc

.PHONY: sweep-ci
sweep-ci:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: |-

# Data Source: ec_gcp_private_service_connect_endpoint

Use this data source to retrieve information about the Azure Private Link configuration for a given region. Further documentation on how to establish a PrivateLink connection can be found in the ESS [documentation](https://www.elastic.co/guide/en/cloud/current/ec-traffic-filtering-psc.html).
Use this data source to retrieve information about the GCP Private Service Connect configuration for a given region. Further documentation on how to establish a PrivateLink connection can be found in the ESS [documentation](https://www.elastic.co/guide/en/cloud/current/ec-traffic-filtering-psc.html).

~> **NOTE:** This data source provides data relevant to the Elasticsearch Service (ESS) only, and should not be used for ECE.

Expand Down
2 changes: 1 addition & 1 deletion docs/resources/ec_deployment_traffic_filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ resource "ec_deployment_traffic_filter" "gcp_psc" {
The following arguments are supported:

* `name` - (Required) Name of the ruleset.
* `type` - (Required) Type of the ruleset. It can be `"ip"`, `"vpce"` or `"azure_private_endpoint"`.
* `type` - (Required) Type of the ruleset. It can be `"ip"`, `"vpce"`, `"azure_private_endpoint"`, or `"gcp_private_service_connect_endpoint"`.
* `region` - (Required) Filter region, the ruleset can only be attached to deployments in the specific region.
* `rule` (Required) Rule block, which can be specified multiple times for multiple rules.
* `include_by_default` - (Optional) To automatically include the ruleset in the new deployments. Defaults to `false`.
Expand Down
96 changes: 96 additions & 0 deletions ec/acc/deployment_template_migration_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// 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 acc

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestAccDeployment_template_migration(t *testing.T) {
resName := "ec_deployment.compute_optimized"
randomName := prefix + acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
basicCfg := "testdata/deployment_compute_optimized_1.tf"
region := getRegion()
cfg := fixtureAccDeploymentResourceBasicDefaults(t, basicCfg, randomName, region, computeOpTemplate)
secondConfigCfg := fixtureAccDeploymentResourceBasicDefaults(t, basicCfg, randomName, region, memoryOpTemplate)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
// Create a Compute Optimized deployment with the default settings.
Config: cfg,
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr(resName, "deployment_template_id", setDefaultTemplate(region, computeOpTemplate)),
resource.TestCheckResourceAttr(resName, "elasticsearch.#", "1"),
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.#", "1"),
resource.TestCheckResourceAttrSet(resName, "elasticsearch.0.topology.0.instance_configuration_id"),
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.0.size", "8g"),
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.0.size_resource", "memory"),
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.0.node_type_data", ""),
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.0.node_type_ingest", ""),
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.0.node_type_master", ""),
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.0.node_type_ml", ""),
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.0.id", "hot_content"),
resource.TestCheckResourceAttrSet(resName, "elasticsearch.0.topology.0.node_roles.#"),
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.0.zone_count", "2"),
resource.TestCheckResourceAttr(resName, "kibana.#", "1"),
resource.TestCheckResourceAttr(resName, "kibana.0.topology.0.zone_count", "1"),
resource.TestCheckResourceAttr(resName, "kibana.0.topology.#", "1"),
resource.TestCheckResourceAttrSet(resName, "kibana.0.topology.0.instance_configuration_id"),
resource.TestCheckResourceAttr(resName, "kibana.0.topology.0.size", "1g"),
resource.TestCheckResourceAttr(resName, "kibana.0.topology.0.size_resource", "memory"),
resource.TestCheckResourceAttr(resName, "apm.#", "0"),
resource.TestCheckResourceAttr(resName, "enterprise_search.#", "0"),
),
},
{
// Change the deployment to memory optimized
Config: secondConfigCfg,
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr(resName, "deployment_template_id", setDefaultTemplate(region, memoryOpTemplate)),
resource.TestCheckResourceAttr(resName, "elasticsearch.#", "1"),
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.#", "1"),
resource.TestCheckResourceAttrSet(resName, "elasticsearch.0.topology.0.instance_configuration_id"),
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.0.size", "8g"),
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.0.size_resource", "memory"),
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.0.node_type_data", ""),
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.0.node_type_ingest", ""),
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.0.node_type_master", ""),
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.0.node_type_ml", ""),
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.0.id", "hot_content"),
resource.TestCheckResourceAttrSet(resName, "elasticsearch.0.topology.0.node_roles.#"),
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.0.zone_count", "2"),
resource.TestCheckResourceAttr(resName, "kibana.#", "1"),
resource.TestCheckResourceAttr(resName, "kibana.0.topology.0.zone_count", "1"),
resource.TestCheckResourceAttr(resName, "kibana.0.topology.#", "1"),
resource.TestCheckResourceAttrSet(resName, "kibana.0.topology.0.instance_configuration_id"),
resource.TestCheckResourceAttr(resName, "kibana.0.topology.0.size", "1g"),
resource.TestCheckResourceAttr(resName, "kibana.0.topology.0.size_resource", "memory"),
resource.TestCheckResourceAttr(resName, "apm.#", "0"),
resource.TestCheckResourceAttr(resName, "enterprise_search.#", "0"),
),
},
},
})
}
13 changes: 11 additions & 2 deletions ec/acc/testdata/deployment_basic_defaults_hw_2.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@ resource "ec_deployment" "defaults" {
version = data.ec_stack.latest.version
deployment_template_id = "%s"

elasticsearch {}
elasticsearch {
topology {
id = "hot_content"
size = "4g"
}
topology {
id = "warm"
size = "4g"
}
}

kibana {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@
},
"eastus": {
"service_alias": "eastus-prod-010-privatelink-service.b5765cd8-1fc8-45e9-91fc-a9b208369f9a.eastus.azure.privatelinkservice",
"domain_name": "privatelink.eastus2.azure.elastic-cloud.com"
"domain_name": "privatelink.eastus.azure.elastic-cloud.com"
},
"southcentralus": {
"service_alias": "southcentralus-prod-013-privatelink-service.f8030986-5fb9-4b0e-8463-69604233b07e.southcentralus.azure.privatelinkservice",
Expand Down
9 changes: 9 additions & 0 deletions ec/ecresource/deploymentresource/apm_expanders.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,12 @@ func apmResource(res *models.DeploymentTemplateInfoV2) *models.ApmPayload {
}
return res.DeploymentTemplate.Resources.Apm[0]
}

// apmResourceFromUpdate returns the ApmPayload from a deployment
// update request or an empty version of the payload.
func apmResourceFromUpdate(res *models.DeploymentUpdateResources) *models.ApmPayload {
if len(res.Apm) == 0 {
return nil
}
return res.Apm[0]
}
26 changes: 20 additions & 6 deletions ec/ecresource/deploymentresource/elasticsearch_expanders.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,20 +374,34 @@ func matchEsTopologyID(id string, topologies []*models.ElasticsearchClusterTopol
)
}

func emptyEsResource() *models.ElasticsearchPayload {
return &models.ElasticsearchPayload{
Plan: &models.ElasticsearchClusterPlan{
Elasticsearch: &models.ElasticsearchConfiguration{},
},
Settings: &models.ElasticsearchClusterSettings{},
}
}

// esResource returns the ElaticsearchPayload from a deployment
// template or an empty version of the payload.
func esResource(res *models.DeploymentTemplateInfoV2) *models.ElasticsearchPayload {
if len(res.DeploymentTemplate.Resources.Elasticsearch) == 0 {
return &models.ElasticsearchPayload{
Plan: &models.ElasticsearchClusterPlan{
Elasticsearch: &models.ElasticsearchConfiguration{},
},
Settings: &models.ElasticsearchClusterSettings{},
}
return emptyEsResource()
}
return res.DeploymentTemplate.Resources.Elasticsearch[0]
}

// esResourceFromUpdate returns the ElaticsearchPayload from a deployment
// update request or an empty version of the payload.
func esResourceFromUpdate(res *models.DeploymentUpdateResources) *models.ElasticsearchPayload {
if len(res.Elasticsearch) == 0 {
return emptyEsResource()
}

return res.Elasticsearch[0]
}

func unsetElasticsearchCuration(payload *models.ElasticsearchPayload) {
if payload.Plan.Elasticsearch != nil {
payload.Plan.Elasticsearch.Curation = nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,12 @@ func essResource(res *models.DeploymentTemplateInfoV2) *models.EnterpriseSearchP
}
return res.DeploymentTemplate.Resources.EnterpriseSearch[0]
}

// essResourceFromUpdate returns the EnterpriseSearchPayload from a deployment
// update request or an empty version of the payload.
func essResourceFromUpdate(res *models.DeploymentUpdateResources) *models.EnterpriseSearchPayload {
if len(res.EnterpriseSearch) == 0 {
return nil
}
return res.EnterpriseSearch[0]
}
Loading

0 comments on commit 9d1dba5

Please sign in to comment.