New to Kestra?
Use blueprints to kickstart your first workflows.
Authenticate with Amazon ECR, pull a private image, and run Python inside it with Kestra. Fresh tokens on every run, no manual ECR login.
id: python-aws-ecr
namespace: company.team
tasks:
- id: ecr
type: io.kestra.plugin.aws.ecr.GetAuthToken
accessKeyId: "{{ secret('AWS_ACCESS_KEY_ID') }}"
secretKeyId: "{{ secret('AWS_SECRET_ACCESS_KEY') }}"
region: eu-central-1
- id: py
type: io.kestra.plugin.scripts.python.Commands
taskRunner:
type: io.kestra.plugin.scripts.runner.docker.Docker
credentials:
username: AWS
password: "{{ outputs.ecr.token }}"
containerImage: 123456789.dkr.ecr.eu-central-1.amazonaws.com/data-infastructure:latest
commands:
- python --version
Run Python (or any command) inside a private container image stored in Amazon Elastic Container Registry (ECR), without manually managing short-lived registry credentials. This blueprint fetches a fresh ECR authorization token, uses it to authenticate the Docker task runner against your private ECR registry, pulls the specified image, and executes your Python commands inside it. It solves the recurring problem of ECR tokens expiring every 12 hours: instead of caching stale credentials or wiring up a custom login step, Kestra mints a valid token on every run.
ecr task (io.kestra.plugin.aws.ecr.GetAuthToken) calls Amazon ECR with your AWS access key and secret key in region eu-central-1 and returns a short-lived authorization token.py task (io.kestra.plugin.scripts.python.Commands) runs on the Docker task runner (io.kestra.plugin.scripts.runner.docker.Docker). Its credentials block authenticates to ECR using username AWS and the password {{ outputs.ecr.token }} piped straight from the first task.containerImage from your private ECR registry and runs the commands list (here, python --version) inside that container.ECR has no scheduler or workflow engine of its own: it stores images and hands out tokens, nothing more. Kestra adds event and schedule triggers, automatic retries, end-to-end execution lineage, and a declarative YAML definition you can version control. The token-then-run handoff via {{ outputs.ecr.token }} is exactly the kind of step-to-step wiring ECR alone cannot express.
ecr:GetAuthorizationToken and pull access to the repository.AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYAWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY secrets to your namespace.region to match your ECR registry.containerImage with your own ECR image URI.commands list to run your script.python --version for a real script, or mount inputs and capture outputs.Schedule or event trigger to run the job on a cadence.