Git Product home page Git Product logo

terraform-provider-ec's Introduction

Terraform Provider for Elastic Cloud

Go Acceptance Status

Terraform provider for the Elastic Cloud API, including:

  • Elasticsearch Service (ESS).
  • Elastic Cloud Enterprise (ECE).
  • Elasticsearch Service Private (ESSP).

Model changes might be introduced between minors until version 1.0.0 is released. Such changes and the expected impact will be detailed in the change log and the individual release notes.

Terraform provider scope

The goal for a Terraform provider is to orchestrate lifecycle for deployments via common set of APIs across ESS, ESSP and ECE (see https://www.elastic.co/guide/en/cloud/current/ec-restful-api.html for API examples)

Things which are out of scope for provider:

We now have Terraform provider for Elastic Stack https://github.com/elastic/terraform-provider-elasticstack which should be used for any operations on Elastic Stack products.

Version guidance

It is strongly recommended to consistently utilize the latest versions of both the Elastic Cloud terraform provider and Terraform CLI. Doing so not only mitigates the risk of encountering known issues but also enhances overall user experience.

Support

We welcome questions on how to use the Elastic providers. The providers are supported by Elastic. General questions, bugs and product issues should be raised in their corresponding repositories, either for the Elastic Stack provider, or the Elastic Cloud one. Questions can also be directed to the discuss forum. https://discuss.elastic.co/c/orchestration.

We will not, however, fix bugs upon customer demand, as we have to prioritize all pending bugs and features, as part of the product's backlog and release cycles.

Support tickets severity

Support tickets related to the Terraform provider can be opened with Elastic, however since the provider is just a client of the underlying product API's, we will not be able to treat provider related support requests as a Severity-1 (Immedediate time frame). Urgent, production-related Terraform issues can be resolved via direct interaction with the underlying project API or UI. We will ask customers to resort to these methods to resolve downtime or urgent issues.

Example usage

These examples are forward looking and might use an unreleased version, for a current view of working examples, please refer to the Terraform registry documentation.

terraform {
  required_version = ">= 0.12.29"

  required_providers {
    ec = {
      source  = "elastic/ec"
      version = "0.11.0"
    }
  }
}

provider "ec" {
  # ECE installation endpoint
  endpoint = "https://my.ece-environment.corp"

  # If the ECE installation has a self-signed certificate
  # setting "insecure" to true is required.
  insecure = true

  # APIKey is the recommended authentication mechanism. When
  # Targeting the Elasticsearch Service, APIKeys are the only
  # valid authentication mechanism.
  apikey = "my-apikey"

  # When targeting ECE installations, username and password
  # authentication is allowed.
  username = "my-username"
  password = "my-password"
}

data "ec_stack" "latest" {
  version_regex = "latest"
  region        = "us-east-1"
}

# Create an Elastic Cloud deployment
resource "ec_deployment" "example_minimal" {
  # Optional name.
  name = "my_example_deployment"

  # Mandatory fields
  region                 = "us-east-1"
  version                = data.ec_stack.latest.version
  deployment_template_id = "aws-io-optimized-v2"

  # Use the deployment template defaults
  elasticsearch = {
    hot = {
      autoscaling = {}
    }

    ml = {
       autoscaling = {
          autoscale = true
       }
    }

  }

  kibana = {
    topology = {}
  }
}

Developer Requirements

  • Terraform 0.13+
  • Go 1.16+ (to build the provider plugin)

Installing the provider via the source code

Clone the repository to a folder on your machine and run make install:

$ mkdir -p ~/development; cd ~/development
$ git clone https://github.com/elastic/terraform-provider-ec
$ cd terraform-provider-ec
$ make install

Generating an Elasticsearch Service (ESS) API Key

To generate an API key, follow these steps:

  1. Open your browser and navigate to https://cloud.elastic.co/login.
  2. Log in with your email and password.
  3. Click on Elasticsearch Service.
  4. Navigate to Features > API Keys and click on Generate API Key.
  5. Choose a name for your API key.
  6. Save your API key somewhere safe.

Using your API Key on the Elastic Cloud terraform provider

After you've generated your API Key, you can make it available to the Terraform provider by exporting it as an environment variable:

$ export EC_API_KEY="<apikey value>"

After doing so, you can navigate to any of our examples in ./examples and try one.

Moving to TF Framework and schema change for ec_deployment resource.

v0.6.0 contains migration to TF Plugin Framework and intoduces new schema for ec_deployment resource:

  • 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.
resource "ec_deployment" "defaults" {
  name                   = "example"
  region                 = "us-east-1"
  version                = data.ec_stack.latest.version
  deployment_template_id = "aws-io-optimized-v2"

  elasticsearch = {
    hot = {
      autoscaling = {}
    }
  }

  kibana = {
    topology = {}
  }

  enterprise_search = {
    zone_count = 1
  }
}
  • topology attribute of elasticsearch is replaced with a number of dedicated attributes, one per tier, e.g.
  elasticsearch {
    topology {
      id         = "hot_content"
      size       = "1g"
      autoscaling {
        max_size = "8g"
      }
    }
    topology {
      id         = "warm"
      size       = "2g"
      autoscaling {
        max_size = "15g"
      }
    }
  }

has to be converted to

  elasticsearch = {
    hot = {
      size = "1g"
      autoscaling = {
        max_size = "8g"
      }
    }

    warm = {
      size = "2g"
      autoscaling = {
        max_size = "15g"
      }
    }
  }

  • 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
resource "ec_deployment" "defaults" {
  name                   = "example"
  region                 = "us-east-1"
  version                = data.ec_stack.latest.version
  deployment_template_id = "aws-io-optimized-v2"

  elasticsearch = {
    hot = {
      autoscaling = {}
    }
  }
}

Please note that the snippet explicitly mentions hot tier with autoscaling attribute even despite the fact that they are empty.

  • 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).

  • strategy attribute is converted to string with the same set of values that was used for its type attribute previously;

  • switching to TF protocol 6. From user perspective it should not require any change in their existing configurations.

