Tofu
Operations

Replay real webhooks into temporary environments

When a CI job or preview deploy exposes a webhook URL, add it as a temporary target, replay a real provider event before payload expiry, and remove the target before the job exits.

Terminal
$ tofu targets add ci-$GITHUB_RUN_ID "$PREVIEW_WEBHOOK_URL" --hook stripe$ tofu replay latest --hook stripe --target ci-$GITHUB_RUN_ID$ tofu targets delete ci-$GITHUB_RUN_ID --hook stripe

Why this helps

The provider keeps the same Tofu URL, while each test run can attach its own target. Webhook tests stay repeatable without creating a new provider endpoint for every branch or preview app.

1. Add target

Name the target with the run ID so concurrent jobs do not collide.

2. Replay

Replay sends a real, signed event so the preview environment exercises the same signature path as production.

3. Clean up

Delete the target on job exit to keep the hook's target list tidy.