Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce integrations_server resource #425

Merged
merged 29 commits into from
Feb 24, 2022
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
d4bba40
Introduce `integrations_server` resource
mieciu Jan 19, 2022
51ed9b9
Introduce `integrations_server` resource - fix expander
mieciu Jan 20, 2022
0619a70
Update to ms-69 changes
mieciu Jan 31, 2022
3d77e04
Merge remote-tracking branch 'origin/master' into integrations-server…
mieciu Jan 31, 2022
4f8ad72
Bump `cloud-sdk-go`
mieciu Jan 31, 2022
31117ba
Add small fix on version parsing
marclop Feb 8, 2022
3d327ee
Merge remote-tracking branch 'origin/master' into integrations-server…
mieciu Feb 9, 2022
987f769
Update `go.sum`
mieciu Feb 9, 2022
70cda39
Update Terraform SDK
marclop Feb 14, 2022
2362c06
Fixup acceptance and nodeRoles flag
marclop Feb 14, 2022
796f73c
Update ec/ecresource/deploymentresource/schema_integrations_server.go
mieciu Feb 14, 2022
566adf6
Review feedback applied
mieciu Feb 14, 2022
fbb5e4a
Update docs
mieciu Feb 14, 2022
8c079c4
Merge branch 'master' into integrations-server-support
marclop Feb 15, 2022
ee1dae1
Update docs - bring back APM
mieciu Feb 16, 2022
bf87d7a
Merge remote-tracking branch 'origin/master' into integrations-server…
mieciu Feb 16, 2022
74a90a8
Merge remote-tracking branch 'mieciu/integrations-server-support' int…
mieciu Feb 16, 2022
b5a8eec
Bump cloud-sdk-go to v1.8.1
mieciu Feb 22, 2022
fdfdac4
Update docs/data-sources/ec_deployments.md
mieciu Feb 22, 2022
5d13c61
Update docs/resources/ec_deployment.md
mieciu Feb 22, 2022
1d0d096
Add basic Integrations Server acceptance test
mieciu Feb 22, 2022
f2c999b
Merge remote-tracking branch 'mieciu/integrations-server-support' int…
mieciu Feb 22, 2022
01fefa6
Bring back APM to unit test
mieciu Feb 22, 2022
6d1428f
Add flattener spec for integrations_server
mieciu Feb 22, 2022
d6be992
Add ECE DT plus more unit tests
mieciu Feb 22, 2022
2bb0ebd
lint TF
mieciu Feb 22, 2022
24bab14
Fix acc test :facepalm:
mieciu Feb 22, 2022
353ac5e
Merge branch 'master' into integrations-server-support
marclop Feb 24, 2022
a010368
Update release notes/changelog
mieciu Feb 24, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/data-sources/ec_deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,19 @@ These will not be available for interpolation.
* `kibana.#.topology.#.instance_configuration_id` - Controls the allocation of this topology element as well as allowed sizes and node_types. It needs to match the ID of an existing instance configuration.
* `kibana.#.topology.#.size` - Amount of memory (RAM) per topology element in the "<size in GB>g" notation.
* `kibana.#.topology.#.zone_count` - Number of zones in which nodes will be placed.
* `integrations_server` - Instance configuration of the Integrations Server type.
* `integrations_server.#.elasticsearch_cluster_ref_id` - The user-specified ID of the Elasticsearch cluster to which this resource kind will link.
* `integrations_server.#.healthy` - Resource kind health status.
* `integrations_server.#.http_endpoint` - HTTP endpoint for the resource kind.
* `integrations_server.#.https_endpoint` - HTTPS endpoint for the resource kind.
* `integrations_server.#.ref_id` - User specified ref_id for the resource kind.
* `integrations_server.#.resource_id` - The resource unique identifier.
* `integrations_server.#.status` - Resource kind status (for example, "started", "stopped", etc).
* `integrations_server.#.version` - Elastic stack version.
* `integrations_server.#.topology` - Node topology element definition.
* `integrations_server.#.topology.#.instance_configuration_id` - Controls the allocation of this topology element as well as allowed sizes and node_types. It needs to match the ID of an existing instance configuration.
* `integrations_server.#.topology.#.size` - Amount of memory (RAM) per topology element in the "<size in GB>g" notation.
* `integrations_server.#.topology.#.zone_count` - Number of zones in which nodes will be placed.
* `apm` - Instance configuration of the APM type.
* `apm.#.elasticsearch_cluster_ref_id` - The user-specified ID of the Elasticsearch cluster to which this resource kind will link.
* `apm.#.healthy` - Resource kind health status.
Expand Down
14 changes: 11 additions & 3 deletions docs/data-sources/ec_deployments.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ data "ec_deployments" "example" {
status = "started"
}