Moving to the provider v0.6.0.

The schema modifications means that a current TF state cannot work as is with the provider version 0.6.0 and higher.

There are 2 ways to tackle this

  • import existing resource using deployment ID, e.g terraform import 'ec_deployment.test' <deployment_id>
  • state upgrade that is performed by TF by calling the provider's API so no action is required from users

Currently the state upgrade functionality is not implemented so importing existing resources is the recommended way to deal with existing TF states. 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. State upgrade doesn't have this limitation.

Known issues of moving to the provider v0.6.0

  • 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.

  • 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). This happens because TF Framework treats all computed attributes as unknown (known after apply) once configuration changes. However, it doesn't mean that all attributes that marked as unknown in the plan will get new values after apply.

  • 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. 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.

  • The migration is based on 0.4.1, so all changes from 0.5.0 are omitted.

terraform-provider-ec's People

Contributors

alaudazzi avatar artemnikitin avatar claudia-correia avatar dependabot[bot] avatar dimuon avatar elastic-backstage-prod[bot] avatar elastic-renovate-prod[bot] avatar ggsood avatar gigerdo avatar hitsumabushi845 avatar jongwooo avatar karencfv avatar karmi avatar kruskall avatar kuisathaverat avatar kunisen avatar kushmaro avatar leejones avatar luigibk avatar marclop avatar mieciu avatar neiljbrookes avatar nkammah avatar pascal-hofmann avatar pmoust avatar renovate[bot] avatar sakurai-youhei avatar snowhork avatar tobio avatar wandergeek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

terraform-provider-ec's Issues

cross cluster search ends in a panic

If i am taking for instance this example
https://github.com/elastic/terraform-provider-ec/tree/master/examples/deployment

