Skip to content

Previews

An isolated OpenTofu workspace that exists while a PR is open.

PR opened → Preview created, tofu apply
PR updated → Preview updated, tofu apply
PR merged → Production apply, preview destroyed
PR closed → Preview destroyed

Each preview gets:

  • Unique statepreviews/pr-42/terraform.tfstate
  • Namespaced resources — via {{ environment }} variable
resource "aws_s3_bucket" "data" {
bucket = "myapp-${var.environment}"
}

PR #42 creates myapp-pr-42. No collision with PR #99 or production.

PR EventYaffle Action
Openedplanapply to preview
Pushedplanapply to preview
Mergedapply to production → destroy preview
Closeddestroy preview

After apply, outputs are available:

In the GitHub check:

Outputs:
api_url = "https://pr-42.api.example.com"

Via API:

Terminal window
curl https://yaffle.dev/api/previews/pr-42/outputs

In GitHub Actions:

- uses: yaffledev/outputs-action@v1
with:
preview: pr-${{ github.event.pull_request.number }}
StatusMeaning
pendingWaiting for runner
planningRunning terraform plan
applyingRunning terraform apply
readyInfrastructure is up
failedRun failed
destroyingRunning terraform destroy
destroyedCleaned up