New to Kestra?
Use blueprints to kickstart your first workflows.
Detect Terraform infrastructure drift on a schedule with Kestra. Run terraform plan, parse the detailed exit code, and alert Slack so teams can reconcile fast.
Catch Terraform infrastructure drift before it causes an incident. This blueprint runs terraform plan -detailed-exitcode on a schedule, inspects the exit code, and posts a Slack alert the moment the live cloud state diverges from the configuration in version control. It turns drift detection from an ad hoc check into a continuous, auditable control without standing up a separate CI job or pipeline.
hourly_drift_check io.kestra.plugin.core.trigger.Schedule trigger fires on the configured cron (0 * * * *, disabled by default).plan task (io.kestra.plugin.terraform.cli.TerraformCLI) runs inside the hashicorp/terraform:latest container via the Docker task runner, executes terraform init in beforeCommands, then runs terraform plan -detailed-exitcode -no-color.allowFailure: true lets the non-zero exit code from a drifted plan flow downstream instead of failing the execution.alert_on_drift task (io.kestra.plugin.core.flow.If) evaluates {{ outputs.plan.exitCode == 2 }}. Exit code 2 means changes are pending.notify_drift (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) posts a message to the Slack webhook so the team can review the plan and reconcile.Terraform itself has no scheduler, no native alerting, and no execution history. CI pipelines can run plan on merge, but they miss changes made directly in the cloud console or by other tools. Kestra fills that gap with event and cron triggers, retries, full execution lineage, and declarative YAML you can review, diff, and version. The If task and allowFailure flag let you branch cleanly on the detailed exit code, and outputs are available for downstream tasks (open a ticket, page on-call, store the plan in object storage) without bolting on extra glue.
plan reads real state.AWS_ACCESS_KEY_ID: AWS access key for the provider.AWS_SECRET_ACCESS_KEY: AWS secret key for the provider.SLACK_WEBHOOK_URL: Slack incoming webhook URL for drift alerts.main.tf in inputFiles with your real configuration and remote backend block.hourly_drift_check and set disabled: false to activate the schedule.plan itself errors.inputFiles clone so the flow always plans the latest committed code.