and change the template to
`deployment_template_id = "aws-cross-cluster-search-v2"``

and apply this one, it results in a panic:

Error: rpc error: code = Unavailable desc = transport is closing

panic: runtime error: index out of range [0] with length 0
2020-10-21T13:45:33.786+0200 [DEBUG] plugin.terraform-provider-ec_v0.1.0: 
2020-10-21T13:45:33.786+0200 [DEBUG] plugin.terraform-provider-ec_v0.1.0: goroutine 32 [running]:
2020-10-21T13:45:33.786+0200 [DEBUG] plugin.terraform-provider-ec_v0.1.0: github.com/elastic/terraform-provider-ec/ec/ecresource/deploymentresource.expandApmTopology(0x20653c0, 0xc000a1b660, 0x0, 0x0, 0x0, 0x1, 0xc0009f7160, 0x100df26, 0xc00014ba40, 0x70)
2020-10-21T13:45:33.786+0200 [DEBUG] plugin.terraform-provider-ec_v0.1.0: 	/Users/test/git/terraform-provider-ec/ec/ecresource/deploymentresource/apm_expanders.go:102 +0x638
2020-10-21T13:45:33.786+0200 [DEBUG] plugin.terraform-provider-ec_v0.1.0: github.com/elastic/terraform-provider-ec/ec/ecresource/deploymentresource.expandApmResource(0x212be80, 0xc000a0bd70, 0xc0003d7180, 0xc000011eb8, 0x20653c0, 0x20653c0)
2020-10-21T13:45:33.786+0200 [DEBUG] plugin.terraform-provider-ec_v0.1.0: 	/Users/test/git/terraform-provider-ec/ec/ecresource/deploymentresource/apm_expanders.go:77 +0x327
2020-10-21T13:45:33.786+0200 [DEBUG] plugin.terraform-provider-ec_v0.1.0: github.com/elastic/terraform-provider-ec/ec/ecresource/deploymentresource.expandApmResources(0xc000a18df0, 0x1, 0x1, 0xc0003d7180, 0xc000a1b6a0, 0x1, 0x1, 0x1, 0x0)
2020-10-21T13:45:33.786+0200 [DEBUG] plugin.terraform-provider-ec_v0.1.0: 	/Users/test/git/terraform-provider-ec/ec/ecresource/deploymentresource/apm_expanders.go:39 +0xbe
2020-10-21T13:45:33.786+0200 [DEBUG] plugin.terraform-provider-ec_v0.1.0: github.com/elastic/terraform-provider-ec/ec/ecresource/deploymentresource.createResourceToModel(0xc000393580, 0xc0005c4740, 0x40, 0x208ca40, 0x2686f00)
2020-10-21T13:45:33.786+0200 [DEBUG] plugin.terraform-provider-ec_v0.1.0: 	/Users/test/git/terraform-provider-ec/ec/ecresource/deploymentresource/expanders.go:64 +0x6c5
2020-10-21T13:45:33.786+0200 [DEBUG] plugin.terraform-provider-ec_v0.1.0: github.com/elastic/terraform-provider-ec/ec/ecresource/deploymentresource.createResource(0x26e5cc0, 0xc000055a40, 0xc000393580, 0x2035800, 0xc0005c4740, 0xc0007b3d80, 0xc000133708, 0x18f534e)
2020-10-21T13:45:33.786+0200 [DEBUG] plugin.terraform-provider-ec_v0.1.0: 	/Users/test/git/terraform-provider-ec/ec/ecresource/deploymentresource/create.go:36 +0xc8
2020-10-21T13:45:33.786+0200 [DEBUG] plugin.terraform-provider-ec_v0.1.0: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0xc0006c5a20, 0x26e5cc0, 0xc000055a40, 0xc000393580, 0x2035800, 0xc0005c4740, 0x0, 0x0, 0x0)
2020-10-21T13:45:33.786+0200 [DEBUG] plugin.terraform-provider-ec_v0.1.0: 	/Users/test/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:276 +0x275
2020-10-21T13:45:33.786+0200 [DEBUG] plugin.terraform-provider-ec_v0.1.0: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0006c5a20, 0x26e5c40, 0xc00052cc80, 0xc00014a230, 0xc0000e98a0, 0x2035800, 0xc0005c4740, 0x0, 0x0, 0x0, ...)
2020-10-21T13:45:33.786+0200 [DEBUG] plugin.terraform-provider-ec_v0.1.0: 	/Users/test/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:387 +0x695
2020-10-21T13:45:33.786+0200 [DEBUG] plugin.terraform-provider-ec_v0.1.0: github.com/hashicorp/terraform-plugin-sdk/v2/internal/helper/plugin.(*GRPCProviderServer).ApplyResourceChange(0xc000510220, 0x26e5c40, 0xc00052cc80, 0xc00014a000, 0xc000510220, 0xc00052cc80, 0x0)
2020-10-21T13:45:33.786+0200 [DEBUG] plugin.terraform-provider-ec_v0.1.0: 	/Users/test/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/internal/helper/plugin/grpc_provider.go:952 +0x8b8
2020-10-21T13:45:33.786+0200 [DEBUG] plugin.terraform-provider-ec_v0.1.0: github.com/hashicorp/terraform-plugin-sdk/v2/internal/tfplugin5._Provider_ApplyResourceChange_Handler.func1(0x26e5c40, 0xc00052cc80, 0x2365be0, 0xc00014a000, 0xc00052cc80, 0x21f31a0, 0xc000054901, 0xc0000e87e0)
2020-10-21T13:45:33.786+0200 [DEBUG] plugin.terraform-provider-ec_v0.1.0: 	/Users/test/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/internal/tfplugin5/tfplugin5.pb.go:3312 +0x86
2020-10-21T13:45:33.787+0200 [DEBUG] plugin.terraform-provider-ec_v0.1.0: github.com/hashicorp/terraform-plugin-sdk/v2/plugin.Serve.func3.1(0x26e5d00, 0xc0005c2000, 0x2365be0, 0xc00014a000, 0xc0000e87c0, 0xc0000e87e0, 0xc0006acb58, 0x10f65f8, 0x22e8b80, 0xc0005c2000)
2020-10-21T13:45:33.787+0200 [DEBUG] plugin.terraform-provider-ec_v0.1.0: 	/Users/test/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/plugin/serve.go:76 +0x87
2020-10-21T13:45:33.787+0200 [DEBUG] plugin.terraform-provider-ec_v0.1.0: github.com/hashicorp/terraform-plugin-sdk/v2/internal/tfplugin5._Provider_ApplyResourceChange_Handler(0x23820e0, 0xc000510220, 0x26e5d00, 0xc0005c2000, 0xc0000549c0, 0xc0005103e0, 0x26e5d00, 0xc0005c2000, 0xc0005c6000, 0x90a)
2020-10-21T13:45:33.787+0200 [DEBUG] plugin.terraform-provider-ec_v0.1.0: 	/Users/test/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/internal/tfplugin5/tfplugin5.pb.go:3314 +0x14b
2020-10-21T13:45:33.787+0200 [DEBUG] plugin.terraform-provider-ec_v0.1.0: google.golang.org/grpc.(*Server).processUnaryRPC(0xc0005fa000, 0x26f6940, 0xc0004c7b00, 0xc0007ba900, 0xc000370b70, 0x32ccfe0, 0x0, 0x0, 0x0)
2020-10-21T13:45:33.787+0200 [DEBUG] plugin.terraform-provider-ec_v0.1.0: 	/Users/test/go/pkg/mod/google.golang.org/[email protected]/server.go:1171 +0x4fd
2020-10-21T13:45:33.787+0200 [DEBUG] plugin.terraform-provider-ec_v0.1.0: google.golang.org/grpc.(*Server).handleStream(0xc0005fa000, 0x26f6940, 0xc0004c7b00, 0xc0007ba900, 0x0)
2020-10-21T13:45:33.787+0200 [DEBUG] plugin.terraform-provider-ec_v0.1.0: 	/Users/test/go/pkg/mod/google.golang.org/[email protected]/server.go:1494 +0xd27
2020-10-21T13:45:33.787+0200 [DEBUG] plugin.terraform-provider-ec_v0.1.0: google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc0002dfd00, 0xc0005fa000, 0x26f6940, 0xc0004c7b00, 0xc0007ba900)
2020-10-21T13:45:33.787+0200 [DEBUG] plugin.terraform-provider-ec_v0.1.0: 	/Users/test/go/pkg/mod/google.golang.org/[email protected]/server.go:834 +0xbb
2020-10-21T13:45:33.787+0200 [DEBUG] plugin.terraform-provider-ec_v0.1.0: created by google.golang.org/grpc.(*Server).serveStreams.func1
2020-10-21T13:45:33.787+0200 [DEBUG] plugin.terraform-provider-ec_v0.1.0: 	/Users/test/go/pkg/mod/google.golang.org/[email protected]/server.go:832 +0x204
2020-10-21T13:45:33.790+0200 [WARN]  plugin.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2020-10-21T13:45:33.790+0200 [DEBUG] plugin: plugin process exited: path=.terraform/plugins/registry.terraform.io/elastic/ec/0.1.0/darwin_amd64/terraform-provider-ec_v0.1.0 pid=46174 error="exit status 2"
2020/10/21 13:45:33 [DEBUG] ec_deployment.example_minimal: apply errored, but we're indicating that via the Error pointer rather than returning it: rpc error: code = Unavailable desc = transport is closing
2020/10/21 13:45:33 [TRACE] eval: *terraform.EvalMaybeTainted
2020/10/21 13:45:33 [TRACE] EvalMaybeTainted: ec_deployment.example_minimal encountered an error during creation, so it is now marked as tainted
2020/10/21 13:45:33 [TRACE] eval: *terraform.EvalWriteState
2020/10/21 13:45:33 [TRACE] EvalWriteState: removing state object for ec_deployment.example_minimal
2020/10/21 13:45:33 [TRACE] eval: *terraform.EvalApplyProvisioners
2020/10/21 13:45:33 [TRACE] EvalApplyProvisioners: ec_deployment.example_minimal has no state, so skipping provisioners
2020/10/21 13:45:33 [TRACE] eval: *terraform.EvalMaybeTainted
2020/10/21 13:45:33 [TRACE] EvalMaybeTainted: ec_deployment.example_minimal encountered an error during creation, so it is now marked as tainted
2020/10/21 13:45:33 [TRACE] eval: *terraform.EvalWriteState
2020/10/21 13:45:33 [TRACE] EvalWriteState: removing state object for ec_deployment.example_minimal
2020/10/21 13:45:33 [TRACE] eval: *terraform.EvalIf
2020/10/21 13:45:33 [TRACE] eval: *terraform.EvalIf
2020/10/21 13:45:33 [TRACE] eval: *terraform.EvalWriteDiff
2020/10/21 13:45:33 [TRACE] eval: *terraform.EvalApplyPost
2020/10/21 13:45:33 [ERROR] eval: *terraform.EvalApplyPost, err: rpc error: code = Unavailable desc = transport is closing
2020/10/21 13:45:33 [ERROR] eval: *terraform.EvalSequence, err: rpc error: code = Unavailable desc = transport is closing
2020/10/21 13:45:33 [TRACE] [walkApply] Exiting eval tree: ec_deployment.example_minimal
2020/10/21 13:45:33 [TRACE] vertex "ec_deployment.example_minimal": visit complete
2020/10/21 13:45:33 [TRACE] dag/walk: upstream of "output.elasticsearch_username (expand)" errored, so skipping
2020/10/21 13:45:33 [TRACE] dag/walk: upstream of "output.elasticsearch_cloud_id (expand)" errored, so skipping
2020/10/21 13:45:33 [TRACE] dag/walk: upstream of "provider[\"registry.terraform.io/elastic/ec\"] (close)" errored, so skipping
2020/10/21 13:45:33 [TRACE] dag/walk: upstream of "output.elasticsearch_version (expand)" errored, so skipping
2020/10/21 13:45:33 [TRACE] dag/walk: upstream of "output.elasticsearch_https_endpoint (expand)" errored, so skipping
2020/10/21 13:45:33 [TRACE] dag/walk: upstream of "output.elasticsearch_password (expand)" errored, so skipping
2020/10/21 13:45:33 [TRACE] dag/walk: upstream of "output.deployment_id (expand)" errored, so skipping
2020/10/21 13:45:33 [TRACE] dag/walk: upstream of "meta.count-boundary (EachMode fixup)" errored, so skipping
2020/10/21 13:45:33 [TRACE] dag/walk: upstream of "root" errored, so skipping
2020/10/21 13:45:33 [TRACE] statemgr.Filesystem: not making a backup, because the new snapshot is identical to the old
2020/10/21 13:45:33 [TRACE] statemgr.Filesystem: no state changes since last snapshot
2020/10/21 13:45:33 [TRACE] statemgr.Filesystem: writing snapshot at terraform.tfstate
2020/10/21 13:45:33 [TRACE] statemgr.Filesystem: removing lock metadata file .terraform.tfstate.lock.info
2020/10/21 13:45:33 [TRACE] statemgr.Filesystem: unlocking terraform.tfstate using fcntl flock
2020-10-21T13:45:33.803+0200 [DEBUG] plugin: plugin exited
!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!
Terraform crashed! This is always indicative of a bug within Terraform.
A crash log has been placed at "crash.log" relative to your current
working directory. It would be immensely helpful if you could please
report the crash with Terraform[1] so that we can fix this.
When reporting bugs, please include your terraform version. That
information is available on the first line of crash.log. You can also
get it by running 'terraform --version' on the command line.
SECURITY WARNING: the "crash.log" file that was created may contain 
sensitive information that must be redacted before it is safe to share 
on the issue tracker.
[1]: https://github.com/hashicorp/terraform/issues
!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

The underlying issue is this snippet:

  enterprise_search {
    topology {
      zone_count = 1
    }
  }

If I take it away, deployment goes through.

Looking at the template it seems enterprise search is missing in this one

ecctl deployment template list --region=us-east-1 --output json| jq '.[] | select(.id | contains("aws-cross-cluster-search-v2"))' | jq '.instance_configurations' | jq '.[].instance_type'
"elasticsearch"
"elasticsearch"
"kibana"

But the question here is more or less:
Should this result in a panic error?

user_settings_json field doesn't work as a string.

Expected Behavior

Users can set a both user_settings_json and user_settings_overrides_json.

Current Behavior

Currently, we're passing settings cfg.UserSettingsJSON and cfg.UserSettingsOverridesJSON both type interface{} as a string, which doesn't work when that field is actually set in the plan, it wasn't failing until now because there's no test case actually covering that field.

It's an interface to be able to accept a raw JSON, in which case it should be a map[string]interface{} which is set to the field.

Possible Solution

Use the wonderful json library.

ec_deployment_template: Add data source

Overview

Add a new ec_deployment_template datasource which returns a single deployment template.

data "ec_deployment_template" "default" {
  id     = "aws-io-optimized-v2"
  region = "us-east-1"
}

Possible Implementation

Possible search or GET criteria:

  • id: Really the only uniqueness factor.
  • name: could be used and then an error returned when more than 1 is returned.

Terraform Provider not supporting few ES Templates

The current version of terraform provider does not support creation of certain ES templates like CCS clusters.
The CCS clusters doesn't have an APM, Enterprise Search and App Search Resource.
The code currently checks them in the template API Response, code checks need to be handled in this case.

Readiness Checklist

  • I am running the latest version
  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been filed
  • I am reporting the issue to the correct repository (for multi-repository projects)

Expected Behavior

The CCS cluster should get created as per the template.

Current Behavior

Getting the following error when running the terraform resource

resource "ec_deployment" "defaults" {
  name                   = "ccs-cluster"
  region                 = "us-east-1"
  version                = "7.9.2"
  deployment_template_id = "aws-cross-cluster-search-v2"

  elasticsearch {
    topology {
      size = "1g"
    }
  }

  kibana {
    topology {
      size = "1g"
    }
  }
}

Possible Solution

Add nil checks for APM and Enterprise Resources in deployment template.

Steps to Reproduce

Run the terraform code provided above with the latest version of code.

Context

Unable to create CCS cluster

Your Environment

  • Version used: master
  • Environment name and version (e.g. Go 1.9): 1.13
  • Server type and version: Mac
  • Operating System and version: MacOS

ec_deployment_extension: Add new resource

Overview

Add a new ec_deployment_extension which allows users to upload and manage custom extensions.

Possible Implementation

resource "ec_deployment_extension" "name" {
    name = "name"
    file = "path"
   
}

Use matrix-style testing for multiple terraform versions

Overview

It would be great to ensure that our acceptance tests run for multiple versions of terraform.

At the moment this is handled automatically by the hashicorp/terraform-plugin-sdk

Possible Implementation

Check the documentation for Acceptance Testing:

ec_stack: Add data source

Overview

Add a new data resource called "ec_stack`, which would allow us to query settings from a specific
stack pack.

