Useful AWS CLI Commands

AWC CLI commands that can help you manage your AWS resources effectively.


Login to AWS ECR

To log in to AWS Elastic Container Registry (ECR), you can use the following command. This command retrieves an authentication token and uses it to authenticate Docker to your registry.

aws ecr get-login-password --region <your-region> | docker login --username AWS --password-stdin <your-account-id>.dkr.ecr.<your-region>.amazonaws.com

Replace <your-region> and <your-account-id> with your specific AWS region and account ID.

Login to AWS CodeArtifact

To log in to AWS CodeArtifact, you can use the following command. This command retrieves an authentication token and configures your package manager to use it.

aws codeartifact login --tool <your-package-manager> --repository <your-repo-name> --domain <your-domain-name> \ 
  --domain-owner <your-account-id> --region <your-region>

Replace <your-region>, <your-account-id>, <your-package-manager>, <your-repo-name>, and <your-domain-name> with your specific AWS region, account ID, package manager (e.g., npm, pip), repository name, and domain name respectively. For dotnet use --tool dotnet