Skip to content

Commit f417c7c

Browse files
authored
feat(synthetics): support for private location resource (#696)
Related to: * #675 * #610
1 parent eaf6c08 commit f417c7c

File tree

21 files changed

+914
-41
lines changed

21 files changed

+914
-41
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ jobs:
102102
- '8.11.4'
103103
- '8.12.2'
104104
- '8.13.4'
105-
- '8.14.0'
105+
- '8.14.3'
106106
steps:
107107
- uses: actions/checkout@v4
108108
- uses: actions/setup-go@v5

CHANGELOG.md

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

33
- Fix setting `id` for Fleet outputs and servers ([#666](https://github.com/elastic/terraform-provider-elasticstack/pull/666))
44
- Fix `elasticstack_fleet_enrollment_tokens` returning empty tokens in some case ([#683](https://github.com/elastic/terraform-provider-elasticstack/pull/683))
5+
- Add support for Kibana synthetics private locations ([#696](https://github.com/elastic/terraform-provider-elasticstack/pull/696))
56

67
## [0.11.4] - 2024-06-13
78

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ testacc: ## Run acceptance tests
5858
test: ## Run unit tests
5959
go test -v $(TEST) $(TESTARGS) -timeout=5m -parallel=4
6060

61-
# Retry command - first argumment is how many attempts are required, second argument is the command to run
62-
# Backoff starts with 1 second and double with next itteration
61+
# Retry command - first argument is how many attempts are required, second argument is the command to run
62+
# Backoff starts with 1 second and double with next iteration
6363
retry = until [ $$(if [ -z "$$attempt" ]; then echo -n "0"; else echo -n "$$attempt"; fi) -ge $(1) ]; do \
6464
backoff=$$(if [ -z "$$backoff" ]; then echo "1"; else echo "$$backoff"; fi); \
6565
sleep $$backoff; \
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
subcategory: "Kibana"
3+
layout: ""
4+
page_title: "Elasticstack: elasticstack_kibana_synthetics_private_location Resource"
5+
description: |-
6+
Creates or updates a Kibana synthetics private location.
7+
---
8+
9+
# Resource: elasticstack_kibana_synthetics_private_location
10+
11+
Creates or updates a Kibana synthetics private location.
12+
See [Monitor via a private agent](https://www.elastic.co/guide/en/observability/current/synthetics-private-location.html#monitor-via-private-agent)
13+
and [api docs](https://www.elastic.co/guide/en/kibana/current/create-private-location-api.html)
14+
15+
## Example Usage
16+
17+
```terraform
18+
provider "elasticstack" {
19+
fleet {}
20+
kibana {}
21+
}
22+
23+
resource "elasticstack_fleet_agent_policy" "sample" {
24+
name = "Sample Agent Policy"
25+
namespace = "default"
26+
description = "A sample agent policy"
27+
monitor_logs = true
28+
monitor_metrics = true
29+
skip_destroy = false
30+
}
31+
32+
resource "elasticstack_kibana_synthetics_private_location" "example" {
33+
label = "example label"
34+
space_id = "default"
35+
agent_policy_id = elasticstack_fleet_agent_policy.sample.policy_id
36+
tags = ["tag-a", "tag-b"]
37+
geo = {
38+
lat = 40.7128
39+
lon = 74.0060
40+
}
41+
}
42+
```
43+
44+
<!-- schema generated by tfplugindocs -->
45+
## Schema
46+
47+
### Required
48+
49+
- `agent_policy_id` (String) The ID of the agent policy associated with the private location. To create a private location for synthetics monitor you need to create an agent policy in fleet and use its agentPolicyId
50+
- `label` (String) A label for the private location, used as unique identifier
51+
52+
### Optional
53+
54+
- `geo` (Attributes) Geographic coordinates (WGS84) for the location (see [below for nested schema](#nestedatt--geo))
55+
- `space_id` (String) An identifier for the space. If space_id is not provided, the default space is used.
56+
- `tags` (List of String) An array of tags to categorize the private location.
57+
58+
### Read-Only
59+
60+
- `id` (String) Generated id for the private location. For monitor setup please use private location label.
61+
62+
<a id="nestedatt--geo"></a>
63+
### Nested Schema for `geo`
64+
65+
Required:
66+
67+
- `lat` (Number) The latitude of the location.
68+
- `lon` (Number) The longitude of the location.
69+
70+
## Import
71+
72+
Import is supported using the following syntax:
73+
74+
```shell
75+
terraform import elasticstack_kibana_synthetics_private_location.my_location <private_location_id>
76+
```
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "elasticstack_kibana_synthetics_private_location Resource - terraform-provider-elasticstack"
4+
subcategory: ""
5+
description: |-
6+
Synthetics private location config, see https://www.elastic.co/guide/en/kibana/current/create-private-location-api.html for more details
7+
---
8+
9+
# elasticstack_kibana_synthetics_private_location (Resource)
10+
11+
Synthetics private location config, see https://www.elastic.co/guide/en/kibana/current/create-private-location-api.html for more details
12+
13+
## Example Usage
14+
15+
```terraform
16+
provider "elasticstack" {
17+
fleet {}
18+
kibana {}
19+
}
20+
21+
resource "elasticstack_fleet_agent_policy" "sample" {
22+
name = "Sample Agent Policy"
23+
namespace = "default"
24+
description = "A sample agent policy"
25+
monitor_logs = true
26+
monitor_metrics = true
27+
skip_destroy = false
28+
}
29+
30+
resource "elasticstack_kibana_synthetics_private_location" "example" {
31+
label = "example label"
32+
space_id = "default"
33+
agent_policy_id = elasticstack_fleet_agent_policy.sample.policy_id
34+
tags = ["tag-a", "tag-b"]
35+
geo = {
36+
lat = 40.7128
37+
lon = 74.0060
38+
}
39+
}
40+
```
41+
42+
<!-- schema generated by tfplugindocs -->
43+
## Schema
44+
45+
### Required
46+
47+
- `agent_policy_id` (String) The ID of the agent policy associated with the private location. To create a private location for synthetics monitor you need to create an agent policy in fleet and use its agentPolicyId
48+
- `label` (String) A label for the private location, used as unique identifier
49+
50+
### Optional
51+
52+
- `geo` (Attributes) Geographic coordinates (WGS84) for the location (see [below for nested schema](#nestedatt--geo))
53+
- `space_id` (String) An identifier for the space. If space_id is not provided, the default space is used.
54+
- `tags` (List of String) An array of tags to categorize the private location.
55+
56+
### Read-Only
57+
58+
- `id` (String) Generated id for the private location. For monitor setup please use private location label.
59+
60+
<a id="nestedatt--geo"></a>
61+
### Nested Schema for `geo`
62+
63+
Required:
64+
65+
- `lat` (Number) The latitude of the location.
66+
- `lon` (Number) The longitude of the location.
67+
68+
## Import
69+
70+
Import is supported using the following syntax:
71+
72+
```shell
73+
terraform import elasticstack_kibana_synthetics_private_location.my_location <private_location_id>
74+
```
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
terraform import elasticstack_kibana_synthetics_private_location.my_location <private_location_id>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
provider "elasticstack" {
2+
fleet {}
3+
kibana {}
4+
}
5+
6+
resource "elasticstack_fleet_agent_policy" "sample" {
7+
name = "Sample Agent Policy"
8+
namespace = "default"
9+
description = "A sample agent policy"
10+
monitor_logs = true
11+
monitor_metrics = true
12+
skip_destroy = false
13+
}
14+
15+
resource "elasticstack_kibana_synthetics_private_location" "example" {
16+
label = "example label"
17+
space_id = "default"
18+
agent_policy_id = elasticstack_fleet_agent_policy.sample.policy_id
19+
tags = ["tag-a", "tag-b"]
20+
geo = {
21+
lat = 40.7128
22+
lon = 74.0060
23+
}
24+
}

internal/clients/api_client.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,12 @@ func buildKibanaClient(cfg config.Client) (*kibana.Client, error) {
391391

392392
if logging.IsDebugOrHigher() {
393393
// Don't use kib.Client.SetDebug() here as we re-use the http client within the OpenAPI generated clients
394-
kibHttpClient := kib.Client.GetClient()
395-
kibHttpClient.Transport = utils.NewDebugTransport("Kibana", kibHttpClient.Transport)
394+
transport, err := kib.Client.Transport()
395+
if err != nil {
396+
return nil, err
397+
}
398+
var roundTripper http.RoundTripper = utils.NewDebugTransport("Kibana", transport)
399+
kib.Client.SetTransport(roundTripper)
396400
}
397401

398402
return kib, nil

0 commit comments

Comments
 (0)