Skip to content

Commit 26c124b

Browse files
authored
fix for http/tcp monitor produces inconsistent result after apply (#801)
* fix: synthetics http monitor creations produced inconsistent result after apply for #800 fix for the fileds: http.locations, http.proxy_url, http.ssl_supported_protocols, http.ssl_verification_mode, tcp.proxy_url, tcp.ssl_supported_protocols, tcp.ssl_verification_mode * make lint happy * update change log * cr comments - reuse utls
1 parent 534352e commit 26c124b

File tree

7 files changed

+184
-129
lines changed

7 files changed

+184
-129
lines changed

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+
- Fix for synthetics http/tcp monitor produces inconsistent result after apply ([#801](https://github.com/elastic/terraform-provider-elasticstack/pull/801))
56

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

internal/kibana/synthetics/acc_test.go

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,9 @@ resource "elasticstack_kibana_synthetics_monitor" "%s" {
3737
timeout = 30
3838
http = {
3939
url = "http://localhost:5601"
40-
ssl_verification_mode = "full"
41-
ssl_supported_protocols = ["TLSv1.0", "TLSv1.1", "TLSv1.2"]
4240
mode = "any"
4341
ipv4 = true
4442
ipv6 = false
45-
proxy_url = "http://localhost:8080"
4643
}
4744
}
4845
`
@@ -128,9 +125,6 @@ resource "elasticstack_kibana_synthetics_monitor" "%s" {
128125
timeout = 30
129126
tcp = {
130127
host = "http://localhost:5601"
131-
ssl_verification_mode = "full"
132-
ssl_supported_protocols = ["TLSv1.0", "TLSv1.1", "TLSv1.2"]
133-
proxy_url = "http://localhost:8080"
134128
proxy_use_local_resolver = true
135129
}
136130
}
@@ -302,14 +296,14 @@ func TestSyntheticMonitorHTTPResource(t *testing.T) {
302296
resource.TestCheckResourceAttr(httpMonitorId, "http.url", "http://localhost:5601"),
303297
resource.TestCheckResourceAttr(httpMonitorId, "http.ssl_verification_mode", "full"),
304298
resource.TestCheckResourceAttr(httpMonitorId, "http.ssl_supported_protocols.#", "3"),
305-
resource.TestCheckResourceAttr(httpMonitorId, "http.ssl_supported_protocols.0", "TLSv1.0"),
306-
resource.TestCheckResourceAttr(httpMonitorId, "http.ssl_supported_protocols.1", "TLSv1.1"),
307-
resource.TestCheckResourceAttr(httpMonitorId, "http.ssl_supported_protocols.2", "TLSv1.2"),
299+
resource.TestCheckResourceAttr(httpMonitorId, "http.ssl_supported_protocols.0", "TLSv1.1"),
300+
resource.TestCheckResourceAttr(httpMonitorId, "http.ssl_supported_protocols.1", "TLSv1.2"),
301+
resource.TestCheckResourceAttr(httpMonitorId, "http.ssl_supported_protocols.2", "TLSv1.3"),
308302
resource.TestCheckResourceAttr(httpMonitorId, "http.max_redirects", "0"),
309303
resource.TestCheckResourceAttr(httpMonitorId, "http.mode", "any"),
310304
resource.TestCheckResourceAttr(httpMonitorId, "http.ipv4", "true"),
311305
resource.TestCheckResourceAttr(httpMonitorId, "http.ipv6", "false"),
312-
resource.TestCheckResourceAttr(httpMonitorId, "http.proxy_url", "http://localhost:8080"),
306+
resource.TestCheckResourceAttr(httpMonitorId, "http.proxy_url", ""),
313307
),
314308
},
315309
// ImportState testing
@@ -402,10 +396,10 @@ func TestSyntheticMonitorTCPResource(t *testing.T) {
402396
resource.TestCheckResourceAttr(tcpMonitorId, "tcp.host", "http://localhost:5601"),
403397
resource.TestCheckResourceAttr(tcpMonitorId, "tcp.ssl_verification_mode", "full"),
404398
resource.TestCheckResourceAttr(tcpMonitorId, "tcp.ssl_supported_protocols.#", "3"),
405-
resource.TestCheckResourceAttr(tcpMonitorId, "tcp.ssl_supported_protocols.0", "TLSv1.0"),
406-
resource.TestCheckResourceAttr(tcpMonitorId, "tcp.ssl_supported_protocols.1", "TLSv1.1"),
407-
resource.TestCheckResourceAttr(tcpMonitorId, "tcp.ssl_supported_protocols.2", "TLSv1.2"),
408-
resource.TestCheckResourceAttr(tcpMonitorId, "tcp.proxy_url", "http://localhost:8080"),
399+
resource.TestCheckResourceAttr(tcpMonitorId, "tcp.ssl_supported_protocols.0", "TLSv1.1"),
400+
resource.TestCheckResourceAttr(tcpMonitorId, "tcp.ssl_supported_protocols.1", "TLSv1.2"),
401+
resource.TestCheckResourceAttr(tcpMonitorId, "tcp.ssl_supported_protocols.2", "TLSv1.3"),
402+
resource.TestCheckResourceAttr(tcpMonitorId, "tcp.proxy_url", ""),
409403
resource.TestCheckResourceAttr(tcpMonitorId, "tcp.proxy_use_local_resolver", "true"),
410404
),
411405
},

internal/kibana/synthetics/create.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func (r *Resource) Create(ctx context.Context, request resource.CreateRequest, r
2020
return
2121
}
2222

23-
input, diags := plan.toKibanaAPIRequest()
23+
input, diags := plan.toKibanaAPIRequest(ctx)
2424
response.Diagnostics.Append(diags...)
2525
if response.Diagnostics.HasError() {
2626
return
@@ -33,9 +33,9 @@ func (r *Resource) Create(ctx context.Context, request resource.CreateRequest, r
3333
return
3434
}
3535

36-
plan, err = plan.toModelV0(result)
37-
if err != nil {
38-
response.Diagnostics.AddError("Failed to convert Kibana monitor API to TF state", err.Error())
36+
plan, diags = plan.toModelV0(ctx, result)
37+
response.Diagnostics.Append(diags...)
38+
if response.Diagnostics.HasError() {
3939
return
4040
}
4141

internal/kibana/synthetics/read.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ func (r *Resource) Read(ctx context.Context, request resource.ReadRequest, respo
4242
return
4343
}
4444

45-
state, err = state.toModelV0(result)
46-
if err != nil {
47-
response.Diagnostics.AddError("Failed to convert Kibana monitor API to TF state", err.Error())
45+
state, diags = state.toModelV0(ctx, result)
46+
response.Diagnostics.Append(diags...)
47+
if response.Diagnostics.HasError() {
4848
return
4949
}
5050

0 commit comments

Comments
 (0)