data "ec_stack" "latest" {
    version = "latest"
    lock    = true
}

Possible Implementation

Adding the ability to obtain the latest version by specifying version = "latest" would be desired as well as a lock boolean which allows the data resource to lock to a specific version once obtained.

Publishing EC Terraform Provider to https://registry.terraform.io/

Plan to publish EC Terraform Provider to terraform registry.

As with Terraform 0.13 release providers can be downloaded directly from terraform registry.
Publishing the provider there will get more community visibility.

Action items

  • Add goreleaser config and GitHub action to the project (#196).
  • Create a GitHub account to to release the provider on the Terraform Registry.
  • Create a GPG key to sign the release.
  • Add required secrets to GitHub secrets.
  • Push v0.1.0-beta
  • Publish the provider to the Terraform Registry.

ec_deployment/ec_deployment_traffic_filters not being re-created after resource id missing

In common terraform providers (mainly looked at the AWS one), when a resource is missing from the cloud provider, but exists in the tfstate files, that resource would be recreated upon re-applying the TF configuration, so that state is consistent.

The flow goes something like this:

  • terraform creates a resource (terraform apply was run)
  • Resource gets deleted in the cloud provider (manually, for example)
  • when terraform apply runs again, detects missing resource
  • terraform re-creates the resource

This is the case with our provider:

  • I terraform applied a deployment
  • deleted it in the cloud console manually
  • re-applying the configuration outputs this plan:
  # ec_deployment.example_minimal will be updated in-place
  ~ resource "ec_deployment" "example_minimal" {
        deployment_template_id = "aws-io-optimized-v2"
        elasticsearch_password = (sensitive value)
        elasticsearch_username = "elastic"
        id                     = "6c070ebed1c7166b9f287f76d2805889"
        name                   = "my_example_deployment"
        region                 = "us-east-1"
        traffic_filter         = [
            "2269062245fd430eb8d07d538a4255b7",
        ]
        version                = "7.9.2"

      + elasticsearch {
          + ref_id = "main-elasticsearch"

          + topology {
              + instance_configuration_id = "aws.data.highio.i3"
              + size                      = "8g"
              + size_resource             = "memory"
            }
        }

      + kibana {
          + elasticsearch_cluster_ref_id = "main-elasticsearch"
          + ref_id                       = "main-kibana"

          + topology {
              + instance_configuration_id = "aws.kibana.r5d"
              + size                      = "1g"
              + size_resource             = "memory"
            }
        }
    }

Plan: 0 to add, 1 to change, 0 to destroy.

I'm guessing this is due to the object still being available (in terms of ID) but in a shutoff state?
In any case, we should treat this case.

When re-applying the file, it says its modifying the resource, but nothing seems to happen.
cloud UI doesn't present the original deployment again.

resulting TF error after the second apply:
image

Seems this is also the case with ec_deployment_traffic_filters

Expected Behavior

Either the original deployment should be 'restored' (i.e, turned on) or be re-created if it's ID doesn't exist anymore.

Use case

The use case where fixing this behaviour would be super useful is with disaster recovery for ECE.
importing a deployment & its configuration, then recreating it in a different ECE environment since it's missing.

Run acceptance tests on every PR on Elastic CI

Overview

Currently, the integration tests aren't run on every pull request, while we publish what we run locally on a PR as a comment, it's not the most trustworthy method.

It would be preferable if the Acceptance tests were run on every PR via the Elastic CI.

ec_deployment: node_attributes removed when specifying an explicit topology

Expected Behavior

Changing some settings in the topology shouldn't remove settings from the definition.

Current Behavior

Going from a minified hot warm definition which contains node_attributes in the deployment template:

resource "ec_deployment" "example_minimal" {
  # Optional name.
  name = "horizon-hot-warm-test"

  # Mandatory fields
  region                 = "aws-eu-west-2"
  version                = "7.9.2"
  deployment_template_id = "aws-hot-warm-v2"

  elasticsearch {}

  kibana {}
}

to an explicit definition which changes the zone_count and size:

resource "ec_deployment" "example_minimal" {
  # Optional name.
  name = "horizon-hot-warm-test"

  # Mandatory fields
  region                 = "aws-eu-west-2"
  version                = "7.9.2"
  deployment_template_id = "aws-hot-warm-v2"

  elasticsearch {
    topology {
      instance_configuration_id = "aws.data.highio.i3"
      zone_count = 1
      memory_per_node = "1g"
    }
    topology {
      instance_configuration_id = "aws.data.highstorage.d2"
      zone_count = 1
      memory_per_node = "2g"
    }
  }

  kibana {}
}

Removes the node_attributes. The full error message is:

Plan change failed: [ClusterFailure:ClusterPrerequisiteValidationFailed]: Failed to validate cluster health/prerequisites. Please resolve each of the errors identified and retry. Caused by: [no.found.constructor.validation.ValidationException: 1. It is not possible to remove node attributes [data -> hot]]

And what was happening is that the node_attributes were being removed from the topology elements:

{
   "cluster_topology": [
     {
       "elasticsearch": {
-        "node_attributes": {
-          "data": "hot"
-        },
         "system_settings": {
           "auto_create_index": true,
           "destructive_requires_name": false,
           "enable_close_index": true,
           "http": {
             "compression": true,
             "cors_allow_credentials": false,
             "cors_enabled": false,
             "cors_max_age": 1728000
           },
           "monitoring_collection_interval": -1,
           "monitoring_history_duration": "3d",
           "reindex_whitelist": [],
           "scripting": {
             "inline": {
               "enabled": true
             },
             "stored": {
               "enabled": true
             }
           },
           "use_disk_threshold": true
         }
       },
       "instance_configuration_id": "aws.data.highio.i3",
       "node_type": {
         "data": true,
         "ingest": true,
         "master": true,
         "ml": false
       },
       "size": {
         "resource": "memory",
-        "value": 4096
+        "value": 1024
       },
-      "zone_count": 2
+      "zone_count": 1
     },
     {
       "elasticsearch": {
-        "node_attributes": {
-          "data": "warm"
-        },
         "system_settings": {
           "auto_create_index": true,
           "destructive_requires_name": false,
           "enable_close_index": true,
           "http": {
             "compression": true,
             "cors_allow_credentials": false,
             "cors_enabled": false,
             "cors_max_age": 1728000
           },
           "monitoring_collection_interval": -1,
           "monitoring_history_duration": "3d",
           "reindex_whitelist": [],
           "scripting": {
             "inline": {
               "enabled": true
             },
             "stored": {
               "enabled": true
             }
           },
           "use_disk_threshold": true
         }
       },
       "instance_configuration_id": "aws.data.highstorage.d2",
       "node_type": {
         "data": true,
         "ingest": true,
         "master": false,
         "ml": false
       },
       "size": {
         "resource": "memory",
-        "value": 4096
+        "value": 2048
       },
-      "zone_count": 2
+      "zone_count": 1
     },
   ],
   "deployment_template": {
     "id": "aws-hot-warm-v2"
   },
   "elasticsearch": {
     "curation": {
       "from_instance_configuration_id": "aws.data.highio.i3",
       "to_instance_configuration_id": "aws.data.highstorage.d2"
     },
     "version": "7.9.2"
   }
}

Introduced by #98

ec_deployment: Add apm_secret_token as top level field

Overview

Currently the APM secret_token is stored under ec_deployment<name>.apm.0.config.secret_token.
While this is fine, the ability to obtain secret_token through a GET /deployment/<id> might
change in the future, thus is better to parse the output of the create / update deployment and store
the value in a top level field named apm_secret_token.

Node Attributes Configuration is Missing in the provider

To Enable Hot Warm Architecture in Elastic Cloud, node attributes are to be assigned to nodes so as ILM policy can be applied to perform the required actions on the indices as per the ILM policy.

Update in the Provider configuration is required to add this functionality.

Benefit of having this change will enable support for Hot Warm architecture.

Write up a Contributing document

Overview

Write up a Contributing.md document to help users contribute to our Terraform provider more easily.

Possible Implementation

  • Structure
  • Acceptance Test writing
  • Test methodology (unit + acc)

Release timeline

Question

Is there a rough timeline for a first release of this provider available?

Any link or just a rough quarter would be nice to know. :)

