AWS Infra
[ AWS CLI ] S3 명령어
Pydole
2021. 11. 4. 21:20
목록보기
$ aws s3 ls
$ aws s3 ls s3://'BucketName' # 버킷내 목록 조회
버킷 생성하기
$ aws s3 mb s3://bucket-name
파일 업로드
$ aws s3 cp 'Filename' s3://'Bucketname' # 파일 업로드
$ aws s3 cp 'Filename' s3://'Bucketname' --acl public-read # public 읽기권한. (버킷ACLs 허용상태)
파일 다운로드
$ aws s3 cp s3://'Bucketname'/'FileName' 'LocalPath'
# 애스터리스트 ( * )
# accesss- 로 시작하는 파일 모두 다운로드
# 매개변수 적용순서는 include 부분부터 적용
$ aws s3 cp s3://['버킷명']['경로'] . --recursive --exclude "*" --include "access-*"
# 패턴 ( [ ] )
# accesslog_202110[1-3]로 시작하는 파일 모두 다운로드
$ aws s3 cp s3://['버킷명']['경로'] . --recursive --exclude "*" --include "accesslog_202110[1-3].log"
기호 | 설명 |
* | Matches everything. (모두 매칭) |
? | Matches any single character. (한자만 매칭) |
[sequence] | Matches any character in sequence. (패턴) |
[!sequence] | Matches any character not in sequence. (패턴 제외) |
https://docs.aws.amazon.com/cli/latest/reference/s3/
s3 — AWS CLI 1.22.73 Command Reference
Note: You are viewing the documentation for an older major version of the AWS CLI (version 1). AWS CLI version 2, the latest major version of AWS CLI, is now stable and recommended for general use. To view this page for the AWS CLI version 2, click here. F
docs.aws.amazon.com
파일삭제
$ aws s3 rm s3://'BucketName'/'FileName'
동기화
$ aws s3 sync 'LocalPath' s3://'BucketName'/'Path' # LocalPath → S3
presign URL (프라이빗 객체에 대해 일시적으로 웹 접근을 허용할 때 사용. 세팅시간만 유효)
# 기본세팅은 3600초
# --expires [초] : 시간 세팅
$ aws s3 presign s3://bucket-name/text.txt --expires 600