New to Kestra?
Use blueprints to kickstart your first workflows.
Build Docker images and push them to AWS Elastic Container Registry with Kestra. A secure, token-authenticated CI pipeline for automated container builds on AWS.
id: build-aws-ecr-image
namespace: company.team
tasks:
- id: fetch_auth_token
type: io.kestra.plugin.aws.ecr.GetAuthToken
accessKeyId: "{{ secret('AWS_ACCESS_KEY_ID') }}"
secretKeyId: "{{ secret('AWS_SECRET_ACCESS_KEY') }}"
region: "{{ secret('AWS_DEFAULT_REGION') }}"
- id: build
type: io.kestra.plugin.docker.Build
dockerfile: |
FROM python:3.10
RUN pip install --upgrade pip
RUN pip install --no-cache-dir kestra requests "polars[all]"
tags:
- 123456789.dkr.ecr.eu-central-1.amazonaws.com/data-infastructure:latest
push: true
credentials:
username: AWS
password: "{{ outputs.fetch_auth_token.token }}"
Build a Docker image and publish it to Amazon Elastic Container Registry (ECR) in a single declarative Kestra flow, using a short-lived ECR authorization token instead of long-lived registry credentials. This blueprint solves a common CI gap for AWS teams: keeping container builds, registry login, tagging, and push in one auditable pipeline that any downstream service (ECS, EKS, or Kubernetes) can pull from, without wiring together shell scripts and aws ecr get-login-password calls.
fetch_auth_token task (io.kestra.plugin.aws.ecr.GetAuthToken) calls the AWS ECR API to mint a temporary authorization token, authenticating with accessKeyId, secretKeyId, and region pulled from Kestra secrets.build task (io.kestra.plugin.docker.Build) builds an image from an inline dockerfile (here a python:3.10 base with kestra, requests, and polars[all] installed), tags it with the target ECR repository URL, and sets push: true.credentials, using username: AWS and password bound to {{ outputs.fetch_auth_token.token }}, so the freshly minted token flows straight from the first task into the push.ECR itself only stores images; it has no scheduler, no build step, and no way to chain authentication into a push. Kestra fills that gap with event-driven and scheduled triggers, automatic retries on transient registry or network failures, full execution lineage and logs for every build, and declarative YAML that keeps the entire pipeline version-controlled and reviewable. Token generation and image push become explicit, dependent tasks rather than fragile glue scripts.
ecr:GetAuthorizationToken and image push.AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYAWS_DEFAULT_REGION123456789.dkr.ecr.eu-central-1.amazonaws.com/data-infastructure:latest) with your own ECR registry URL, repository, and tag.dockerfile to match the image you want to build.dockerfile for a file-based one checked out from Git earlier in the flow.latest for traceable releases.