TestAccDatasourceDeployment_basic isn't deterministic enough

Current Behavior

There are some cases where the data source acceptance test for ec_deployments fails, I believe it's because there some dangling resources in the development account which fulfilled the query, the error is:

=== CONT  TestAccDatasourceDeployment_basic
    datasource_deployment_basic_test.go:37: Step 2/2 error: Check failed: Check 7/10 error: data.ec_deployments.query: Attribute "deployments.0.elasticsearch_resource_id" not set, but "elasticsearch.0.resource_id" is set in ec_deployment.basic_datasource as "42087fdee82b4b1ead0fab53e37e5c81"

Expected Behavior

Should consistently pass.

Possible Solution

It'd be better to reference the existing deployment by name even if trimming the name as to provide a unique enough name_prefix.

ec_deployment: Test against legacy plans

Description

At this point, no testing has been performed against legacy deployments with legacy plans, some testing should be performed to ensure it works interchangeably with legacy and current plans.

Upgrade EC terraform provider to use latest sdk provider functions

Overview

Upgrade EC terraform provider to use latest SDKs provider functions introduced as part of SDK2 , which adds diagnosis capabilities during provider initialisation.

Possible Implementation

Refactor the provider code according to the new SDK schema.

Testing

the provider works as per the current implementation.

Context

