Skip to content

Commit 3d70ddd

Browse files
committed
squashed
1 parent d5fba96 commit 3d70ddd

37 files changed

+2341
-1398
lines changed

.github/workflows/test.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,25 @@ jobs:
8080
ELASTICSEARCH_USERNAME: ${{ env.KIBANA_SYSTEM_USERNAME }}
8181
ELASTICSEARCH_PASSWORD: ${{ env.KIBANA_SYSTEM_PASSWORD }}
8282
XPACK_ENCRYPTEDSAVEDOBJECTS_ENCRYPTIONKEY: a7a6311933d3503b89bc2dbc36572c33a6c10925682e591bffcab6911c06786d
83-
# LOGGING_ROOT_LEVEL: debug
83+
# LOGGING_ROOT_LEVEL: debug
8484
ports:
8585
- 5601:5601
8686
options: --health-cmd="curl http://localhost:5601/api/status" --health-interval=10s --health-timeout=5s --health-retries=10
87+
fleet:
88+
image: docker.elastic.co/beats/elastic-agent:${{ matrix.version }}
89+
env:
90+
SERVER_NAME: fleet
91+
FLEET_ENROLL: 1
92+
FLEET_URL: http://fleet:8220
93+
FLEET_INSECURE: "true"
94+
FLEET_SERVER_ENABLE: "1"
95+
FLEET_SERVER_POLICY_ID: fleet-server-policy
96+
FLEET_SERVER_ELASTICSEARCH_HOST: http://elasticsearch:9200
97+
FLEET_SERVER_ELASTICSEARCH_INSECURE: "true"
98+
FLEET_SERVER_INSECURE_HTTP: "true"
99+
KIBANA_HOST: http://kibana:5601
100+
KIBANA_FLEET_SETUP: "1"
101+
KIBANA_FLEET_PASSWORD: ${{ env.ELASTIC_PASSWORD }}
87102

88103
timeout-minutes: 15
89104
strategy:
@@ -138,6 +153,16 @@ jobs:
138153
ELASTICSEARCH_USERNAME: "elastic"
139154
ELASTICSEARCH_PASSWORD: ${{ env.ELASTIC_PASSWORD }}
140155

156+
- id: setup-fleet
157+
name: Setup Fleet
158+
run: |-
159+
make setup-kibana-fleet
160+
env:
161+
ELASTICSEARCH_ENDPOINTS: "http://elasticsearch:9200"
162+
ELASTICSEARCH_USERNAME: "elastic"
163+
ELASTICSEARCH_PASSWORD: ${{ env.ELASTIC_PASSWORD }}
164+
FLEET_ENDPOINT: "https://fleet:8220"
165+
141166
- id: force-install-synthetics
142167
name: Force install synthetics
143168
if: matrix.version == '8.14.3' || matrix.version == '8.15.0'

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
- Fix handling of `sys_monitoring` in `elasticstack_fleet_agent_policy` ([#792](https://github.com/elastic/terraform-provider-elasticstack/pull/792))
44
- 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))
5+
- Migrate `elasticstack_fleet_output` and `elasticstack_fleet_integration_policy` to terraform-plugin-framework. Fix drift in integration policy secrets. ([#TODO](https://github.com/elastic/terraform-provider-elasticstack/pull/TODO))
56

67
## [0.11.7] - 2024-09-20
78

Makefile

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

@@ -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,24 @@ 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 -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 -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 -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 -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"]}')
216+
@ $(call retry, 10, curl -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"}}')
184217

185218
.PHONY: docker-clean
186219
docker-clean: ## Try to remove provisioned nodes and assigned network
187-
@ docker rm -f $(ELASTICSEARCH_NAME) $(KIBANA_NAME) || true
220+
@ docker rm -f $(ELASTICSEARCH_NAME) $(KIBANA_NAME) $(FLEET_NAME) || true
188221
@ docker network rm $(ELASTICSEARCH_NETWORK) || true
189222

190223

docs/resources/fleet_integration_policy.md

Lines changed: 2 additions & 2 deletions
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

@@ -112,7 +112,7 @@ Optional:
112112

113113
- `enabled` (Boolean) Enable the input.
114114
- `streams_json` (String, Sensitive) Input streams as JSON.
115-
- `vars_json` (String, Sensitive) Input variables as JSON.
115+
- `vars_json` (String, Sensitive) Input vars as JSON.
116116

117117
## Import
118118

docs/resources/fleet_output.md

Lines changed: 1 addition & 1 deletion
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

generated/fleet/fleet.gen.go

Lines changed: 15 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generated/fleet/getschema.go

Lines changed: 25 additions & 0 deletions
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
transformRemoveUnnecessaryGoPointers,
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)