apm {
version = "7.9.1"
integrations_server {
version = "8.0.0"
}

enterprise_search {
Expand All @@ -54,7 +54,11 @@ data "ec_deployments" "example" {
* `kibana.#.status` - Resource kind status (Available statuses are: initializing, stopping, stopped, rebooting, restarting, reconfiguring, and started).
* `kibana.#.version` - Elastic stack version.
* `kibana.#.healthy` - Overall health status of the Kibana instances.
* `apm` - Filter by APM resource kind status or configuration.
* `integrations_server` - Filter by Integrations Server resource kind status or configuration.
* `integrations_server.#.status` - Resource kind status (Available statuses are: initializing, stopping, stopped, rebooting, restarting, reconfiguring, and started).
* `integrations_server.#.version` - Elastic stack version.
* `integrations_server.#.healthy` - Overall health status of the Integrations Server instances.
* `apm` - **DEPRECATED** Filter by APM resource kind status or configuration.
* `apm.#.status` - Resource kind status (Available statuses are: initializing, stopping, stopped, rebooting, restarting, reconfiguring, and started).
* `apm.#.version` - Elastic stack version.
* `apm.#.healthy` - Overall health status of the APM instances.
Expand All @@ -63,6 +67,8 @@ data "ec_deployments" "example" {
* `enterprise_search.#.version` - Elastic stack version.
* `enterprise_search.#.healthy` - Overall health status of the Enterprise Search instances.

**Note:** `apm` resource kind has been deprecated in stack version 8.0.0. New deployments should use `integrations_server` instead.
mieciu marked this conversation as resolved.
Show resolved Hide resolved

## Attributes Reference

~> **NOTE:** Depending on the deployment definition, some values may not be set.
Expand All @@ -76,6 +82,8 @@ These will not be available for interpolation.
* `deployments.#.elasticsearch_ref_id` - The Elasticsearch resource reference.
* `deployments.#.kibana_resource_id` - The Kibana resource unique ID.
* `deployments.#.kibana_ref_id` - The Kibana resource reference.
* `deployments.#.integrations_server_resource_id` - The Integrations Server resource unique ID.
* `deployments.#.integrations_server_ref_id` - The Integrations Server resource reference.
* `deployments.#.apm_resource_id` - The APM resource unique ID.
* `deployments.#.apm_ref_id` - The APM resource reference.
* `deployments.#.enterprise_search_resource_id` - The Enterprise Search resource unique ID.
Expand Down
37 changes: 33 additions & 4 deletions docs/resources/ec_deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ resource "ec_deployment" "example_minimal" {

kibana {}

apm {}
integrations_server {}

enterprise_search {}
}
Expand Down Expand Up @@ -84,7 +84,7 @@ resource "ec_deployment" "example_minimal" {

kibana {}

apm {}
integrations_server {}

enterprise_search {}
}
Expand Down Expand Up @@ -207,8 +207,9 @@ The following arguments are supported:

-> **Note on disabling Kibana** While optional it is recommended deployments specify a Kibana block, since not doing so might cause issues when modifying or upgrading the deployment.

* `apm` (Optional) APM instance definition, can only be specified once.
* `integrations_server` (Optional) Integrations Server instance definition, can only be specified once. It has replaced `apm` in stack version 8.0.0.
* `enterprise_search` (Optional) Enterprise Search server definition, can only be specified once. For multi-node Enterprise Search deployments, use multiple `topology` blocks.
* `apm` **DEPRECATED** (Optional) APM instance definition, can only be specified once.
mieciu marked this conversation as resolved.
Show resolved Hide resolved
* `traffic_filter` (Optional) List of traffic filter rule identifiers that will be applied to the deployment.
* `observability` (Optional) Observability settings that you can set to ship logs and metrics to a separate deployment.
* `tags` (Optional) Key value map of arbitrary string tags.
Expand All @@ -219,7 +220,7 @@ The following arguments are supported:

To create a valid deployment, you must specify at least the resource type `elasticsearch`. The supported resources are listed below.

A default topology from the deployment template is used for empty blocks: `elasticsearch {}`, `kibana {}`, `apm {}`, `enterprise_search {}`. When a block is not set, the resource kind is not enabled in the deployment.
A default topology from the deployment template is used for empty blocks: `elasticsearch {}`, `kibana {}`, `integrations_server {}`, `enterprise_search {}`. When a block is not set, the resource kind is not enabled in the deployment.

The `ec_deployment` resource will opt-out all the resources except Elasticsearch, which inherits the default topology from the deployment template. For example, the [I/O Optimized template includes an Elasticsearch cluster 8 GB memory x 2 availability zones](https://www.elastic.co/guide/en/cloud/current/ec-getting-started-profiles.html#ec-getting-started-profiles-io).

Expand Down Expand Up @@ -354,6 +355,30 @@ The optional `kibana.config` block supports the following arguments:
* `user_settings_yaml` - (Optional) YAML-formatted user level `kibana.yml` setting overrides.
* `user_settings_override_yaml` - (Optional) YAML-formatted admin (ECE) level `kibana.yml` setting overrides.

#### Integrations Server

The optional `integrations_server` block supports the following arguments:

* `topology` - (Optional) Can be set multiple times to compose complex topologies.
* `elasticsearch_cluster_ref_id` - (Optional) This field references the `ref_id` of the deployment Elasticsearch cluster. The default value `main-elasticsearch` is recommended.
* `ref_id` - (Optional) Can be set on the Integrations Server resource. The default value `main-integrations_server` is recommended.
* `config` (Optional) Integrations Server settings applied to all topologies unless overridden in the `topology` element.

##### Topology

The optional `integrations_server.topology` block supports the following arguments:

* `instance_configuration_id` - (Optional) Default instance configuration of the deployment template. No need to change this value since Integrations Server has only one _instance type_.
* `size` - (Optional) Amount of memory (RAM) per topology element in the "<size in GB>g" notation. When omitted, it defaults to the deployment template value.
* `size_resource` - (Optional) Type of resource to which the size is assigned. Defaults to `"memory"`.
* `zone_count` - (Optional) Number of zones that the Integrations Server deployment will span. This is used to set HA. When omitted, it defaults to the deployment template value.

##### Config

The optional `integrations_server.config` block supports the following arguments:

* `debug_enabled` - (Optional) Enable debug mode for the component. Defaults to `false`.

#### APM

The optional `apm` block supports the following arguments:
Expand Down Expand Up @@ -441,6 +466,10 @@ In addition to all the arguments above, the following attributes are exported:
* `kibana.#.region` - Kibana region.
* `kibana.#.http_endpoint` - Kibana resource HTTP endpoint.
* `kibana.#.https_endpoint` - Kibana resource HTTPs endpoint.
* `integrations_server.#.resource_id` - Integrations Server resource unique identifier.
* `integrations_server.#.region` - Integrations Server region.
* `integrations_server.#.http_endpoint` - Integrations Server resource HTTP endpoint.
* `integrations_server.#.https_endpoint` - Integrations Server resource HTTPs endpoint.
* `apm.#.resource_id` - APM resource unique identifier.
* `apm.#.region` - APM region.
* `apm.#.http_endpoint` - APM resource HTTP endpoint.
Expand Down
2 changes: 1 addition & 1 deletion ec/acc/deployment_basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func TestAccDeployment_basic_config(t *testing.T) {
resource.TestCheckResourceAttr(resName, "kibana.0.config.#", "1"),
resource.TestCheckResourceAttr(resName, "kibana.0.config.0.user_settings_yaml", "csp.warnLegacyBrowsers: true"),
resource.TestCheckResourceAttr(resName, "enterprise_search.0.config.#", "1"),
resource.TestCheckResourceAttr(resName, "enterprise_search.0.config.0.user_settings_yaml", "ent_search.login_assistance_message: somemessage"),
resource.TestCheckResourceAttr(resName, "enterprise_search.0.config.0.user_settings_yaml", "# comment"),
),
},
{
Expand Down
2 changes: 1 addition & 1 deletion ec/acc/testdata/deployment_basic_settings_config_2.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ resource "ec_deployment" "basic" {

enterprise_search {
config {
user_settings_yaml = "ent_search.login_assistance_message: somemessage"
user_settings_yaml = "# comment"
mieciu marked this conversation as resolved.
Show resolved Hide resolved
}
topology {
instance_configuration_id = "%s"
Expand Down
5 changes: 5 additions & 0 deletions ec/ecdatasource/deploymentdatasource/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ func modelToState(d *schema.ResourceData, res *models.DeploymentGetResponse) err
return err
}

integrationsServerFlattened := flattenIntegrationsServerResources(res.Resources.IntegrationsServer)
if err := d.Set("integrations_server", integrationsServerFlattened); err != nil {
return err
}

enterpriseSearchFlattened := flattenEnterpriseSearchResources(res.Resources.EnterpriseSearch)
if err := d.Set("enterprise_search", enterpriseSearchFlattened); err != nil {
return err
Expand Down
8 changes: 8 additions & 0 deletions ec/ecdatasource/deploymentdatasource/datasource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ func Test_modelToState(t *testing.T) {
Healthy: ec.Bool(true),
},
}},
IntegrationsServer: []*models.IntegrationsServerResourceInfo{{
Info: &models.IntegrationsServerInfo{
Healthy: ec.Bool(true),
},
}},
EnterpriseSearch: []*models.EnterpriseSearchResourceInfo{
{
Info: &models.EnterpriseSearchInfo{
Expand Down Expand Up @@ -161,6 +166,9 @@ func newSampleDeployment() map[string]interface{} {
"apm": []interface{}{map[string]interface{}{
"healthy": true,
}},
"integrations_server": []interface{}{map[string]interface{}{
"healthy": true,
}},
"enterprise_search": []interface{}{map[string]interface{}{
"healthy": true,
}},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
// 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 deploymentdatasource

import (
"github.com/elastic/cloud-sdk-go/pkg/models"

"github.com/elastic/terraform-provider-ec/ec/internal/util"
)

// flattenIntegrationsServerResources takes in IntegrationsServer resource models and returns its
// flattened form.
func flattenIntegrationsServerResources(in []*models.IntegrationsServerResourceInfo) []interface{} {
var result = make([]interface{}, 0, len(in))
for _, res := range in {
var m = make(map[string]interface{})

if res.ElasticsearchClusterRefID != nil {
m["elasticsearch_cluster_ref_id"] = *res.ElasticsearchClusterRefID
}

if res.RefID != nil {
m["ref_id"] = *res.RefID
}

if res.Info != nil {
if res.Info.Healthy != nil {
m["healthy"] = *res.Info.Healthy
}

if res.Info.ID != nil {
m["resource_id"] = *res.Info.ID
}

if res.Info.Status != nil {
m["status"] = *res.Info.Status
}

if !util.IsCurrentIntegrationsServerPlanEmpty(res) {
var plan = res.Info.PlanInfo.Current.Plan

if plan.IntegrationsServer != nil {
m["version"] = plan.IntegrationsServer.Version
}

m["topology"] = flattenIntegrationsServerTopology(plan)
}

if res.Info.Metadata != nil {
for k, v := range util.FlattenClusterEndpoint(res.Info.Metadata) {
m[k] = v
}
}
}

result = append(result, m)
}

return result
}

func flattenIntegrationsServerTopology(plan *models.IntegrationsServerPlan) []interface{} {
var result = make([]interface{}, 0, len(plan.ClusterTopology))
for _, topology := range plan.ClusterTopology {
var m = make(map[string]interface{})

if isIntegrationsServerSizePopulated(topology) && *topology.Size.Value == 0 {
continue
}

m["instance_configuration_id"] = topology.InstanceConfigurationID

if isIntegrationsServerSizePopulated(topology) {
m["size"] = util.MemoryToState(*topology.Size.Value)
m["size_resource"] = *topology.Size.Resource
}

m["zone_count"] = topology.ZoneCount

result = append(result, m)
}

return result
}

func isIntegrationsServerSizePopulated(topology *models.IntegrationsServerTopologyElement) bool {
if topology.Size != nil && topology.Size.Value != nil {
return true
}

return false
}
5 changes: 5 additions & 0 deletions ec/ecdatasource/deploymentdatasource/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ func newSchema() map[string]*schema.Schema {
Computed: true,
Elem: newApmResourceInfo(),
},
"integrations_server": {
Type: schema.TypeList,
Computed: true,
Elem: newIntegrationsServerResourceInfo(),
},
"enterprise_search": {
Type: schema.TypeList,
Computed: true,
Expand Down
Loading