Skip to content
Michael O'Brien edited this page Nov 22, 2024 · 3 revisions

AWS

Add awscli2 to macbook

michaelobrien@mbp7 benchmark % brew install awscli
michaelobrien@mbp7 benchmark % brew --prefix awscli
/opt/homebrew/opt/awscli
michaelobrien@mbp7 benchmark % vi ~/.bash_profile
michaelobrien@mbp7 benchmark % source ~/.bash_profile
michaelobrien@mbp7 benchmark % aws --version
aws-cli/2.22.3 Python/3.12.7 Darwin/24.1.0 source/arm64

ECR

ECR Login

ECR push container to repository

michaelobrien@mbp7 benchmark % aws ecr create-repository --repository-name michael20241122
michaelobrien@mbp7 benchmark % aws ecr describe-repositories --repository-names michael20241122 --query 'repositories[*].repositoryUri' --output text
4..0.dkr.ecr.us-east-1.amazonaws.com/michael20241122
michaelobrien@mbp7 benchmark % aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 4..0.dkr.ecr.us-east-1.amazonaws.com
Login Succeeded

michaelobrien@mbp7 benchmark % docker push 45....dkr.ecr.us-east-1.amazonaws.com/michael20241122:latest
The push refers to repository [45...0.dkr.ecr.us-east-1.amazonaws.com/michael20241122]
ed2c1c508fc3: Pushed

michaelobrien@mbp7 benchmark % aws ecr list-images --repository-name michael20241122 
{
    "imageIds": [
        {
            "imageDigest": "sha256:2cd308ac0c85d5a00a86093394c916433d891b6333ea8fbc2d230efced816dec",
            "imageTag": "latest"
        }
    ]
} 

Delete ECR repository

michaelobrien@mbp7 benchmark % aws ecr delete-repository --repository-name michael20241122

An error occurred (RepositoryNotEmptyException) when calling the DeleteRepository operation: The repository with name 'michael20241122' in registry with id '4...0' cannot be deleted because it still contains images

use --force
michaelobrien@mbp7 benchmark % aws ecr delete-repository --repository-name michael20241122 --force
{
    "repository": {
        "repositoryArn": "arn:aws:ecr:us-east-1:4...0:repository/michael20241122",
        "registryId": "4...0",
        "repositoryName": "michael20241122",
        "repositoryUri": "45..0.dkr.ecr.us-east-1.amazonaws.com/michael20241122",
        "createdAt": "2024-11-22T14:13:02.780000-05:00",
        "imageTagMutability": "MUTABLE"
    }
}

check repository is gone
michaelobrien@mbp7 benchmark % aws ecr list-images --repository-name michael20241122        

An error occurred (RepositoryNotFoundException) when calling the ListImages operation: The repository with name 'michael20241122' does not exist in the registry with id '4..0'

Clone this wiki locally