New to Kestra?
Use blueprints to kickstart your first workflows.
Clone a Git repo and run Terraform plan and apply with Kestra to deploy infrastructure as code, with a remote S3 backend, retries, and GitOps triggers.
Run Terraform infrastructure as code straight from a GitHub repository with Kestra. This blueprint clones a Git repo, runs terraform init, terraform plan, and terraform apply in a single isolated working directory, and stores state in a remote S3 backend so your team always plans and applies against shared, consistent state. It closes the gap between writing HCL and actually shipping it: instead of running Terraform from someone's laptop or a brittle CI script, you get a declarative, auditable pipeline that deploys cloud resources on schedule or on every merge.
git task (io.kestra.plugin.core.flow.WorkingDirectory) creates an isolated workspace that keeps the cloned files and Terraform working files together for the run.clone_repository (io.kestra.plugin.git.Clone) clones the repository and main branch.terraform (io.kestra.plugin.terraform.cli.TerraformCLI) runs terraform init via beforeCommands, then terraform plan and terraform apply -auto-approve, piping each through tee into plan_output.txt and apply_output.txt.terraform.tfvars file is injected through inputFiles, supplying the target username, hostname, and a password pulled from a secret. Matching outputFiles (*.txt) capture the plan and apply logs as downloadable artifacts.env so Terraform can reach the remote S3 backend and provision resources.plan and apply logs as run artifacts for review and audit.The Terraform CLI has no scheduler, no retry logic, and no event awareness of its own. Kestra adds event triggers (schedule or a GitHub webhook on merge), automatic retries on transient failures, full run lineage with captured plan and apply logs, and a declarative YAML definition you keep in Git. You orchestrate Terraform alongside the rest of your stack rather than wiring it into a separate CI tool.
CI_CD_PASSWORD: password injected into terraform.tfvars.AWS_ACCESS_KEY_ID: AWS access key for the S3 backend and providers.AWS_SECRET_KEY_ID: AWS secret key paired with the access key.AWS_DEFAULT_REGION: AWS region for the backend and resources.clone_repository at your own repository and branch.terraform.tfvars values to match your configuration.plan_output.txt and apply_output.txt artifacts.Schedule trigger to apply infrastructure on a recurring cadence (GitOps).Webhook trigger to deploy whenever a pull request merges.-chdir flag if your Terraform lives in a subdirectory, for example terraform apply -auto-approve -chdir=environment/production.plan and apply into separate flows gated by a manual approval step.