sentry_alert_rule.notification_target_id could previously only point at
a target created outside Terraform (sentryctl/curl/the web UI) --
without this resource, "manage alert rules as code" was only half true.
Same create/destroy-only shape as sentry_alert_rule and for the same
reason: alerting has no PUT /targets/{id} either, confirmed down to
notifystore.Store (Create/List/Get/Delete, no Update).
client.go's notificationTarget type mirrors notifystore.Target's JSON
shape. headers stays raw JSON bytes end to end -- the client has no
opinion about its shape (neither does alerting's own Target type,
json.RawMessage), and the resource layer round-trips it as a plain
JSON-text string a caller provides via Terraform's jsonencode().
secret is marked Sensitive in the schema, but alerting's own
GET /targets/{id} returns it unredacted (confirmed in
notifystore/store.go -- no redaction at the store or handler layer, an
existing property of alerting's API, not something this provider
introduces). A new client test
(TestGetNotificationTargetReturnsSecretUnredacted) documents that real
behavior so a future change to it would be caught here, not discovered
by surprise. Sensitive keeps the value out of plan/apply console output;
it does not keep it out of Terraform state, the standard caveat for any
sensitive attribute, named explicitly in the schema description and
README rather than left implicit.
Examples updated end to end: sentry_alert_rule's example now creates a
real sentry_notification_target and references its .id, instead of a
placeholder string.
Verified: client tests are real httptest.Server round trips. Schema
validation needs no Terraform binary.
TestAccNotificationTargetResource_basic is a real acceptance test,
skip-gated by TF_ACC same as the other two, including a
plancheck.ExpectResourceAction assertion that a config change actually
plans destroy-then-create, and (since secret really does round-trip
unredacted) a real ImportStateVerify on the secret attribute rather than
one papered over with ImportStateVerifyIgnore. Not run against a live
stack in this environment, same disclosed gap as everything else
Docker-gated in this repo.
25 lines
802 B
Terraform
25 lines
802 B
Terraform
resource "sentry_notification_target" "ops_webhook" {
|
|
name = "Ops Webhook"
|
|
kind = "webhook"
|
|
webhook_url = "https://ops.example.com/hooks/sentry-alerts"
|
|
|
|
# Optional. Sensitive -- not printed in plan/apply output, but note
|
|
# it's still stored in Terraform state in plaintext (alerting's own
|
|
# GET /targets/{id} returns it unredacted; see the provider README).
|
|
secret = var.ops_webhook_secret
|
|
|
|
# Optional -- must be a JSON object string.
|
|
headers = jsonencode({
|
|
"X-Team" = "platform"
|
|
})
|
|
}
|
|
|
|
variable "ops_webhook_secret" {
|
|
type = string
|
|
sensitive = true
|
|
}
|
|
|
|
# Create/destroy only -- alerting has no PUT /targets/{id} today, so
|
|
# changing any attribute above destroys and recreates the target rather
|
|
# than updating it in place. See the provider README for why.
|