Skip to content

Commit aafc5a1

Browse files
Add support for synthetics global parameters (elastic#1155)
* Add support for synthetics global parameters This adds support for creating synthetics global parameters, which are used to store secrets used for synthetics monitors. This implementation is based on what we already do for synthetics private locations. This is mostly just a simple wrapper around API calls, except we currently requery the resource after creating it or updating it. This is because Kibana (at least in 9.0.0) has some unexpected responses for /api/synthetics/params: 1. The POST request to create a parameter does not include the `value` field in the response. 2. The PUT request to update a parameter returns the new values for all fields, except for `value`, which contains the old secret. 3. None of the responses include the `share_across_spaces` value, which can only be inferred by checking of `namespaces` is `["*"]`. We also use the undocumented `DELETE /api/synthetics/params` API that the Kibana UI uses due to many quirks with the deletion APIs in various versions of Kibana. I tested every single version of Kibana since the parameter APIs were introduced (8.12.0) and this one is the only one that works on all versions. * `DELETE /api/synthetics/params/<id>` (from documentation) - Works on >=8.17.0. - HTTP 404 on 8.12.x through 8.16.x. * `DELETE /api/synthetics/params/_bulk_delete` (from documentation) - HTTP 400 on 9.0.x with error message about URL parameters and body provided at the same time (`_bulk_delete` interpreted as parameter ID?). - HTTP 403 on 8.18.x with error message about missing `uptime-read` and `uptime-write` permissions despite having the `superuser` role. - HTTP 403 with no details on 8.17.x. - HTTP 404 on 8.12.x through 8.16.x. * `POST /api/synthetics/params/_bulk_delete` (from comment in documentation example) - Works on >=8.17.0. - HTTP 404 on 8.12.x through 8.16.x. * `DELETE /api/synthetics/params` (what the Kibana UI does) - Works on >=8.12.0. Finally, this updates the Github Actions workflow to run the tests using HTTP basic auth instead of API keys. On all versions of Kibana, the params endpoint fails to return the current value when using API keys, even if permissions are not restricted for the key. Explicitly granting the key all permissions to Kibana does not work either. Fixes: elastic#1152 Signed-off-by: Andrew Gunnerson <[email protected]> * synthetics/parameter: Remove duplicate code when rereading in create/update Signed-off-by: Andrew Gunnerson <[email protected]> * synthetics/parameter: Switch to using OAPI client Co-Authored-By: Toby Brain <[email protected]> Signed-off-by: Andrew Gunnerson <[email protected]> * Changelog --------- Signed-off-by: Andrew Gunnerson <[email protected]> Co-authored-by: Toby Brain <[email protected]>
1 parent ec089b4 commit aafc5a1

File tree

21 files changed

+1436
-3
lines changed

21 files changed

+1436
-3
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,5 @@ jobs:
179179
ELASTICSEARCH_USERNAME: "elastic"
180180
ELASTICSEARCH_PASSWORD: ${{ env.ELASTIC_PASSWORD }}
181181
KIBANA_ENDPOINT: "http://localhost:5601"
182-
KIBANA_API_KEY: ${{ steps.get-api-key.outputs.apikey }}
182+
KIBANA_USERNAME: "elastic"
183+
KIBANA_PASSWORD: ${{ env.ELASTIC_PASSWORD }}

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- Migrate `elasticstack_elasticsearch_system_user` resource to Terraform plugin framework ([#1154](https://github.com/elastic/terraform-provider-elasticstack/pull/1154))
55
- Add custom `endpoint` configuration support for snapshot repository setup ([#1158](https://github.com/elastic/terraform-provider-elasticstack/pull/1158))
66
- Add `description` to `elasticstack_kibana_security_role` ([#1172](https://github.com/elastic/terraform-provider-elasticstack/issues/1172))
7+
- Add `elasticstack_kibana_synthetics_parameter` resource ([#1155](https://github.com/elastic/terraform-provider-elasticstack/pull/1155))
78

89
## [0.11.15] - 2025-04-23
910

@@ -425,7 +426,8 @@
425426
- Initial set of docs
426427
- CI integration
427428
428-
[Unreleased]: https://github.com/elastic/terraform-provider-elasticstack/compare/v0.11.14...HEAD
429+
[Unreleased]: https://github.com/elastic/terraform-provider-elasticstack/compare/v0.11.15...HEAD
430+
[0.11.15]: https://github.com/elastic/terraform-provider-elasticstack/compare/v0.11.14...v0.11.15
429431
[0.11.14]: https://github.com/elastic/terraform-provider-elasticstack/compare/v0.11.13...v0.11.14
430432
[0.11.13]: https://github.com/elastic/terraform-provider-elasticstack/compare/v0.11.12...v0.11.13
431433
[0.11.12]: https://github.com/elastic/terraform-provider-elasticstack/compare/v0.11.11...v0.11.12
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
subcategory: "Kibana"
3+
layout: ""
4+
page_title: "Elasticstack: elasticstack_kibana_synthetics_parameter Resource"
5+
description: |-
6+
Creates or updates a Kibana synthetics parameter.
7+
---
8+
9+
# Resource: elasticstack_kibana_synthetics_parameter
10+
11+
Creates or updates a Kibana synthetics parameter.
12+
See [Working with secrets and sensitive values](https://www.elastic.co/docs/solutions/observability/synthetics/work-with-params-secrets)
13+
and [API docs](https://www.elastic.co/docs/api/doc/kibana/group/endpoint-synthetics)
14+
15+
## Example Usage
16+
17+
```terraform
18+
provider "elasticstack" {
19+
kibana {}
20+
}
21+
22+
resource "elasticstack_kibana_synthetics_parameter" "example" {
23+
key = "example_key"
24+
value = "example_value"
25+
description = "Example description"
26+
tags = ["tag-a", "tag-b"]
27+
}
28+
```
29+
30+
<!-- schema generated by tfplugindocs -->
31+
## Schema
32+
33+
### Required
34+
35+
- `key` (String) The key of the parameter.
36+
- `value` (String, Sensitive) The value associated with the parameter.
37+
38+
### Optional
39+
40+
- `description` (String) A description of the parameter.
41+
- `share_across_spaces` (Boolean) Whether the parameter should be shared across spaces.
42+
- `tags` (List of String) An array of tags to categorize the parameter.
43+
44+
### Read-Only
45+
46+
- `id` (String) Generated id for the parameter.
47+
48+
## Import
49+
50+
Import is supported using the following syntax:
51+
52+
```shell
53+
terraform import elasticstack_kibana_synthetics_parameter.my_param <space id>/<param_id>
54+
```
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
terraform import elasticstack_kibana_synthetics_parameter.my_param <space id>/<param_id>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
provider "elasticstack" {
2+
kibana {}
3+
}
4+
5+
resource "elasticstack_kibana_synthetics_parameter" "example" {
6+
key = "example_key"
7+
value = "example_value"
8+
description = "Example description"
9+
tags = ["tag-a", "tag-b"]
10+
}

0 commit comments

Comments
 (0)