Skip to content

Commit

Permalink
Switch to protocol 6 (elastic#451)
Browse files Browse the repository at this point in the history
* Switch to protocol 6
* Update Stack version to 8.10.3
  • Loading branch information
dimuon authored and daemitus committed Nov 30, 2023
1 parent 07f12c2 commit 0d2eed2
Show file tree
Hide file tree
Showing 88 changed files with 210 additions and 144 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
- '8.7.1'
- '8.8.2'
- '8.9.2'
- '8.10.2'
- '8.10.3'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## [Unreleased]

### Added
- Switch to Terraform [protocol version 6](https://developer.hashicorp.com/terraform/plugin/terraform-plugin-protocol#protocol-version-6) that is compatible with Terraform CLI version 1.0 and later.

## [0.10.0] - 2023-11-02

### Added
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ SWAGGER_VERSION ?= 8.7

GOVERSION ?= 1.20

STACK_VERSION ?= 8.9.0
STACK_VERSION ?= 8.10.3

ELASTICSEARCH_NAME ?= terraform-elasticstack-es
ELASTICSEARCH_ENDPOINTS ?= http://$(ELASTICSEARCH_NAME):9200
Expand Down
20 changes: 15 additions & 5 deletions docs/guides/elasticstack-and-cloud.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,13 @@ resource "ec_deployment" "monitoring" {
version = data.ec_stack.latest.version
deployment_template_id = var.deployment_template_id
elasticsearch {}
kibana {}
elasticsearch = {
hot = {
autoscaling = {}
}
}
kibana = {}
}
resource "ec_deployment" "cluster" {
Expand All @@ -64,13 +69,18 @@ resource "ec_deployment" "cluster" {
version = data.ec_stack.latest.version
deployment_template_id = var.deployment_template_id
observability {
observability = {
deployment_id = ec_deployment.monitoring.id
ref_id = ec_deployment.monitoring.elasticsearch[0].ref_id
}
elasticsearch {}
kibana {}
elasticsearch = {
hot = {
autoscaling = {}
}
}
kibana = {}
}
provider "elasticstack" {
Expand Down
21 changes: 21 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The Elasticstack provider provides the resources to interact with Elastic stack
It is recommended to setup at least minimum security, https://www.elastic.co/guide/en/elasticsearch/reference/current/security-minimal-setup.html
in order to interact with the Elasticsearch and be able to use the provider's full capabilities

The provider uses Terraform [protocol version 6](https://developer.hashicorp.com/terraform/plugin/terraform-plugin-protocol#protocol-version-6) that is compatible with Terraform CLI version 1.0 and later.

## Authentication

Expand All @@ -31,6 +32,16 @@ The following methods are supported:
Default static credentials can be provided by adding the `username`, `password` and `endpoints` in the `elasticsearch` block:

```terraform
terraform {
required_version = ">= 1.0.0"
required_providers {
elasticstack = {
source = "elastic/elasticstack"
version = "~>0.9"
}
}
}
provider "elasticstack" {
elasticsearch {
username = "elastic"
Expand Down Expand Up @@ -104,6 +115,16 @@ See docs related to the specific resources.
## Example Usage

```terraform
terraform {
required_version = ">= 1.0.0"
required_providers {
elasticstack = {
source = "elastic/elasticstack"
version = "~>0.9"
}
}
}
provider "elasticstack" {
elasticsearch {
username = "elastic"
Expand Down
20 changes: 15 additions & 5 deletions examples/cloud/deployment.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ resource "ec_deployment" "monitoring" {
version = data.ec_stack.latest.version
deployment_template_id = var.deployment_template_id

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

kibana = {}
}

resource "ec_deployment" "cluster" {
Expand All @@ -21,13 +26,18 @@ resource "ec_deployment" "cluster" {
version = data.ec_stack.latest.version
deployment_template_id = var.deployment_template_id

observability {
observability = {
deployment_id = ec_deployment.monitoring.id
ref_id = ec_deployment.monitoring.elasticsearch[0].ref_id
}

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

kibana = {}
}

provider "elasticstack" {
Expand Down
10 changes: 10 additions & 0 deletions examples/provider/provider.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
terraform {
required_version = ">= 1.0.0"
required_providers {
elasticstack = {
source = "elastic/elasticstack"
version = "~>0.9"
}
}
}

provider "elasticstack" {
elasticsearch {
username = "elastic"
Expand Down
10 changes: 5 additions & 5 deletions internal/acctest/acctest.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ import (
"testing"

"github.com/elastic/terraform-provider-elasticstack/provider"
"github.com/hashicorp/terraform-plugin-go/tfprotov5"
"github.com/hashicorp/terraform-plugin-go/tfprotov6"
)

var Providers map[string]func() (tfprotov5.ProviderServer, error)
var Providers map[string]func() (tfprotov6.ProviderServer, error)

func init() {
providerServerFactory, err := provider.ProtoV5ProviderServerFactory(context.Background(), "dev")
providerServerFactory, err := provider.ProtoV6ProviderServerFactory(context.Background(), "dev")
if err != nil {
log.Fatal(err)
}
Providers = map[string]func() (tfprotov5.ProviderServer, error){
"elasticstack": func() (tfprotov5.ProviderServer, error) {
Providers = map[string]func() (tfprotov6.ProviderServer, error){
"elasticstack": func() (tfprotov6.ProviderServer, error) {
return providerServerFactory(), nil
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
func TestAccDataSourceClusterInfo(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
ProtoV5ProviderFactories: acctest.Providers,
ProtoV6ProviderFactories: acctest.Providers,
Steps: []resource.TestStep{
{
Config: testAccDataSourceSecurityUser,
Expand Down
4 changes: 2 additions & 2 deletions internal/elasticsearch/cluster/script_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestAccResourceScript(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
CheckDestroy: checkScriptDestroy,
ProtoV5ProviderFactories: acctest.Providers,
ProtoV6ProviderFactories: acctest.Providers,
Steps: []resource.TestStep{
{
Config: testAccScriptCreate(scriptID),
Expand Down Expand Up @@ -47,7 +47,7 @@ func TestAccResourceScriptSearchTemplate(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
CheckDestroy: checkScriptDestroy,
ProtoV5ProviderFactories: acctest.Providers,
ProtoV6ProviderFactories: acctest.Providers,
Steps: []resource.TestStep{
{
Config: testAccSearchTemplateCreate(scriptID),
Expand Down
2 changes: 1 addition & 1 deletion internal/elasticsearch/cluster/settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestAccResourceClusterSettings(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
CheckDestroy: checkResourceClusterSettingsDestroy,
ProtoV5ProviderFactories: acctest.Providers,
ProtoV6ProviderFactories: acctest.Providers,
Steps: []resource.TestStep{
{
Config: testAccResourceClusterSettingsCreate(),
Expand Down
2 changes: 1 addition & 1 deletion internal/elasticsearch/cluster/slm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestAccResourceSLM(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
CheckDestroy: checkSlmDestroy(name),
ProtoV5ProviderFactories: acctest.Providers,
ProtoV6ProviderFactories: acctest.Providers,
Steps: []resource.TestStep{
{
Config: testAccSlmCreate(name),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func TestAccDataSourceSnapRepoFs(t *testing.T) {

resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
ProtoV5ProviderFactories: acctest.Providers,
ProtoV6ProviderFactories: acctest.Providers,
Steps: []resource.TestStep{
{
Config: testAccDataSourceSnapRepoFs(name),
Expand Down Expand Up @@ -59,7 +59,7 @@ func TestAccDataSourceSnapRepoUrl(t *testing.T) {

resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
ProtoV5ProviderFactories: acctest.Providers,
ProtoV6ProviderFactories: acctest.Providers,
Steps: []resource.TestStep{
{
Config: testAccDataSourceSnapRepoUrl(name),
Expand Down
4 changes: 2 additions & 2 deletions internal/elasticsearch/cluster/snapshot_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestAccResourceSnapRepoFs(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
CheckDestroy: checkRepoDestroy(name),
ProtoV5ProviderFactories: acctest.Providers,
ProtoV6ProviderFactories: acctest.Providers,
Steps: []resource.TestStep{
{
Config: testAccRepoFsCreate(name),
Expand Down Expand Up @@ -51,7 +51,7 @@ func TestAccResourceSnapRepoUrl(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
CheckDestroy: checkRepoDestroy(name),
ProtoV5ProviderFactories: acctest.Providers,
ProtoV6ProviderFactories: acctest.Providers,
Steps: []resource.TestStep{
{
Config: testAccRepoUrlCreate(name),
Expand Down
2 changes: 1 addition & 1 deletion internal/elasticsearch/enrich/policy_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func TestAccDataSourceEnrichPolicy(t *testing.T) {
name := sdkacctest.RandStringFromCharSet(10, sdkacctest.CharSetAlphaNum)
resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
ProtoV5ProviderFactories: acctest.Providers,
ProtoV6ProviderFactories: acctest.Providers,
Steps: []resource.TestStep{
{
Config: testAccEnrichPolicyDataSource(name),
Expand Down
2 changes: 1 addition & 1 deletion internal/elasticsearch/enrich/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestAccResourceEnrichPolicy(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
CheckDestroy: checkEnrichPolicyDestroy(name),
ProtoV5ProviderFactories: acctest.Providers,
ProtoV6ProviderFactories: acctest.Providers,
Steps: []resource.TestStep{
{
Config: testAccEnrichPolicy(name),
Expand Down
2 changes: 1 addition & 1 deletion internal/elasticsearch/index/component_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestAccResourceComponentTemplate(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
CheckDestroy: checkResourceComponentTemplateDestroy,
ProtoV5ProviderFactories: acctest.Providers,
ProtoV6ProviderFactories: acctest.Providers,
Steps: []resource.TestStep{
{
Config: testAccResourceComponentTemplateCreate(templateName),
Expand Down
2 changes: 1 addition & 1 deletion internal/elasticsearch/index/data_stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestAccResourceDataStream(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
CheckDestroy: checkResourceDataStreamDestroy,
ProtoV5ProviderFactories: acctest.Providers,
ProtoV6ProviderFactories: acctest.Providers,
Steps: []resource.TestStep{
{
Config: testAccResourceDataStreamCreate(dsName),
Expand Down
4 changes: 2 additions & 2 deletions internal/elasticsearch/index/ilm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestAccResourceILM(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
CheckDestroy: checkResourceILMDestroy,
ProtoV5ProviderFactories: acctest.Providers,
ProtoV6ProviderFactories: acctest.Providers,
Steps: []resource.TestStep{
{
Config: testAccResourceILMCreate(policyName),
Expand Down Expand Up @@ -86,7 +86,7 @@ func TestAccResourceILMRolloverConditions(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
CheckDestroy: checkResourceILMDestroy,
ProtoV5ProviderFactories: acctest.Providers,
ProtoV6ProviderFactories: acctest.Providers,
Steps: []resource.TestStep{
{
SkipFunc: versionutils.CheckIfVersionIsUnsupported(index.RolloverMinConditionsMinSupportedVersion),
Expand Down
10 changes: 5 additions & 5 deletions internal/elasticsearch/index/index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestAccResourceIndex(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
CheckDestroy: checkResourceIndexDestroy,
ProtoV5ProviderFactories: acctest.Providers,
ProtoV6ProviderFactories: acctest.Providers,
Steps: []resource.TestStep{
{
Config: testAccResourceIndexCreate(indexName),
Expand Down Expand Up @@ -58,7 +58,7 @@ func TestAccResourceIndexSettings(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
CheckDestroy: checkResourceIndexDestroy,
ProtoV5ProviderFactories: acctest.Providers,
ProtoV6ProviderFactories: acctest.Providers,
Steps: []resource.TestStep{
{
Config: testAccResourceIndexSettingsCreate(indexName),
Expand Down Expand Up @@ -109,7 +109,7 @@ func TestAccResourceIndexSettingsMigration(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
CheckDestroy: checkResourceIndexDestroy,
ProtoV5ProviderFactories: acctest.Providers,
ProtoV6ProviderFactories: acctest.Providers,
Steps: []resource.TestStep{
{
Config: testAccResourceIndexSettingsMigrationCreate(indexName),
Expand Down Expand Up @@ -138,7 +138,7 @@ func TestAccResourceIndexSettingsConflict(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
CheckDestroy: checkResourceIndexDestroy,
ProtoV5ProviderFactories: acctest.Providers,
ProtoV6ProviderFactories: acctest.Providers,
Steps: []resource.TestStep{
{
Config: testAccResourceIndexSettingsConflict(indexName),
Expand All @@ -154,7 +154,7 @@ func TestAccResourceIndexRemovingField(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
CheckDestroy: checkResourceIndexDestroy,
ProtoV5ProviderFactories: acctest.Providers,
ProtoV6ProviderFactories: acctest.Providers,
Steps: []resource.TestStep{
// Confirm removing field doesn't produce recreate by using prevent_destroy
{Config: testAccResourceIndexRemovingFieldCreate(indexName)},
Expand Down
2 changes: 1 addition & 1 deletion internal/elasticsearch/index/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestAccResourceIndexTemplate(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
CheckDestroy: checkResourceIndexTemplateDestroy,
ProtoV5ProviderFactories: acctest.Providers,
ProtoV6ProviderFactories: acctest.Providers,
Steps: []resource.TestStep{
{
Config: testAccResourceIndexTemplateCreate(templateName),
Expand Down
2 changes: 1 addition & 1 deletion internal/elasticsearch/ingest/pipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestAccResourceIngestPipeline(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
CheckDestroy: checkResourceIngestPipelineDestroy,
ProtoV5ProviderFactories: acctest.Providers,
ProtoV6ProviderFactories: acctest.Providers,
Steps: []resource.TestStep{
{
Config: testAccResourceIngestPipelineCreate(pipelineName),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
func TestAccDataSourceIngestProcessorAppend(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
ProtoV5ProviderFactories: acctest.Providers,
ProtoV6ProviderFactories: acctest.Providers,
Steps: []resource.TestStep{
{
Config: testAccDataSourceIngestProcessorAppend,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
func TestAccDataSourceIngestProcessorBytes(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
ProtoV5ProviderFactories: acctest.Providers,
ProtoV6ProviderFactories: acctest.Providers,
Steps: []resource.TestStep{
{
Config: testAccDataSourceIngestProcessorBytes,
Expand Down
Loading

0 comments on commit 0d2eed2

Please sign in to comment.