secrets file format for AWS ECR

I would like to pull a docker image from a private docker repo on AWS ECR. I found the instructions on how to add a secrets file here:

Both links show examples for Google’s CR, and Docker Hub. Do you have an example for AWS ECR?
Thanks!

2 Likes

A colleague was able to help me out: username = AWS and password = AWS Token.

Here is a script to create the secrets.yml file and run ‘balena deploy’ and pull a docker image from AWS ECR us-east-1 as part of the build:

#!/bin/bash

AWS_ACCOUNT_ID="{add your account number here}"
AWS_REGION="us-east-1"
AWS_TOKEN=$(aws ecr get-login-password --region ${AWS_REGION})
cat <<EOF > secrets.yml
'${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com':
    username: AWS
    password: '${AWS_TOKEN}'
EOF

balena deploy {fleet name} --build --nocache --registry-secrets ./secrets.yml

BTW don’t be surprised if it looks like the command execution stalled - there is no feedback/progress while downloading the docker image from AWS ECR. I was expecting progress similar to the docker pull command but unfortunately there is none.

Thanks @npv12 for sharing your solution.