Using the latest features provided by the sdk2 kit of terrafom.

Your Environment

Mac OS-X
Golang version 1.14.6

acceptance: Tests fail with errors unrelated to TF provider

Description

Currently acceptance tests can sometimes fail when there are errors
unrelated to the terraform provider.

For example, if a deployment is unhealthy (unassigned shard or whatever),
or the deployment failed to delete (which only issues a warning), etc, the tests will fail.

It seems to me that it would probably make sense to either log these errors somehow,
or not take these errors into account at all as they can provide false positives.

ec_deployment: Make instance_configuration_id optional

Overview

Both the deployment_template_id and topology.instance_configuration_id are required, but in fact, we can automatically obtain the topology.instance_configuration_id by reading the deployment_template.

This is going to make getting started much easier and less confusing.

Good safeguards should be put in place which return an error when there's more than one topology element and instance_configuration_id is missing, but the API validation would already return that error.

Possible Implementation

ec_deployment: Add data source

Description

Implement a data resource which allows the user to search deployments, and retrieve a result.

The deployment API has the Search API available which uses models.SearchRequest and contains a models.QueryContainer, giving the user A LOT of options and queries.

I wonder if we should have a simple and an advanced querying mechanism, with simplified queries for users.

data "ec_deployment" "example" {
  # Based on models.QueryContainer
  query {
    nested {
      path = "plan_info.current.plan.cluster_topology"
      query {
        bool {
        }
      }
    }
  }
}

