Overivew
오늘은 awscli에 대해서 정리해보려고 한다.
awscli 설치
# Version 2 설치 방법
$ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
$ unzip awscliv2.zip
$ sudo ./aws/install
$ ./aws/install -i /usr/local/aws-cli -b /usr/local/bin
$ aws --version
$ aws-cli/2.11.15 Python/3.11.3 Linux/5.15.90.1-microsoft-standard-WSL2 exe/x86_64.ubuntu.22 prompt/off
# 기존 awscli 업데이트 방법
$ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
$ unzip awscliv2.zip
$ sudo ./aws/install --bin-dir /usr/local/bin --install-dir /usr/local/aws-cli --update
# 업그레이드 성공!
somaz@AD01769994:~$ aws --version
aws-cli/2.11.6 Python/3.11.2 Linux/5.10.16.3-microsoft-standard-WSL2 exe/x86_64.ubuntu.20 prompt/off
aws configure 구성
계정이 한개일 때(default)
$ aws configure
AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: <Enter> or ex. ap-northeast-2
Default output format [None]: <Enter>
계정이 2개 이상일때
$ aws configure --profile <ID>
AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: <Enter> or ex. ap-northeast-2
Default output format [None]: <Enter>
aws configure 구성 확인
somaz@AD01769994:~$ aws configure list
Name Value Type Location
---- ----- ---- --------
profile <not set> None None
access_key ****************MPLE shared-credentials-file
secret_key ****************MPLG shared-credentials-file
region ap-northeast-2 config-file ~/.aws/config
somaz@AD01769994:~$ aws configure list --profile somaz
Name Value Type Location
---- ----- ---- --------
profile luxon manual --profile
access_key ****************MPLE shared-credentials-file
secret_key ****************MPLG shared-credentials-file
region <not set> None None
자주쓰는 AWS CLI 명령어
AWS EC2 (Elastic Compute Cloud)
List instances
aws ec2 describe-instances
# profile 사용하기
aws ec2 describe-instances --profile <ID>
Start an instance
aws ec2 start-instances --instance-ids <instance id>
Stop an instance
aws ec2 stop-instances --instance-ids <instance id>
aws ec2 terminate-instances --instance-ids <instance id>
AWS S3 (Simple Storage Service)
List buckets
aws s3 ls
List objects in a bucket
aws s3 ls s3://<bucket-name>
Copy a file to a bucket
aws s3 cp <local-file> s3://<bucket-name>/<object-name>
Copy a directory to a bucket
aws s3 cp <local-file> s3://<bucket-name>/<directory-name> --recursive
Copy a file from a bucket
aws s3 cp s3://<bucket-name>/<object-name> <Name to save to local>
Copy a directory from a bucket
aws s3 cp s3://<bucket-name>/<directory-name> <Name to save to local> --recursive
Delete an object from a bucket
aws s3 rm s3://<bucket-name>/<object-name>
AWS IAM (Identity and Access Management)
List users
aws iam list-users
List roles
aws iam list-roles
Create a user
aws iam create-user --user-name <user-name>
Attach a policy to a user
aws iam attach-user-policy --user-name <user-name> --policy-arn <policy-arn>
Delete a user
aws iam delete-user --user-name <user-name>
AWS ECR (Elastic Container Registry)
List repositories
aws ecr describe-repositories
Create a repository
aws ecr create-repository --repository-name <repository-name>
Delete a repository
aws ecr delete-repository --repository-name <repository-name>
Get the login command for a registry
aws ecr get-login-password --region <region> | docker login --username AWS --password-stdin <aws-account-id>.dkr.ecr.<region>.amazonaws.com
AWS EKS (Elastic Kubernetes Service)
List clusters
aws eks list-clusters
Describe a cluster
aws eks describe-cluster --name <cluster-name>
Create a cluster
aws eks create-cluster --name <cluster-name> --role-arn <role-arn> --resources-vpc-config subnetIds=<subnet-id1>,<subnet-id2>
Delete a cluster
aws eks delete-cluster --name <cluster-name>
Reference
What is AWS Command Line Interface?
AWS CLI Command Reference
AWS CLI로 Application Load Balancer 생성해 보기
'AWS' 카테고리의 다른 글
AWS Cloudfront란? / Canary 및 Blue-Green 배포 (0) | 2023.04.03 |
---|---|
AWS Secrets Manager란?(OAuth, SSO) (0) | 2023.04.01 |
AWS IAM이란? (0) | 2023.03.30 |
AWS S3 권한이란? (0) | 2023.03.29 |
AWS S3란?(개념, 속성) (0) | 2023.03.28 |