AWS Command Line Interface

2 min read

AWS Command Line Interface

AWS Command Line Interface (AWS CLI)는 AWS 명령줄 셸에서 명령을 사용하는 서비스입니다.

macOS 를 사용할때는 homebrew를 사용하여 install 할수 있다.

brew install awscli

위 처럼 인스톨후에

aws configure

명령어를 입력하면 Access key IDSecret access key 입력할수 있다.

실제 파일이 생성되는것은 아래의 정보처럼 생성이 된다.

~/.aws/credentials

[default]
aws_access_key_id=AKIAIOSFODNN7EXAMPLE
aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

~/.aws/config

[default]
region=us-west-2
output=json

S3 명령어

버킷 생성

aws s3 mb <target> [--options]

버킷 및 오브젝트 목록

aws s3 ls <target> [--options]

예제

$ aws s3 ls
2018-12-11 17:08:50 my-bucket
2018-12-14 14:55:44 my-bucket2

$ aws s3 ls s3://bucket-name
                           PRE example/
2018-12-04 19:05:48          3 MyFile1.txt

$ aws s3 ls s3://bucket-name/example/
2018-12-06 18:59:32          3 MyFile1.txt

버킷 삭제

$ aws s3 rb <target> [--options]

전체 삭제를 위해선 --force 옵션을 사용해야 된다.

$ aws s3 rb s3://bucket-name --force

개체 삭제

$ aws s3 rm  <target> [--options]

$ aws s3 rm s3://bucket-name/example

개체 이동

$ aws s3 mv <source> <target> [--options]

개체 복사

$ aws s3 cp <source> <target> [--options]

개체 동기화

$ aws s3 sync <source> <target> [--options]


참조