-
[ AWS CLI ] S3 명령어AWS Infra 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
'AWS Infra' 카테고리의 다른 글
[ AWS ] S3 Bucket policy (0) 2021.12.03 [ AWS ] IAM Policy 특정IP에서 접근시에만 권한 허용 (0) 2021.11.30 [ Python ] paramiko를 이용한 pem-key SSH 접속 (자동화 작업) (0) 2021.11.30 [ AWS ] S3 용량과 객체수 모니터링 (s3api와 python) (0) 2021.11.21 AWS Linux UTC 시간 한국시간으로 변경 (0) 2021.11.13 [ AWS ] IAM Policy 특정 S3만 읽기 / 쓰기 권한 부여 (0) 2021.11.04 [ AWS ] Linux AWS S3 설치 (0) 2021.11.01 [ AWS ] Lambda와 CloudWatch를 이용한 EC2 Start, Stop (0) 2021.10.31