Search code examples
amazon-web-servicesaws-cliamazon-ecr

AWS CLI create ECR repo


I am trying to create a ECR repo with list of tags from the AWS cli. This is the command I am running. I need to pass in the tags as JSON

aws ecr create-repository \
    --repository-name alpha/sample-repo \
    --region us-west-2 \
    --tags [{"Key":"env","Value":"dev"},{"Key":"team","Value":"finance"}]

and getting the below error

Error parsing parameter '--tags': Invalid JSON:
[Key:env]

what am i missing here? How to make it work?


Solution

  • Try enclosing the tags with a single quote

    aws ecr create-repository \
        --repository-name alpha/sample-repo \
        --region us-west-2 \
        --tags '[{"Key":"env","Value":"dev"},{"Key":"team","Value":"finance"}]'