Skip to content

Commit 403c5d5

Browse files
committed
Merge remote-tracking branch 'origin/main' into 667-fleet-data-tags
* origin/main: fix package policy secrets (#821) chore(deps): update codecov/codecov-action digest to b9fd7d1 (#815) Bump release memory Switch to golang 1.23.2 in release Bump release memory Prepare release v0.11.8 (#810) Add key_id as an explicit attribute (#789) standalone-output resource (#811) Add URL support to data_view field_formats (#812) migrate fleet integration_policy to framework, fix secret churn (#797) Allow mappings to be unknown to support mappings defined in index templates (#803)
2 parents bf587f0 + c878dd8 commit 403c5d5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2780
-1429
lines changed

.buildkite/release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
steps:
22
- label: Release
33
agents:
4-
image: "golang:1.23.1@sha256:4f063a24d429510e512cc730c3330292ff49f3ade3ae79bda8f84a24fa25ecb0"
4+
image: "golang:1.23.2@sha256:adee809c2d0009a4199a11a1b2618990b244c6515149fe609e2788ddf164bd10"
55
cpu: "8"
6-
memory: "8G"
6+
memory: "16G"
77
command:
88
- ".buildkite/scripts/release.sh"

.github/workflows/test.yml

+28-6
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ jobs:
6363
xpack.security.enabled: true
6464
xpack.security.authc.api_key.enabled: true
6565
xpack.security.authc.token.enabled: true
66-
xpack.security.http.ssl.enabled: false
6766
xpack.watcher.enabled: true
6867
xpack.license.self_generated.type: trial
6968
repositories.url.allowed_urls: https://example.com/*
@@ -80,10 +79,28 @@ jobs:
8079
ELASTICSEARCH_USERNAME: ${{ env.KIBANA_SYSTEM_USERNAME }}
8180
ELASTICSEARCH_PASSWORD: ${{ env.KIBANA_SYSTEM_PASSWORD }}
8281
XPACK_ENCRYPTEDSAVEDOBJECTS_ENCRYPTIONKEY: a7a6311933d3503b89bc2dbc36572c33a6c10925682e591bffcab6911c06786d
83-
# LOGGING_ROOT_LEVEL: debug
82+
# LOGGING_ROOT_LEVEL: debug
8483
ports:
8584
- 5601:5601
8685
options: --health-cmd="curl http://localhost:5601/api/status" --health-interval=10s --health-timeout=5s --health-retries=10
86+
fleet:
87+
image: docker.elastic.co/beats/elastic-agent:${{ matrix.version }}
88+
env:
89+
SERVER_NAME: fleet
90+
FLEET_ENROLL: "1"
91+
FLEET_URL: https://fleet:8220
92+
FLEET_INSECURE: "true"
93+
FLEET_SERVER_ENABLE: "1"
94+
FLEET_SERVER_POLICY_ID: fleet-server
95+
FLEET_SERVER_ELASTICSEARCH_HOST: http://elasticsearch:9200
96+
FLEET_SERVER_ELASTICSEARCH_INSECURE: "true"
97+
FLEET_SERVER_INSECURE_HTTP: "true"
98+
KIBANA_HOST: http://kibana:5601
99+
KIBANA_FLEET_SETUP: "1"
100+
KIBANA_FLEET_PASSWORD: ${{ env.ELASTIC_PASSWORD }}
101+
ports:
102+
- 8220:8220
103+
options: --restart="unless-stopped"
87104

88105
timeout-minutes: 15
89106
strategy:
@@ -123,8 +140,6 @@ jobs:
123140
- name: Setup Kibana user
124141
run: make set-kibana-password
125142
env:
126-
ELASTICSEARCH_ENDPOINTS: "http://localhost:9200"
127-
ELASTICSEARCH_USERNAME: "elastic"
128143
ELASTICSEARCH_PASSWORD: ${{ env.ELASTIC_PASSWORD }}
129144
KIBANA_SYSTEM_USERNAME: ${{ env.KIBANA_SYSTEM_USERNAME }}
130145
KIBANA_SYSTEM_PASSWORD: ${{ env.KIBANA_SYSTEM_PASSWORD }}
@@ -134,10 +149,17 @@ jobs:
134149
run: |-
135150
echo "apikey=$(make create-es-api-key | jq -r .encoded)" >> "$GITHUB_OUTPUT"
136151
env:
137-
ELASTICSEARCH_ENDPOINTS: "http://localhost:9200"
138-
ELASTICSEARCH_USERNAME: "elastic"
139152
ELASTICSEARCH_PASSWORD: ${{ env.ELASTIC_PASSWORD }}
140153

154+
- id: setup-fleet
155+
name: Setup Fleet
156+
if: matrix.version == '8.10.3' || matrix.version == '8.11.4' || matrix.version == '8.12.2' || matrix.version == '8.13.4' || matrix.version == '8.14.3' || matrix.version == '8.15.0'
157+
run: |-
158+
make setup-kibana-fleet
159+
env:
160+
ELASTICSEARCH_PASSWORD: ${{ env.ELASTIC_PASSWORD }}
161+
FLEET_NAME: "fleet"
162+
141163
- id: force-install-synthetics
142164
name: Force install synthetics
143165
if: matrix.version == '8.14.3' || matrix.version == '8.15.0'

CHANGELOG.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
## [Unreleased]
22

3+
- Fix secret handling `elasticstack_fleet_integration_policy` resource. ([#821](https://github.com./elastic/terraform-provider-elasticstack/pull/821))
4+
5+
## [0.11.8] - 2024-10-02
6+
7+
- Add key_id to the `elasticstack_elasticsearch_api_key` resource. ([#789](https://github.com./elastic/terraform-provider-elasticstack/pull/789))
38
- Fix handling of `sys_monitoring` in `elasticstack_fleet_agent_policy` ([#792](https://github.com./elastic/terraform-provider-elasticstack/pull/792))
49
- Migrate `elasticstack_fleet_agent_policy`, `elasticstack_fleet_integration` (both), and `elasticstack_fleet_server_host` to terraform-plugin-framework ([#785](https://github.com./elastic/terraform-provider-elasticstack/pull/785))
510
- Fix for synthetics http/tcp monitor produces inconsistent result after apply ([#801](https://github.com./elastic/terraform-provider-elasticstack/pull/801))
11+
- Migrate `elasticstack_fleet_integration_policy` to terraform-plugin-framework. Fix drift in integration policy secrets. ([#797](https://github.com./elastic/terraform-provider-elasticstack/pull/797))
12+
- Migrate `elasticstack_fleet_output` to terraform-plugin-framework. ([#811](https://github.com./elastic/terraform-provider-elasticstack/pull/811))
613

714
## [0.11.7] - 2024-09-20
815

@@ -345,8 +352,9 @@
345352
- Initial set of docs
346353
- CI integration
347354
348-
[Unreleased]: https://github.com./elastic/terraform-provider-elasticstack/compare/v0.11.7...HEAD
349-
[0.11.6]: https://github.com./elastic/terraform-provider-elasticstack/compare/v0.11.6...v0.11.7
355+
[Unreleased]: https://github.com./elastic/terraform-provider-elasticstack/compare/v0.11.8...HEAD
356+
[0.11.8]: https://github.com./elastic/terraform-provider-elasticstack/compare/v0.11.7...v0.11.8
357+
[0.11.7]: https://github.com./elastic/terraform-provider-elasticstack/compare/v0.11.6...v0.11.7
350358
[0.11.6]: https://github.com./elastic/terraform-provider-elasticstack/compare/v0.11.5...v0.11.6
351359
[0.11.5]: https://github.com./elastic/terraform-provider-elasticstack/compare/v0.11.4...v0.11.5
352360
[0.11.4]: https://github.com./elastic/terraform-provider-elasticstack/compare/v0.11.3...v0.11.4

Makefile

+41-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
SHELL := /bin/bash
33

44

5-
VERSION ?= 0.11.7
5+
VERSION ?= 0.11.8
66

77
NAME = elasticstack
88
BINARY = terraform-provider-${NAME}
@@ -31,7 +31,11 @@ KIBANA_SYSTEM_USERNAME ?= kibana_system
3131
KIBANA_SYSTEM_PASSWORD ?= password
3232
KIBANA_API_KEY_NAME ?= kibana-api-key
3333

34+
FLEET_NAME ?= terraform-elasticstack-fleet
35+
FLEET_ENDPOINT ?= https://$(FLEET_NAME):8220
36+
3437
SOURCE_LOCATION ?= $(shell pwd)
38+
, := ,
3539

3640
export GOBIN = $(shell pwd)/bin
3741

@@ -72,7 +76,7 @@ retry = until [ $$(if [ -z "$$attempt" ]; then echo -n "0"; else echo -n "$$atte
7276
# To run specific test (e.g. TestAccResourceActionConnector) execute `make docker-testacc TESTARGS='-run ^TestAccResourceActionConnector$$'`
7377
# To enable tracing (or debugging), execute `make docker-testacc TF_LOG=TRACE`
7478
.PHONY: docker-testacc
75-
docker-testacc: docker-elasticsearch docker-kibana ## Run acceptance tests in the docker container
79+
docker-testacc: docker-elasticsearch docker-kibana docker-fleet ## Run acceptance tests in the docker container
7680
@ docker run --rm \
7781
-e ELASTICSEARCH_ENDPOINTS="$(ELASTICSEARCH_ENDPOINTS)" \
7882
-e KIBANA_ENDPOINT="$(KIBANA_ENDPOINT)" \
@@ -163,6 +167,30 @@ docker-kibana-with-tls: docker-network docker-elasticsearch set-kibana-password
163167
docker.elastic.co/kibana/kibana:$(STACK_VERSION); \
164168
fi)
165169

170+
.PHONY: docker-fleet
171+
docker-fleet: docker-network docker-elasticsearch docker-kibana setup-kibana-fleet ## Start Fleet node in docker container
172+
@ docker rm -f $(FLEET_NAME) &> /dev/null || true
173+
@ $(call retry, 5, if ! docker ps --format '{{.Names}}' | grep -w $(FLEET_NAME) > /dev/null 2>&1 ; then \
174+
docker run -d \
175+
-p 8220:8220 \
176+
-e SERVER_NAME=fleet \
177+
-e FLEET_ENROLL=1 \
178+
-e FLEET_URL=$(FLEET_ENDPOINT) \
179+
-e FLEET_INSECURE=true \
180+
-e FLEET_SERVER_ENABLE=1 \
181+
-e FLEET_SERVER_POLICY_ID=fleet-server \
182+
-e FLEET_SERVER_ELASTICSEARCH_HOST=$(ELASTICSEARCH_ENDPOINTS) \
183+
-e FLEET_SERVER_ELASTICSEARCH_INSECURE=true \
184+
-e FLEET_SERVER_INSECURE_HTTP=true \
185+
-e KIBANA_HOST=$(KIBANA_ENDPOINT) \
186+
-e KIBANA_FLEET_SETUP=1 \
187+
-e KIBANA_FLEET_USERNAME=$(ELASTICSEARCH_USERNAME) \
188+
-e KIBANA_FLEET_PASSWORD=$(ELASTICSEARCH_PASSWORD) \
189+
--name $(FLEET_NAME) \
190+
--network $(ELASTICSEARCH_NETWORK) \
191+
docker.elastic.co/beats/elastic-agent:$(STACK_VERSION); \
192+
fi)
193+
166194

167195
.PHONY: docker-network
168196
docker-network: ## Create a dedicated network for ES and test runs
@@ -172,19 +200,25 @@ docker-network: ## Create a dedicated network for ES and test runs
172200

173201
.PHONY: set-kibana-password
174202
set-kibana-password: ## Sets the ES KIBANA_SYSTEM_USERNAME's password to KIBANA_SYSTEM_PASSWORD. This expects Elasticsearch to be available at localhost:9200
175-
@ $(call retry, 10, curl -X POST -u $(ELASTICSEARCH_USERNAME):$(ELASTICSEARCH_PASSWORD) -H "Content-Type: application/json" http://localhost:9200/_security/user/$(KIBANA_SYSTEM_USERNAME)/_password -d "{\"password\":\"$(KIBANA_SYSTEM_PASSWORD)\"}" | grep -q "^{}")
203+
@ $(call retry, 10, curl -sS -X POST -u $(ELASTICSEARCH_USERNAME):$(ELASTICSEARCH_PASSWORD) -H "Content-Type: application/json" http://localhost:9200/_security/user/$(KIBANA_SYSTEM_USERNAME)/_password -d '{"password":"$(KIBANA_SYSTEM_PASSWORD)"}' | grep -q "^{}")
176204

177205
.PHONY: create-es-api-key
178206
create-es-api-key: ## Creates and outputs a new API Key. This expects Elasticsearch to be available at localhost:9200
179-
@ $(call retry, 10, curl -X POST -u $(ELASTICSEARCH_USERNAME):$(ELASTICSEARCH_PASSWORD) -H "Content-Type: application/json" http://localhost:9200/_security/api_key -d "{\"name\":\"$(KIBANA_API_KEY_NAME)\"}")
207+
@ $(call retry, 10, curl -sS -X POST -u $(ELASTICSEARCH_USERNAME):$(ELASTICSEARCH_PASSWORD) -H "Content-Type: application/json" http://localhost:9200/_security/api_key -d '{"name":"$(KIBANA_API_KEY_NAME)"}')
180208

181209
.PHONY: create-es-bearer-token
182-
create-es-bearer-token:
183-
@ $(call retry, 10, curl -X POST -u $(ELASTICSEARCH_USERNAME):$(ELASTICSEARCH_PASSWORD) -H "Content-Type: application/json" http://localhost:9200/_security/oauth2/token -d "{\"grant_type\": \"client_credentials\"}")
210+
create-es-bearer-token: ## Creates and outputs a new OAuth bearer token. This expects Elasticsearch to be available at localhost:9200
211+
@ $(call retry, 10, curl -sS -X POST -u $(ELASTICSEARCH_USERNAME):$(ELASTICSEARCH_PASSWORD) -H "Content-Type: application/json" http://localhost:9200/_security/oauth2/token -d '{"grant_type":"client_credentials"}')
212+
213+
.PHONY: setup-kibana-fleet
214+
setup-kibana-fleet: ## Creates the agent and integration policies required to run Fleet. This expects Kibana to be available at localhost:5601
215+
@ $(call retry, 10, curl -sS --fail-with-body -X POST -u $(ELASTICSEARCH_USERNAME):$(ELASTICSEARCH_PASSWORD) -H "Content-Type: application/json" -H "kbn-xsrf: true" http://localhost:5601/api/fleet/fleet_server_hosts -d '{"name":"default"$(,)"host_urls":["$(FLEET_ENDPOINT)"]$(,)"is_default":true}')
216+
@ $(call retry, 10, curl -sS --fail-with-body -X POST -u $(ELASTICSEARCH_USERNAME):$(ELASTICSEARCH_PASSWORD) -H "Content-Type: application/json" -H "kbn-xsrf: true" http://localhost:5601/api/fleet/agent_policies -d '{"id":"fleet-server"$(,)"name":"Fleet Server"$(,)"namespace":"default"$(,)"monitoring_enabled":["logs"$(,)"metrics"]}')
217+
@ $(call retry, 10, curl -sS --fail-with-body -X POST -u $(ELASTICSEARCH_USERNAME):$(ELASTICSEARCH_PASSWORD) -H "Content-Type: application/json" -H "kbn-xsrf: true" http://localhost:5601/api/fleet/package_policies -d '{"name":"fleet-server"$(,)"namespace":"default"$(,)"policy_id":"fleet-server"$(,)"enabled":true$(,)"inputs":[{"type":"fleet-server"$(,)"enabled":true$(,)"streams":[]$(,)"vars":{}}]$(,)"package":{"name":"fleet_server"$(,)"version":"1.5.0"}}')
184218

185219
.PHONY: docker-clean
186220
docker-clean: ## Try to remove provisioned nodes and assigned network
187-
@ docker rm -f $(ELASTICSEARCH_NAME) $(KIBANA_NAME) || true
221+
@ docker rm -f $(ELASTICSEARCH_NAME) $(KIBANA_NAME) $(FLEET_NAME) || true
188222
@ docker network rm $(ELASTICSEARCH_NETWORK) || true
189223

190224

docs/resources/elasticsearch_security_api_key.md

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ output "api_key" {
9898
- `encoded` (String, Sensitive) API key credentials which is the Base64-encoding of the UTF-8 representation of the id and api_key joined by a colon (:).
9999
- `expiration_timestamp` (Number) Expiration time in milliseconds for the API key. By default, API keys never expire.
100100
- `id` (String) Internal identifier of the resource.
101+
- `key_id` (String) Unique id for this API key.
101102

102103
<a id="nestedblock--elasticsearch_connection"></a>
103104
### Nested Schema for `elasticsearch_connection`

docs/resources/fleet_integration_policy.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ resource "elasticstack_fleet_integration_policy" "sample" {
9393
- `description` (String) The description of the integration policy.
9494
- `enabled` (Boolean) Enable the integration policy.
9595
- `force` (Boolean) Force operations, such as creation and deletion, to occur.
96-
- `input` (Block List) (see [below for nested schema](#nestedblock--input))
96+
- `input` (Block List) Integration inputs. (see [below for nested schema](#nestedblock--input))
9797
- `policy_id` (String) Unique identifier of the integration policy.
9898
- `vars_json` (String, Sensitive) Integration-level variables as JSON.
9999

docs/resources/fleet_output.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ resource "elasticstack_fleet_output" "test_output" {
4848
- `default_monitoring` (Boolean) Make this output the default for agent monitoring.
4949
- `hosts` (List of String) A list of hosts.
5050
- `output_id` (String) Unique identifier of the output.
51-
- `ssl` (Block List, Max: 1) SSL configuration. (see [below for nested schema](#nestedblock--ssl))
51+
- `ssl` (Block List) SSL configuration. (see [below for nested schema](#nestedblock--ssl))
5252

5353
### Read-Only
5454

docs/resources/kibana_data_view.md

+2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ Optional:
8888

8989
Optional:
9090

91+
- `labeltemplate` (String)
9192
- `pattern` (String)
93+
- `urltemplate` (String)
9294

9395

9496

generated/fleet/fleet.gen.go

+16-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generated/fleet/getschema.go

+25
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ var transformers = []TransformFunc{
7171
transformSchemasInputsType,
7272
transformInlinePackageDefinitions,
7373
transformAddPackagePolicyVars,
74+
transformAddPackagePolicySecretReferences,
7475
transformFixPackageSearchResult,
7576
}
7677

@@ -334,6 +335,30 @@ func transformAddPackagePolicyVars(schema *Schema) {
334335
}
335336
}
336337

338+
// transformAddPackagePolicySecretReferences adds the missing 'secretReferences'
339+
// field to the PackagePolicy schema struct.
340+
func transformAddPackagePolicySecretReferences(schema *Schema) {
341+
inputs, ok := schema.Components.GetFields("schemas.new_package_policy.properties")
342+
if !ok {
343+
panic("properties not found")
344+
}
345+
346+
// Only add it if it doesn't exist.
347+
if _, ok = inputs.Get("secret_references"); !ok {
348+
inputs.Set("secret_references", map[string]any{
349+
"type": "array",
350+
"items": map[string]any{
351+
"type": "object",
352+
"properties": map[string]any{
353+
"id": map[string]any{
354+
"type": "string",
355+
},
356+
},
357+
},
358+
})
359+
}
360+
}
361+
337362
// transformFixPackageSearchResult removes unneeded fields from the
338363
// SearchResult struct. These fields are also causing parsing errors.
339364
func transformFixPackageSearchResult(schema *Schema) {

0 commit comments

Comments
 (0)