Create AWS ECR repository if it doesn't exist

Ysak picture Ysak · Jun 25, 2018 · Viewed 8.3k times · Source

How can I create an AWS ECR repository if it doesn't already exist?

Answer

James Soubry picture James Soubry · May 16, 2019

One liner to create a repo if it doesn't exist:

aws ecr describe-repositories --repository-names ${REPO_NAME} || aws ecr create-repository --repository-name ${REPO_NAME}