Skip to main content

Complete Example

A minimal but complete configuration that provisions a project, an endpoint, and two destinations.

main.tf

terraform {
required_providers {
webhookr = {
source = "forgers-tech/webhookr"
}
}
}

provider "webhookr" {
api_url = "https://api.webhookr.tech"
# Authentication via WEBHOOKR_API_TOKEN (see below).
}

resource "webhookr_project" "payments" {
name = "payments-prod"
}

resource "webhookr_endpoint" "stripe" {
project_id = webhookr_project.payments.id
name = "Stripe events"
}

resource "webhookr_destination" "orders" {
project_id = webhookr_project.payments.id
endpoint_id = webhookr_endpoint.stripe.id
name = "Order service"
url = "https://orders.internal.example.com/webhooks/stripe"
}

resource "webhookr_destination" "analytics" {
project_id = webhookr_project.payments.id
endpoint_id = webhookr_endpoint.stripe.id
name = "Analytics pipeline"
url = "https://analytics.internal.example.com/ingest"
timeout_ms = 10000

headers = {
"X-Source" = "webhookr"
}
}

output "ingest_url" {
description = "Public URL Stripe should send webhooks to."
value = "${var.api_url}/v1/ingest/${webhookr_endpoint.stripe.slug}"
}

variables.tf

variable "api_url" {
type = string
default = "https://api.webhookr.tech"
}

Apply

export WEBHOOKR_API_URL="https://api.webhookr.tech"
export WEBHOOKR_API_TOKEN="whk_xxxxxxxxxxxxxxxxxxxxxxxx"

terraform init
terraform plan
terraform apply

After apply, Terraform prints the ingest_url output — the address to configure in Stripe (or any provider). Every event it receives fans out to both the Order service and Analytics pipeline destinations.

tip

The endpoint slug is generated by Webhookr, so the ingest URL is only known after the first apply. Reading it from an output (as above) keeps it accurate.

Next