New to Kestra?
Use blueprints to kickstart your first workflows.
Automate infrastructure with Kestra: build a Docker image, run it as a container, and provision files with Terraform in one declarative pipeline.
Automate an end-to-end infrastructure workflow that builds a Docker image, runs it as a container, and provisions resources with Terraform, all from a single declarative Kestra flow. This getting started example shows how to wire image builds, container execution, and Infrastructure as Code together so your DevOps automation runs as one reproducible pipeline instead of disconnected scripts and manual steps.
build_image uses io.kestra.plugin.docker.Build to build a Docker image from an inline Dockerfile (Python 3.11 Alpine with the kestra package installed). The image tag comes from the docker_image input, and registry credentials are supplied as secrets so the image can be pushed once push is set to true.run_container uses io.kestra.plugin.docker.Run with pullPolicy: NEVER to run the freshly built local image and inspect the installed Kestra package via pip show kestra.run_terraform uses io.kestra.plugin.terraform.cli.TerraformCLI to run terraform init, plan, and apply -auto-approve. The inline main.tf fetches Pokémon data over HTTP and writes a formatted pokemon.txt file, captured through outputFiles.log_pokemon uses io.kestra.plugin.core.log.Log to read and log the generated pokemon.txt, verifying the automation worked end to end.plan_output.txt, apply_output.txt, pokemon.txt) surfaced as task outputs.Docker and Terraform each run a single step well, but neither sequences a build, a container run, and a provisioning apply together with shared inputs and outputs. Kestra adds event triggers, automatic retries, full execution lineage, and a declarative YAML definition that ties these tools into one auditable workflow. You get a single source of truth for the whole pipeline instead of glue scripts, plus the ability to schedule, trigger, and observe every run.
DOCKERHUB_USERNAME: Docker registry username (used when pushing the image).DOCKERHUB_PASSWORD: Docker registry password or access token.DOCKERHUB_USERNAME and DOCKERHUB_PASSWORD secrets to your Kestra instance.docker_image input tag.push: true on build_image to publish the image to your registry.main.tf with your own Terraform provisioning real cloud resources.pip show kestra command for your own container smoke test.