Skip to content

Commit 72127a3

Browse files
committed
feat: Add support for secret_manager_enabled
1 parent 2f0f121 commit 72127a3

File tree

5 files changed

+51
-3
lines changed

5 files changed

+51
-3
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
data "grafana_synthetic_monitoring_probes" "main" {}
2+
3+
resource "grafana_synthetic_monitoring_check" "http" {
4+
job = "HTTP Secret Manager"
5+
target = "https://api.example.com"
6+
enabled = true
7+
probes = [
8+
data.grafana_synthetic_monitoring_probes.main.probes.Mumbai,
9+
]
10+
labels = {
11+
environment = "production"
12+
service = "api"
13+
}
14+
settings {
15+
http {
16+
ip_version = "V4"
17+
method = "GET"
18+
secret_manager_enabled = true
19+
bearer_token = "gsm:my-api-token"
20+
21+
basic_auth {
22+
username = "admin"
23+
password = "gsm:my-api-password"
24+
}
25+
26+
headers = [
27+
"Accept: application/json",
28+
"User-Agent: Terraform-Synthetic-Monitoring",
29+
]
30+
31+
valid_status_codes = [
32+
200,
33+
201,
34+
202,
35+
]
36+
37+
fail_if_ssl = false
38+
fail_if_not_ssl = true
39+
}
40+
}
41+
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,4 +220,4 @@ require (
220220
)
221221

222222
// https://github.com/hashicorp/terraform-exec/issues/423
223-
replace github.com/hashicorp/terraform-exec v0.22.0 => github.com/hrmsk66/terraform-exec v0.21.0
223+
replace github.com/hashicorp/terraform-exec v0.22.0 => github.com/hrmsk66/terraform-exec v0.21.0

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,6 @@ github.com/grafana/river v0.3.0 h1:6TsaR/vkkcppUM9I0muGbPIUedCtpPu6OWreE5+CE6g=
206206
github.com/grafana/river v0.3.0/go.mod h1:icSidCSHYXJUYy6TjGAi/D+X7FsP7Gc7cxvBUIwYMmY=
207207
github.com/grafana/slo-openapi-client/go/slo v0.0.0-20250218172929-ab9cae090da6 h1:7jbuz2MCqHlIc+vC3geOEzMZolm30v3K1bFTaTJ4mGI=
208208
github.com/grafana/slo-openapi-client/go/slo v0.0.0-20250218172929-ab9cae090da6/go.mod h1:a9idYds6valDrBwBdcFTIp+QzlERgf2CFDZgEfmp9pA=
209-
github.com/grafana/synthetic-monitoring-agent v0.39.2 h1:aiaU4mUzhe1mdORaVfaTKiFTSTlfyT4doBQoovA+I1k=
210-
github.com/grafana/synthetic-monitoring-agent v0.39.2/go.mod h1:nt+OvMmK7GsM72gMKaVA9uNDwQKxU90WeyxU0gnwrOQ=
211209
github.com/grafana/synthetic-monitoring-api-go-client v0.15.1 h1:YCQ5dWFeWny24wo6SA/rVrtpF0Y7miGHAnFF15LDWFQ=
212210
github.com/grafana/synthetic-monitoring-api-go-client v0.15.1/go.mod h1:6PmnrhmVoEsf6s4d20zmsujgpPwprC4Roc7jAK9Thyc=
213211
github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.0.1 h1:qnpSQwGEnkcRpTqNOIR6bJbR0gAorgP9CSALpRcKoAA=

internal/resources/syntheticmonitoring/resource_check.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,12 @@ var (
371371
Type: schema.TypeString,
372372
Optional: true,
373373
},
374+
"secret_manager_enabled": {
375+
Description: "Enable secret manager for bearer token and basic auth password resolution using ${secrets.secret_name} syntax.",
376+
Type: schema.TypeBool,
377+
Optional: true,
378+
Default: false,
379+
},
374380
},
375381
}
376382

@@ -1003,6 +1009,7 @@ func resourceCheckRead(ctx context.Context, d *schema.ResourceData, c *smapi.Cli
10031009
"fail_if_header_not_matches_regexp": headerMatch(chk.Settings.Http.FailIfHeaderNotMatchesRegexp),
10041010
"compression": compression,
10051011
"cache_busting_query_param_name": chk.Settings.Http.CacheBustingQueryParamName,
1012+
"secret_manager_enabled": chk.Settings.Http.SecretManagerEnabled,
10061013
})
10071014

10081015
settings.Add(map[string]interface{}{
@@ -1518,6 +1525,7 @@ func makeCheckSettings(settings map[string]interface{}) (sm.CheckSettings, error
15181525
FailIfBodyMatchesRegexp: common.SetToStringSlice(h["fail_if_body_matches_regexp"].(*schema.Set)),
15191526
FailIfBodyNotMatchesRegexp: common.SetToStringSlice(h["fail_if_body_not_matches_regexp"].(*schema.Set)),
15201527
CacheBustingQueryParamName: h["cache_busting_query_param_name"].(string),
1528+
SecretManagerEnabled: h["secret_manager_enabled"].(bool),
15211529
}
15221530
compression, ok := h["compression"].(string)
15231531
if ok {

internal/resources/syntheticmonitoring/resource_check_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ func TestAccResourceCheck_http(t *testing.T) {
141141
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.http", "settings.0.http.0.fail_if_header_matches_regexp.0.header", "Content-Type"),
142142
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.http", "settings.0.http.0.fail_if_header_matches_regexp.0.regexp", "application/soap*"),
143143
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.http", "settings.0.http.0.fail_if_header_matches_regexp.0.allow_missing", "true"),
144+
resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.http", "settings.0.http.0.secret_manager_enabled", "false"),
144145
),
145146
},
146147
{

0 commit comments

Comments
 (0)