-
Notifications
You must be signed in to change notification settings - Fork 0
AWS ‐ CLI
Installing in windows
Run this in command prompt : msiexec.exe /i https://awscli.amazonaws.com/AWSCLIV2.msi
To configure the profile
Aws configure --profile <profilename>
To get help of service
aws dynamodb help
aws ec2 help
To set default region
aws configure set region us-east-1
To get the EC2 instances
Aws ec2 describe-instances --profile <profilename> --region ca-central-1
To get the users
aws iam list-users --profile <profilename>
To get the dynamodb tables
aws dynamodb list-tables --profile clip1 --region us-east-1
aws ecs create-cluster --cluster-name --region us-east-1
Configuring Ingress for the ECS container - configuring port 80 to be exposed, by enabling in security group aws ec2 authorize-security-group-ingress --group-id --protocol tcp --port 80 --cidr 0.0.0.0/0
aws ecs register-task-definition --cli-input-json file://filename.json
aws ecs create-service --cluster <clster-name> --service-name <name-given-in-above-json> --task-definition <task-def-name>:<version> --desired-count 1 --launch-type "FARGATE" --network-configuration "awsvpcConfiguration={subnets=[],securityGroups=[],assignPublicIp=ENABLED}"
aws ecs list-services --cluster <cluster=name>
aws ecs describe-services --cluster <cluster=name>
To list Amazon Elastic Container Registry (ECR) repositories using AWS CLI, use the following command:
aws ecr describe-repositories --region <region-name>
aws ecr describe-repositories --region us-east-1
This will return a JSON output containing all ECR repositories in us-east-1.
If you only want to see repository names:
aws ecr describe-repositories --query 'repositories[*].repositoryName' --output table
or in a simple list format:
aws ecr describe-repositories --query 'repositories[*].repositoryName' --output text
If you want to see the images inside a repository:
aws ecr list-images --repository-name <your-repository-name> --region <region-name>
Example:
aws ecr list-images --repository-name my-next-app --region us-east-1
To find a specific repository:
aws ecr describe-repositories --query "repositories[?repositoryName=='my-next-app']"
To push a local Docker image to AWS Elastic Container Registry (ECR), follow these steps:
First, authenticate Docker to AWS ECR using the AWS CLI:
aws ecr get-login-password --region <region-name> | docker login --username AWS --password-stdin <aws_account_id>.dkr.ecr.<region-name>.amazonaws.com
🔹 Example for us-east-1
:
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 123456789012.dkr.ecr.us-east-1.amazonaws.com
If you haven't created a repository yet, create one:
aws ecr create-repository --repository-name my-next-app --region <region-name>
🔹 Example:
aws ecr create-repository --repository-name my-next-app --region us-east-1
Tag your local image to match the ECR repository URL:
docker tag <local-image-name>:<tag> <aws_account_id>.dkr.ecr.<region-name>.amazonaws.com/<repository-name>:<tag>
🔹 Example:
docker tag my-next-app:latest 123456789012.dkr.ecr.us-east-1.amazonaws.com/my-next-app:latest
Now, push the image to ECR:
docker push <aws_account_id>.dkr.ecr.<region-name>.amazonaws.com/<repository-name>:<tag>
🔹 Example:
docker push 123456789012.dkr.ecr.us-east-1.amazonaws.com/my-next-app:latest
After pushing the image, verify it using:
aws ecr list-images --repository-name my-next-app --region us-east-1
Now, you can use the image in AWS ECS (Fargate), Kubernetes (EKS), or Lambda (Container Image).
Would you like help deploying it on ECS or Lambda? 🚀
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicRead",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::<bucket-name>/*"
}
]
}