Skip to content

Commit

Permalink
[WIP] Upgrade to Elasticsearch 8.4.1 (#15)
Browse files Browse the repository at this point in the history
* fix: migrate to es-handler instead to wrap all api call. Fix so many little bugs.

Signed-off-by: langoureaux-s <[email protected]>

* feat: upgrade do elasticsearch 8.4.1 and add golangci-lint step

Signed-off-by: langoureaux-s <[email protected]>

* fix: Add acctest form elasticsearch_data_stream ressource

Signed-off-by: langoureaux-s <[email protected]>

* fix: Add forget tests and documentation

Signed-off-by: langoureaux-s <[email protected]>

* fix: fix github workflow

Signed-off-by: langoureaux-s <[email protected]>

* fix: bump to es-handler 8.0.2

Signed-off-by: langoureaux-s <[email protected]>

Signed-off-by: langoureaux-s <[email protected]>
Co-authored-by: langoureaux-s <[email protected]>
  • Loading branch information
disaster37 and langoureaux-s authored Sep 16, 2022
1 parent dd57f51 commit b122f51
Show file tree
Hide file tree
Showing 53 changed files with 1,707 additions and 2,278 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,24 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: "1.17"
go-version: "1.18"
- name: Setup Elasticsearch
run: |
set -e
docker-compose up &
until $(curl --output /dev/null --silent --head --fail -u elastic:changeme http://localhost:9200); do sleep 5; done
curl -XPOST -u elastic:changeme http://localhost:9200/_license/start_trial?acknowledge=true
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
args: --timeout 600s
- name: Run build
run: make build
- name: Run acceptance tests
run: ELASTICSEARCH_URLS="http://localhost:9200" ELASTICSEARCH_USERNAME="elastic" ELASTICSEARCH_PASSWORD="changeme" make testacc
run: |
mv es/resource_elasticsearch_license_test.go es/resource_elasticsearch_license_test.go.disable
ELASTICSEARCH_URLS="http://localhost:9200" ELASTICSEARCH_USERNAME="elastic" ELASTICSEARCH_PASSWORD="changeme" make testacc
- name: Run acceptance test on license resource
run: |
set -e
Expand All @@ -58,7 +65,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: 1.18
- name: Import GPG key
id: import_gpg
uses: paultyng/[email protected]
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ gen:
rm -f aws/internal/keyvaluetags/*_gen.go
go generate ./...

test: fmtcheck
test: fmt fmtcheck
go test $(TEST) -timeout=30s -parallel=4

testacc: fmt fmtcheck
Expand Down Expand Up @@ -93,7 +93,7 @@ trial-license:
curl -XPOST -u ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD} ${ELASTICSEARCH_URLS}/_license/start_trial?acknowledge=true

start-pods: clean-pods
kubectl run elasticsearch --image docker.elastic.co/elasticsearch/elasticsearch:8.0.1 --port "9200" --expose --env "cluster.name=test" --env "discovery.type=single-node" --env "ELASTIC_PASSWORD=changeme" --env "xpack.security.enabled=true" --env "ES_JAVA_OPTS=-Xms512m -Xmx512m" --env "path.repo=/tmp" --limits "cpu=500m,memory=1024Mi"
kubectl run elasticsearch --image docker.elastic.co/elasticsearch/elasticsearch:8.4.1 --port "9200" --expose --env "cluster.name=test" --env "discovery.type=single-node" --env "ELASTIC_PASSWORD=changeme" --env "xpack.security.enabled=true" --env "ES_JAVA_OPTS=-Xms512m -Xmx512m" --env "path.repo=/tmp" --limits "cpu=500m,memory=1024Mi"
echo "Waiting for Elasticsearch availability"
until curl -s http://elasticsearch:9200 | grep -q 'missing authentication credentials'; do sleep 30; done;
echo "Enable trial license"
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3"

services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.0.1
image: docker.elastic.co/elasticsearch/elasticsearch:8.4.1
hostname: elasticsearch
environment:
cluster.name: test
Expand Down
3 changes: 3 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,6 @@ provider "elasticsearch" {
- [elasticsearch_snapshot_repository](resources/elasticsearch_snapshot_repository.md)
- [elasticsearch_snapshot_lifecycle_policy](resources/elasticsearch_snapshot_lifecycle_policy.md)
- [elasticsearch_watcher](resources/elasticsearch_watcher.md)
- [elasticsearch_data_stream](resources/elasticsearch_data_stream.md)
- [elasticsearch_ingest_pipeline](resources/elasticsearch_ingest_pipeline.md)
- [elasticsearch_transform](resources/elasticsearch_transform.md)
28 changes: 28 additions & 0 deletions docs/resources/elasticsearch_data_stream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# elasticsearch_data_stream

This resource permit to manage the index data stream in Elasticsearch.
You can see the API documentation: https://www.elastic.co/guide/en/elasticsearch/reference/current/data-stream-apis.html

***Supported Elasticsearch version:***
- v8

## Example Usage

It will create data stream index.

> You need to have index template with `data_sream` that match your index before to create data stream index.
```tf
resource elasticsearch_data_stream "test" {
name = "terraform-test"
}
```

## Argument Reference

***The following arguments are supported:***
- **name**: (required) The data stream index name.

## Attribute Reference

NA
1 change: 1 addition & 0 deletions docs/resources/elasticsearch_index_component_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ You can see the API documentation: https://www.elastic.co/guide/en/elasticsearch

***Supported Elasticsearch version:***
- v7
- v8

## Example Usage

Expand Down
1 change: 1 addition & 0 deletions docs/resources/elasticsearch_index_lifecycle_policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ You can see the API documentation: https://www.elastic.co/guide/en/elasticsearch
***Supported Elasticsearch version:***
- v6
- v7
- v8

## Example Usage

Expand Down
1 change: 1 addition & 0 deletions docs/resources/elasticsearch_index_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ You can see the API documentation: https://www.elastic.co/guide/en/elasticsearch

***Supported Elasticsearch version:***
- v7
- v8

## Example Usage

Expand Down
1 change: 1 addition & 0 deletions docs/resources/elasticsearch_index_template_legacy.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ You can see the API documentation: https://www.elastic.co/guide/en/elasticsearch
***Supported Elasticsearch version:***
- v6
- v7
- v8

## Example Usage

Expand Down
41 changes: 41 additions & 0 deletions docs/resources/elasticsearch_ingest_pipeline.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# elasticsearch_ingest_pipeline Resource Source

This resource permit to manage the ingest pipeline in Elasticsearch.
You can see the API documentation: https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest-apis.html

***Supported Elasticsearch version:***
- v8

## Example Usage

It will create ingest pipeline.

```tf
resource elasticsearch_ingest_pipeline "test" {
name = "terraform-test"
pipeline = <<EOF
{
"description" : "My optional pipeline description",
"processors" : [
{
"set" : {
"description" : "My optional processor description",
"field": "my-keyword-field",
"value": "foo"
}
}
]
}
EOF
}
```

## Argument Reference

***The following arguments are supported:***
- **name**: (required) Identifier for the ingest pipeline.
- **pipeline**: (required) The pipeline specification. It's a string as JSON object.

## Attribute Reference

NA
1 change: 1 addition & 0 deletions docs/resources/elasticsearch_license.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ You can see the API documentation: https://www.elastic.co/guide/en/elasticsearch
***Supported Elasticsearch version:***
- v6
- v7
- v8

## Example Usage

Expand Down
1 change: 1 addition & 0 deletions docs/resources/elasticsearch_role.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ You can see the API documentation: https://www.elastic.co/guide/en/elasticsearch
***Supported Elasticsearch version:***
- v6
- v7
- v8

## Example Usage

Expand Down
1 change: 1 addition & 0 deletions docs/resources/elasticsearch_role_mapping.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ You can see the API documentation: https://www.elastic.co/guide/en/elasticsearch
***Supported Elasticsearch version:***
- v6
- v7
- v8

## Example Usage

Expand Down
1 change: 1 addition & 0 deletions docs/resources/elasticsearch_snapshot_lifecycle_policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ You can see the API documentation: https://www.elastic.co/guide/en/elasticsearch

***Supported Elasticsearch version:***
- v7
- v8

## Example Usage

Expand Down
1 change: 1 addition & 0 deletions docs/resources/elasticsearch_snapshot_repository.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ You can see the API documentation: https://www.elastic.co/guide/en/elasticsearch
***Supported Elasticsearch version:***
- v6
- v7
- v8

## Example Usage

Expand Down
74 changes: 74 additions & 0 deletions docs/resources/elasticsearch_transform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# elasticsearch_transform Resource Source

This resource permit to manage the transform in Elasticsearch.
You can see the API documentation: https://www.elastic.co/guide/en/elasticsearch/reference/current/transform-apis.html

***Supported Elasticsearch version:***
- v8

## Example Usage

It will create transform.

```tf
resource "elasticsearch_transform" "test" {
name = "terraform-test-transform"
transform = <<EOF
{
"source": {
"index": ["ecs-*"],
"query": {
"term": {
"geoip.continent_name": {
"value": "Asia"
}
}
}
},
"pivot": {
"group_by": {
"customer_id": {
"terms": {
"field": "customer_id"
}
}
},
"aggregations": {
"max_price": {
"max": {
"field": "taxful_total_price"
}
}
}
},
"description": "Maximum priced ecommerce data by customer_id in Asia",
"dest": {
"index": "kibana_sample_data_ecommerce_transform1"
},
"frequency": "5m",
"sync": {
"time": {
"field": "order_date",
"delay": "60s"
}
},
"retention_policy": {
"time": {
"field": "order_date",
"max_age": "30d"
}
}
}
EOF
}
```

## Argument Reference

***The following arguments are supported:***
- **name**: (required) Identifier for the transform.
- **transform**: (required) The transform specification. It's a string as JSON object.

## Attribute Reference

NA
1 change: 1 addition & 0 deletions docs/resources/elasticsearch_user.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ You can see the API documenation: https://www.elastic.co/guide/en/elasticsearch/
***Supported Elasticsearch version:***
- v6
- v7
- v8

## Example Usage

Expand Down
1 change: 1 addition & 0 deletions docs/resources/elasticsearch_watcher.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ You can see the API documentation: https://www.elastic.co/guide/en/elasticsearch
***Supported Elasticsearch version:***
- v6
- v7
- v8

## Example Usage

Expand Down
Loading

0 comments on commit b122f51

Please sign in to comment.