Reference

I believe the aws_iam_policy_document is a good resource for inspiration: https://www.terraform.io/docs/providers/aws/d/iam_policy_document.html

Terraform data resource reference

https://www.terraform.io/docs/configuration/data-sources.html

ec_deployment: Make acceptance test fields dynamic

Description

Currently the acceptance tests for ec_deployment uses hardcoded fields like:

  • version (7.6.2)
  • region (us-east-1)
  • deployment_template_id (aws-io-optimized) and their instance configurations, Elasticsearch, Kibana and APM.

It would be best to make these parameters more dynamic depending on which region the tests are run in, and if run against an ECE environment should also work.

ec_deployment: Elasticsearch snapshot_settings management

Description

Currently, the ec_deployment resource has an elasticsearch.snapshot_settings object which can be used to manage the Elasticsearch snapshot settings for a given deployment.

The snapshot settings management is currently not implemented and when doing so, it should be done with care.

Managing the default ESS repository

When a Deployment lives in ESS, it automatically has an assigned S3 repository for the Elasticsearch resource of the deployment.
The configuration is readable when the remote resource is read and the state is saved, so we'd have to be careful not to remove the default repository information when managing the snapshot settings or always incur a state change when no settings are configured and the cluster has the default snapshot repository assigned.

Managing repository settings in ECE

When a Deployment is created in ECE, managing the snapshot settings is more straightforward than in SaaS, however it should be tested there too.

Add verbose_credentials parameter to provider

Overview

By default, the request.log of terraform should redact the APIKey and Authorization headers. To enable this and also enable un-redacting it and dumping the credentials in the file, a verbose_credentials attribute should be added to the provided to allow this.

Possible Implementation

new verbose_credentials boolean which should map to the EC_VERBOSE_CREDENTIALS environment variable.

ec_deployment: Add settings object to AppSearch resource

Description

Currently, there's no way of managing an Apm resource settings, this is not desirable as users might want to control which settings their Apm deployment resources have set.

There's quite a lot of fields and sub-objects to implement, so this might take some time to implement.

Improve package structure

Description

We are exporting several functions that should not be. We should flatten the structure a bit in order to tighten the scope. The only functions that should be exported for each datasource/resource are Datasource() and Resource().

ec_deployment panics when using certain Deployment Templates

Expected Behavior

ec_deployment should work with all deployment templates.

Current Behavior

Introduced by #98

It panics on templates which are missing apm or enterprise_search resources in the deployment template.

Possible Solution

Return a default *models.<kind>Payload.

ec_deployment_traffic_filter_association: Add resource

Overview

Add a new ec_deployment_traffic_filter_association which allows attaching a deployment to a traffic filter rule without the need to manage the Elasticsearch deployment in Terraform.

Possible Implementation

resource "ec_deployment_traffic_filter_association" "default" {
    deployment_id     = "0bdac90a9b2b416dbf7b6dd1001c9339"
    traffic_filter_id = "a28f0ca168da873ed6da7647a9bcd5ff"
}

ec_deployment: Add settings object to elasticsearch resource

Description

Currently, there's no way of managing an Elasticsearch resource settings, this is not desirable as users might want to control which settings their Elasticsearch deployment resources have set.

There's quite a lot of fields and sub-objects to implement, so this might take some time to implement.

Example deployment not working with Trial account and eu-central-1 region

Readiness Checklist

  • I am running the latest version
  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been filed
  • I am reporting the issue to the correct repository (for multi-repository projects)

Expected Behavior

Should deploy example deployment.

Current Behavior

When applying terraform with changed region to "eu-central-1" it's failing with this error:
Error: failed creating deployment: 2 errors occurred: * api error: clusters.cluster_invalid_plan: Instance configuration [aws.data.highio.i3] does not exist or is not available to you. The instance configuration must be one of the available configurations. Use the Instance Configuration API to get a list of available configurations. (resources.elasticsearch[0].cluster_topology[0].instance_configuration_id) * set "request_id" to "aen40sa8eww7wotfyd1wr9rbfkt4dmjr6hfzkawxxxxxxxxxxxxxxxxxxx" to recreate the deployment resources

Deployment works with us-east-1 (default) and also works with eu-central-1 in the Elastic Cloud UI, just not in terraform.

Steps to Reproduce

  1. Create new account on elastic cloud
  2. Create API key in Account settings
  3. Download terraform provider and example
  4. Change region to eu-central-1
  5. terraform apply

Your Environment

  • Version used: latest
  • Environment name and version (e.g. Go 1.9): Go 1.15
  • Operating System and version: macOS Catalina

ec_deployment: Add support for traffic filtering

Overview

I would like support for IP traffic filters.

Possible Implementation

We would need a new resource "ec_ip_traffic_filter". Next to that, we can have an optional field in "ec_deployment" that can point to a resource of type "ec_ip_traffic_filter".

We will also need a data source "ec_ip_traffic_filter" for when the filter is created externally, and you want to associate a deployment with that filter.

Context

I have Azure Web applications that need to connect to ES (hosted in EC). Ideally I can dynamically add the x-amount of outbound IP adresses to the the Elasticsearch deployment.

I currently use the same technique to add whitelist entries to MongoDB Atlas projects

Your Environment

We have different deployments for different environments (dev/staging/prod). I would like to add a different ruleset to each deployment.

When changing the filter, I don't want any connection downtime (I have not tested this yet without Terraform as this is quite a new feature.

ec_deployment: Allow users to reset the Elasticsearch password

Overview

To help support cases where the user might have either imported the deployment or changed the password independently, and terraform doesn't have an elasticsearch_password or it's outdated, it would be good to allow users to reset their Elasticsearch password by setting a field boolean field to true.

The endpoint is at /deployments/{deployment_id}/elasticsearch/{ref_id}/_reset-password.

Possible Implementation

Creating a field reset_elasticseach_password of type Bool, where setting the field will reset the Elasticsearch credentials.

ec_deployment: Support Cross Cluster Search settings

Overview

Currently, there's no way users can configure the cross cluster search settings in their deployments, it would be great to allow them to do so.

Possible Implementation

Adding a new remote_cluster block which allows users to set one or more remote clusters.

resource "ec_deployment" "source_deployment" {
  name = "my_source_ccs"

  region                 = "us-east-1"
  version                = "7.9.2"
  deployment_template_id = "aws-io-optimized-v2"

  elasticsearch {}

  kibana {}

  apm {}
}

resource "ec_deployment" "ccs" {
  name = "ccs deployment"

  region                 = "us-east-1"
  version                = "7.9.2"
  deployment_template_id = "aws-cross-cluster-search-v2"

  elasticsearch {
    remote_cluster {
      deployment_id = ec_deployment.source_deployment.id

      # Remote deployment's elasticsearch ref_id (Optional) defaults to "main-elasticsearch"
      ref_id = "main-elasticsearch"

      # If true, skip this cluster during search if it is disconnected
      skip_unavailable = false

      # The alias for this remote cluster. Aliases must only contain letters, digits, dashes and underscores
      alias = "some alias"
    }
  }

  kibana {}
}

Testing

An acceptance test or two wouldn't be bad.

Context

Similar to what the UI allows:

image

ec_deployment: Add settings object to apm resource

Description

Currently, there's no way of managing an Apm resource settings, this is not desirable as users might want to control which settings their Apm deployment resources have set.

There's quite a lot of fields and sub-objects to implement, so this might take some time to implement.

ec_deployment: Add acceptance tests for all deployment templates

Overview

We should have at least 1 acceptance test per deployment template where the most common templates and use cases are tested to ensure the provider logic is solid and bug-free.

Stack Test Cases

  • IO Optimized
  • Hot / Warm
  • Compute Optimized
  • Memory Optimized
  • Cross Cluster Search

Solution Test Cases

  • Enterprise Search
  • Elastic Observability
  • Elastic Security

Document "ec_deployment" resource fields and sub-fields

Description

Currently the "ec_deployment" resource doesn't all its documentation populated. We need to document:

  • Complete resource documentation
  • Determine if Example is good enough or needs more configuration settings set.
  • Argument reference, complete the list of accepted "parameters"
  • Attribute Reference, the attributes which other resources might want to reference.

Add monitoring via log delivery APIs

Overview

Add monitoring object which uses the "log delivery" mechanism.

Possible Implementation

Use the new Log delivery APIs available after MS46 is deployed.

ec_deployment: Add Importer

Description

Ideally, we'd like to be able to import existing Elastic Cloud deployments into a locally managed terraform ec_deployment resource. To do so, an Importer function must be written and assigned to ec_deployment resource.

It should be a safe importer and perform no changes on the resource when imported.

Terraform command

$ terraform import ec_deployment.imported 320b7b540dfc967a7a649c18e2fce4ed

ec_deployment: Add settings object to kibana resource

Description

Currently, there's no way of managing an Kibana resource settings, this is not desirable as users might want to control which settings their Kibana deployment resources have set.

There's quite a lot of fields and sub-objects to implement, so this might take some time to implement.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.