

**이 문서는 AWS CLI의 버전 1에만 해당합니다.**

곧 AWS CLI 버전 1에 대한 지원이 종료될 예정임을 알려드립니다. AWS CLI 버전 2로 마이그레이션하는 것이 좋습니다. 마이그레이션 날짜, 추가 세부 정보 및 방법에 대한 자세한 내용은 [공지 사항](https://aws.amazon.com/blogs/developer/cli-v1-maintenance-mode-announcement/)을 참조하세요. AWS CLI의 버전 2와 관련된 문서는 [버전 2 사용 설명서](https://docs.aws.amazon.com/cli/latest/userguide/)를 참조하세요.

# AWS CLI에서 상위 수준(s3) 명령 사용
<a name="cli-services-s3-commands"></a>

이 주제에서는 AWS CLI에서 [https://docs.aws.amazon.com/cli/v1/reference/s3/index.html](https://docs.aws.amazon.com/cli/v1/reference/s3/index.html) 명령을 사용하여 Amazon S3 버킷과 객체를 관리하는 데 사용할 수 있는 몇 가지 명령을 설명합니다. 이 주제에서 다루지 않은 명령과 추가 명령 예제는 *AWS CLI 참조*에 있는 [https://docs.aws.amazon.com/cli/v1/reference/s3/index.html](https://docs.aws.amazon.com/cli/v1/reference/s3/index.html) 명령을 참조하세요.

상위 수준 `aws s3` 명령은 Amazon S3 객체 관리를 간소화합니다. 이 명령을 사용하면 명령 자체 내에서와 로컬 디렉터리를 사용하여 Amazon S3의 내용을 관리할 수 있습니다.

**Topics**
+ [사전 조건](#using-s3-commands-prereqs)
+ [시작하기 전에](#using-s3-commands-before)
+ [버킷 만들기](#using-s3-commands-managing-buckets-creating)
+ [버킷 및 객체 나열](#using-s3-commands-listing-buckets)
+ [버킷 삭제](#using-s3-commands-delete-buckets)
+ [객체 삭제](#using-s3-commands-delete-objects)
+ [객체 이동](#using-s3-commands-managing-objects-move)
+ [객체 복사](#using-s3-commands-managing-objects-copy)
+ [객체 동기화](#using-s3-commands-managing-objects-sync)
+ [s3 명령에 자주 사용되는 옵션](#using-s3-commands-managing-objects-param)
+ [리소스](#using-s3-commands-managing-buckets-references)

## 사전 조건
<a name="using-s3-commands-prereqs"></a>

`s3` 명령을 실행하려면 다음을 수행해야 합니다.
+ AWS CLI를 설치하고 구성합니다. 자세한 내용은 [AWS CLI 설치, 업데이트 및 제거](cli-chap-install.md) 및 [AWS CLI에 대한 인증 및 액세스 보안 인증](cli-chap-authentication.md) 섹션을 참조하세요.
+ 사용하는 프로파일에는 예제에서 수행하는 AWS 작업을 허용하는 권한이 있어야 합니다.
+ 다음 Amazon S3 용어를 이해하세요.
  + **버킷** - 최상위 Amazon S3 폴더입니다.
  + **접두사** - 버킷의 Amazon S3 폴더입니다.
  + **객체** - Amazon S3 버킷에서 호스팅되는 모든 항목입니다.

## 시작하기 전에
<a name="using-s3-commands-before"></a>

이 섹션에서는 `aws s3` 명령을 사용하기 전에 주의해야 할 몇 가지 사항에 대해 설명합니다.

### 대용량 객체 업로드
<a name="using-s3-commands-before-large"></a>

`aws s3` 명령을 사용하여 Amazon S3 버킷에 대용량 객체를 업로드하면 AWS CLI에서 자동으로 멀티파트 업로드를 수행합니다. 이러한 `aws s3` 명령을 사용할 때는 실패한 업로드를 재개할 수 없습니다.

시간 초과로 인해 멀티파트 업로드가 실패하거나 AWS CLI에서 수동으로 취소할 경우 AWS CLI는 업로드를 중지하고 생성된 모든 파일을 정리합니다. 이 프로세스는 몇 분 정도 걸릴 수 있습니다.

kill 명령이나 시스템 오류로 인해 멀티파트 업로드 또는 정리 프로세스가 취소되면 생성된 파일은 Amazon S3 버킷에 남아 있습니다. 멀티파트 업로드를 정리하려면 [s3api abort-multipart-upload](https://docs.aws.amazon.com/cli/latest/reference/s3api/abort-multipart-upload.html) 명령을 사용합니다.

### 멀티파트 복사의 파일 속성 및 태그
<a name="using-s3-commands-before-tags"></a>

`aws s3` 네임스페이스에서 AWS CLI 버전 1 버전의 명령을 사용하여 한 Amazon S3 버킷 위치에서 다른 Amazon S3 버킷 위치로 파일을 복사하고 해당 작업에서 [멀티파트 복사](https://docs.aws.amazon.com/AmazonS3/latest/userguide/CopyingObjctsMPUapi.html)를 사용하는 경우 소스 객체의 파일 속성은 대상 객체로 복사되지 않습니다.

## 버킷 만들기
<a name="using-s3-commands-managing-buckets-creating"></a>

[https://docs.aws.amazon.com/cli/v1/reference/s3/mb.html](https://docs.aws.amazon.com/cli/v1/reference/s3/mb.html) 명령을 사용하여 버킷을 만듭니다. 버킷 이름은 ***글로벌로*** 고유(모든 Amazon S3에서 고유)해야 하며 DNS를 준수해야 합니다.

버킷 이름에는 소문자, 숫자, 하이픈, 마침표가 포함될 수 있습니다. 버킷 이름은 문자나 숫자로만 시작하고 끝날 수 있으며 하이픈이나 다른 마침표 옆에 마침표가 포함될 수 없습니다.

**구문**:

```
$ aws s3 mb <target> [--options]
```

### s3 mb 예제
<a name="using-s3-commands-managing-buckets-creating-examples"></a>

다음 예제에서는 `s3://amzn-s3-demo-bucket` 버킷을 생성합니다.

```
$ aws s3 mb s3://amzn-s3-demo-bucket
```

## 버킷 및 객체 나열
<a name="using-s3-commands-listing-buckets"></a>

버킷, 폴더 또는 객체를 나열하려면 [https://docs.aws.amazon.com/cli/v1/reference/s3/ls.html](https://docs.aws.amazon.com/cli/v1/reference/s3/ls.html) 명령을 사용합니다. 대상 또는 옵션 없이 명령을 사용하면 모든 버킷이 나열됩니다.

**구문**:

```
$ aws s3 ls <target> [--options]
```

이 명령과 함께 사용할 몇 가지 일반적인 옵션 및 예제는 [s3 명령에 자주 사용되는 옵션](#using-s3-commands-managing-objects-param) 섹션을 참조하세요. 사용 가능한 옵션의 전체 목록은 *AWS CLI 명령 참조*에서 [https://docs.aws.amazon.com/cli/v1/reference/s3/ls.html](https://docs.aws.amazon.com/cli/v1/reference/s3/ls.html) 섹션을 참조하세요.

### s3 ls 예제
<a name="using-s3-commands-managing-objects-list-examples"></a>

다음 예제에서는 모든 Amazon S3 버킷을 나열합니다.

```
$ aws s3 ls
2018-12-11 17:08:50 amzn-s3-demo-bucket1
2018-12-14 14:55:44 amzn-s3-demo-bucket2
```

다음 명령은 버킷에 있는 모든 객체와 접두사를 나열합니다. 이 예제 출력에서 접두사 `example/`에는 `MyFile1.txt`라는 이름의 파일이 하나 있습니다.

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

명령에 특정 접두사를 포함하여 출력을 필터링할 수 있습니다. 다음 명령은 *bucket-name/example/*에 있는 객체(즉, 접두사 *example/*을 기준으로 필터링된 *bucket-name*에 있는 객체)를 나열합니다.

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

특정 리전의 버킷과 객체만 표시하려면 `--region` 옵션을 사용합니다.

```
$ aws s3 ls --region us-east-2
2018-12-06 18:59:32          3 MyFile1.txt
```

버킷 및 객체 목록이 많은 경우 `--max-items` 또는 `--page-size` 옵션을 사용하여 결과를 페이지 매김할 수 있습니다. `--max-items` 옵션은 직접 호출에서 반환되는 총 버킷 및 객체 수를 제한하고 `--page-size` 옵션은 페이지에 나열된 버킷 및 객체 수를 제한합니다.

```
$ aws s3 ls --max-items 100 --page-size 10
```

페이지 매김에 대한 자세한 내용은 [--page-size 파라미터를 사용하는 방법](cli-usage-pagination.md#cli-usage-pagination-pagesize) 및 [--max-items 파라미터를 사용하는 방법](cli-usage-pagination.md#cli-usage-pagination-maxitems) 섹션을 참조하세요.

## 버킷 삭제
<a name="using-s3-commands-delete-buckets"></a>

버킷을 삭제하려면 [https://docs.aws.amazon.com/cli/v1/reference/s3/rb.html](https://docs.aws.amazon.com/cli/v1/reference/s3/rb.html) 명령을 사용합니다.

**구문**:

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

### s3 rb 예제
<a name="using-s3-commands-removing-buckets-examples"></a>

다음 예제에서는 `s3://amzn-s3-demo-bucket` 버킷을 제거합니다.

```
$ aws s3 rb s3://amzn-s3-demo-bucket
```

기본적으로 작업에 성공하려면 버킷이 비어 있어야 합니다. 비어 있지 않은 버킷을 제거하려면 `--force` 옵션을 포함시켜야 합니다. 이전에 삭제했지만 보관된 객체가 포함되어 있는 버전 지정된 버킷을 사용할 경우 이 명령을 사용하여 버킷을 제거할 수 *없습니다*. 먼저 모든 내용을 제거해야 합니다.

다음 예제에서는 버킷의 모든 객체와 접두사를 삭제한 다음 버킷을 삭제합니다.

```
$ aws s3 rb s3://amzn-s3-demo-bucket --force
```

## 객체 삭제
<a name="using-s3-commands-delete-objects"></a>

버킷이나 로컬 디렉터리의 객체를 삭제하려면 [https://docs.aws.amazon.com/cli/v1/reference/s3/rm.html](https://docs.aws.amazon.com/cli/v1/reference/s3/rm.html) 명령을 사용합니다.

**구문**:

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

이 명령과 함께 사용할 몇 가지 일반적인 옵션 및 예제는 [s3 명령에 자주 사용되는 옵션](#using-s3-commands-managing-objects-param) 섹션을 참조하세요. 전체 옵션 목록은 *AWS CLI 명령 참조*에서 [https://docs.aws.amazon.com/cli/v1/reference/s3/rm.html](https://docs.aws.amazon.com/cli/v1/reference/s3/rm.html) 섹션을 참조하세요.

### s3 rm 예제
<a name="using-s3-commands-delete-objects-examples"></a>

다음 예제에서는 `filename.txt`에서 `s3://amzn-s3-demo-bucket/example` 파일을 삭제합니다.

```
$ aws s3 rm s3://amzn-s3-demo-bucket/example/filename.txt
```

다음 예제에서는 `s3://amzn-s3-demo-bucket/example` 옵션을 사용하여 `--recursive`에서 모든 객체를 삭제합니다.

```
$ aws s3 rm s3://amzn-s3-demo-bucket/example --recursive
```

## 객체 이동
<a name="using-s3-commands-managing-objects-move"></a>

[https://docs.aws.amazon.com/cli/v1/reference/s3/mv.html](https://docs.aws.amazon.com/cli/v1/reference/s3/mv.html) 명령을 사용하여 버킷이나 로컬 디렉터리에서 객체를 이동합니다. `s3 mv` 명령은 소스 객체 또는 파일을 지정된 대상에 복사한 다음 소스 객체 또는 파일을 삭제합니다.

**구문**:

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

이 명령과 함께 사용할 몇 가지 일반적인 옵션 및 예제는 [s3 명령에 자주 사용되는 옵션](#using-s3-commands-managing-objects-param) 섹션을 참조하세요. 사용 가능한 옵션의 전체 목록은 *AWS CLI 명령 참조*에서 [https://docs.aws.amazon.com/cli/v1/reference/s3/mv.html](https://docs.aws.amazon.com/cli/v1/reference/s3/mv.html) 섹션을 참조하세요.

**주의**  
Amazon S3 소스 또는 대상 URI에서 어떤 유형의 액세스 포인트 ARN 또는 액세스 포인트 별칭을 사용하는 경우, 소스 및 대상 Amazon S3 URI가 서로 다른 기본 버킷으로 확인되도록 각별히 주의해야 합니다. 소스 버킷과 대상 버킷이 동일한 경우 소스 파일이나 객체를 그 자체로 옮길 수 있어 실수로 소스 파일이나 객체가 삭제될 수 있습니다. 소스 버킷과 대상 버킷이 동일하지 않은지 확인하려면 `--validate-same-s3-paths` 파라미터를 사용하거나 환경 변수 ``AWS_CLI_S3_MV_VALIDATE_SAME_S3_PATHS``를 `true`로 설정하세요.

### s3 mv 예제
<a name="using-s3-commands-managing-objects-move-examples"></a>

다음 예제에서는 `s3://amzn-s3-demo-bucket/example`에서 모든 객체를 `s3://amzn-s3-demo-bucket/`으로 이동합니다.

```
$ aws s3 mv s3://amzn-s3-demo-bucket/example s3://amzn-s3-demo-bucket/
```

다음 예제에서는 `s3 mv` 명령을 사용하여 현재 작업 디렉터리에서 Amazon S3 버킷으로 로컬 파일을 이동합니다.

```
$ aws s3 mv filename.txt s3://amzn-s3-demo-bucket
```

다음 예제에서는 Amazon S3 버킷에서 현재 작업 디렉터리로 파일을 이동합니다. 여기서 `./`는 현재 작업 디렉터리를 지정합니다.

```
$ aws s3 mv s3://amzn-s3-demo-bucket/filename.txt ./
```

## 객체 복사
<a name="using-s3-commands-managing-objects-copy"></a>

[https://docs.aws.amazon.com/cli/v1/reference/s3/cp.html](https://docs.aws.amazon.com/cli/v1/reference/s3/cp.html) 명령을 사용하여 버킷이나 로컬 디렉터리에서 객체를 복사합니다.

**구문**:

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

표준 입력(`stdin`) 또는 표준 출력(`stdout`)으로의 파일 스트리밍을 위해 dash 파라미터를 사용할 수 있습니다.

**주의**  
PowerShell을 사용하는 경우 셸은 CRLF의 인코딩을 변경하거나, 파이프 입력이나 출력 또는 리디렉션된 출력에 CRLF를 추가할 수 있습니다.

`s3 cp` 명령은 다음 구문을 사용하여 `stdin`에서 지정된 버킷으로 파일 스트림을 업로드합니다.

**구문**:

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

`s3 cp` 명령은 다음 구문을 사용하여 `stdout`에 대한 Amazon S3 파일 스트림을 다운로드합니다.

**구문**:

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

이 명령과 함께 사용할 몇 가지 일반적인 옵션 및 예제는 [s3 명령에 자주 사용되는 옵션](#using-s3-commands-managing-objects-param) 섹션을 참조하세요. 전체 옵션 목록은 *AWS CLI 명령 참조*에서 [https://docs.aws.amazon.com/cli/v1/reference/s3/cp.html](https://docs.aws.amazon.com/cli/v1/reference/s3/cp.html) 섹션을 참조하세요.

### `s3 cp` 예제
<a name="using-s3-commands-managing-objects-copy-examples"></a>

다음 예제에서는 `s3://amzn-s3-demo-bucket/example`에서 `s3://amzn-s3-demo-bucket/`으로 모든 객체를 복사합니다.

```
$ aws s3 cp s3://amzn-s3-demo-bucket/example s3://amzn-s3-demo-bucket/
```

다음 예제에서는 `s3 cp` 명령을 사용하여 현재 작업 디렉터리에서 Amazon S3 버킷으로 로컬 파일을 복사합니다.

```
$ aws s3 cp filename.txt s3://amzn-s3-demo-bucket
```

다음 예제에서는 Amazon S3 버킷에서 현재 작업 디렉터리로 파일을 복사합니다. 여기서 `./`는 현재 작업 디렉터리를 지정합니다.

```
$ aws s3 cp s3://amzn-s3-demo-bucket/filename.txt ./
```

다음 예제에서는 echo를 사용하여 "hello world" 텍스트를 `s3://bucket-name/filename.txt` 파일로 스트리밍합니다.

```
$ echo "hello world" | aws s3 cp - s3://amzn-s3-demo-bucket/filename.txt
```

다음 예제에서는 `s3://amzn-s3-demo-bucket/filename.txt` 파일을 `stdout`으로 스트리밍하고 내용을 콘솔로 인쇄합니다.

```
$ aws s3 cp s3://amzn-s3-demo-bucket/filename.txt -
hello world
```

다음 예제에서는 `s3://bucket-name/pre`의 내용을 `stdout`으로 스트리밍하고, `bzip2` 명령을 사용하여 파일을 압축하고 `key.bz2`라는 새 압축 파일을 `s3://bucket-name`에 업로드합니다.

```
$ aws s3 cp s3://amzn-s3-demo-bucket/pre - | bzip2 --best | aws s3 cp - s3://amzn-s3-demo-bucket/key.bz2
```

## 객체 동기화
<a name="using-s3-commands-managing-objects-sync"></a>

[https://docs.aws.amazon.com/cli/v1/reference/s3/sync.html](https://docs.aws.amazon.com/cli/v1/reference/s3/sync.html) 명령은 버킷과 디렉터리의 콘텐츠 또는 두 버킷의 콘텐츠를 동기화합니다. 일반적으로 `s3 sync`는 원본과 대상 간에 누락되거나 오래된 파일 또는 객체를 복사합니다. 하지만 `--delete` 옵션을 제공하여 원본에 없는 파일이나 객체를 대상에서 제거할 수도 있습니다.

**구문**:

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

이 명령과 함께 사용할 몇 가지 일반적인 옵션 및 예제는 [s3 명령에 자주 사용되는 옵션](#using-s3-commands-managing-objects-param) 섹션을 참조하세요. 전체 옵션 목록은 *AWS CLI 명령 참조*에서 [https://docs.aws.amazon.com/cli/v1/reference/s3/sync.html](https://docs.aws.amazon.com/cli/v1/reference/s3/sync.html) 섹션을 참조하세요.

### s3 동기화 예제
<a name="using-s3-commands-managing-objects-sync-examples"></a>

다음 예제에서는 *amzn-s3-demo-bucket*이라는 버킷에 있는 *path*라는 Amazon S3 접두사의 내용을 현재 작업 디렉터리와 동기화합니다.

`s3 sync`는 대상에 있는 동일한 이름의 파일과 크기 또는 수정 시간이 다른 모든 파일을 업데이트합니다. 출력에는 동기화 중에 수행된 특정 작업이 표시됩니다. 이 작업은 하위 디렉터리 `MySubdirectory`와 해당 내용을 `s3://amzn-s3-demo-bucket/path/MySubdirectory`와 반복적으로 동기화합니다.

```
$ aws s3 sync . s3://amzn-s3-demo-bucket/path
upload: MySubdirectory\MyFile3.txt to s3://amzn-s3-demo-bucket/path/MySubdirectory/MyFile3.txt
upload: MyFile2.txt to s3://amzn-s3-demo-bucket/path/MyFile2.txt
upload: MyFile1.txt to s3://amzn-s3-demo-bucket/path/MyFile1.txt
```

다음 예제에서는 이전 예제를 확장하여 `--delete` 옵션을 사용하는 방법을 보여줍니다.

```
// Delete local file
$ rm ./MyFile1.txt

// Attempt sync without --delete option - nothing happens
$ aws s3 sync . s3://amzn-s3-demo-bucket/path

// Sync with deletion - object is deleted from bucket
$ aws s3 sync . s3://amzn-s3-demo-bucket/path --delete
delete: s3://amzn-s3-demo-bucket/path/MyFile1.txt

// Delete object from bucket
$ aws s3 rm s3://amzn-s3-demo-bucket/path/MySubdirectory/MyFile3.txt
delete: s3://amzn-s3-demo-bucket/path/MySubdirectory/MyFile3.txt

// Sync with deletion - local file is deleted
$ aws s3 sync s3://amzn-s3-demo-bucket/path . --delete
delete: MySubdirectory\MyFile3.txt

// Sync with Infrequent Access storage class
$ aws s3 sync . s3://amzn-s3-demo-bucket/path --storage-class STANDARD_IA
```

`--delete` 옵션을 사용할 때 `--exclude` 및 `--include` 옵션은 `s3 sync` 작업 중에 삭제할 파일 또는 객체를 필터링할 수 있습니다. 이 경우 파라미터 문자열은 대상 디렉터리 또는 버킷의 맥락에서 삭제에서 제외하거나 삭제를 위해 포함할 파일을 지정해야 합니다. 다음은 그 한 예입니다.

```
Assume local directory and s3://amzn-s3-demo-bucket/path currently in sync and each contains 3 files:
MyFile1.txt
MyFile2.rtf
MyFile88.txt
'''

// Sync with delete, excluding files that match a pattern. MyFile88.txt is deleted, while remote MyFile1.txt is not.
$ aws s3 sync . s3://amzn-s3-demo-bucket/path --delete --exclude "path/MyFile?.txt"
delete: s3://amzn-s3-demo-bucket/path/MyFile88.txt
'''

// Sync with delete, excluding MyFile2.rtf - local file is NOT deleted
$ aws s3 sync s3://amzn-s3-demo-bucket/path . --delete --exclude "./MyFile2.rtf"
download: s3://amzn-s3-demo-bucket/path/MyFile1.txt to MyFile1.txt
'''

// Sync with delete, local copy of MyFile2.rtf is deleted
$ aws s3 sync s3://amzn-s3-demo-bucket/path . --delete
delete: MyFile2.rtf
```

## s3 명령에 자주 사용되는 옵션
<a name="using-s3-commands-managing-objects-param"></a>

다음 옵션은 이 주제에서 설명하는 명령에 자주 사용됩니다. 명령에 사용할 수 있는 옵션의 전체 목록은 [AWS CLI 참조 가이드](https://docs.aws.amazon.com/cli/v1/reference/)의 특정 명령을 참조하세요.

**acl**  
`s3 sync` 및 `s3 cp`는 `--acl` 옵션을 사용할 수 있습니다. 이렇게 하면 Amazon S3에 복사된 파일에 대한 액세스 권한을 설정할 수 있습니다. `--acl` 옵션에는 `private`, `public-read` 및 `public-read-write` 값을 적용할 수 있습니다. 자세한 내용은 *Amazon S3 사용 설명서*의 [미리 제공된 ACL](https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html#canned-acl)을 참조하세요.  

```
$ aws s3 sync . s3://amzn-s3-demo-bucket/path --acl public-read
```

**exclude**  
`s3 cp`, `s3 mv`, `s3 sync` 또는 `s3 rm` 명령을 사용하는 경우 `--exclude` 또는 `--include` 옵션을 사용하여 결과를 필터링할 수 있습니다. `--exclude` 옵션은 명령에서 객체만 제외하도록 규칙을 설정하고 옵션은 지정된 순서대로 적용됩니다. 방법은 다음 예제와 같습니다.  

```
Local directory contains 3 files:
MyFile1.txt
MyFile2.rtf
MyFile88.txt

// Exclude all .txt files, resulting in only MyFile2.rtf being copied
$ aws s3 cp . s3://amzn-s3-demo-bucket/path --exclude "*.txt"

// Exclude all .txt files but include all files with the "MyFile*.txt" format, resulting in, MyFile1.txt, MyFile2.rtf, MyFile88.txt being copied
$ aws s3 cp . s3://amzn-s3-demo-bucket/path --exclude "*.txt" --include "MyFile*.txt"

// Exclude all .txt files, but include all files with the "MyFile*.txt" format, but exclude all files with the "MyFile?.txt" format resulting in, MyFile2.rtf and MyFile88.txt being copied
$ aws s3 cp . s3://amzn-s3-demo-bucket/path --exclude "*.txt" --include "MyFile*.txt" --exclude "MyFile?.txt"
```

**포함**  
`s3 cp`, `s3 mv`, `s3 sync` 또는 `s3 rm` 명령을 사용하는 경우 `--exclude` 또는 `--include` 옵션을 사용하여 결과를 필터링할 수 있습니다. `--include` 옵션은 명령에 지정된 객체만 포함하도록 규칙을 설정하며 옵션은 지정된 순서대로 적용됩니다. 방법은 다음 예제와 같습니다.  

```
Local directory contains 3 files:
MyFile1.txt
MyFile2.rtf
MyFile88.txt

// Include all .txt files, resulting in MyFile1.txt and MyFile88.txt being copied
$ aws s3 cp . s3://amzn-s3-demo-bucket/path --include "*.txt"

// Include all .txt files but exclude all files with the "MyFile*.txt" format, resulting in no files being copied
$ aws s3 cp . s3://amzn-s3-demo-bucket/path --include "*.txt" --exclude "MyFile*.txt"

// Include all .txt files, but exclude all files with the "MyFile*.txt" format, but include all files with the "MyFile?.txt" format resulting in MyFile1.txt being copied

$ aws s3 cp . s3://amzn-s3-demo-bucket/path --include "*.txt" --exclude "MyFile*.txt" --include "MyFile?.txt"
```

**권한 부여**  
`s3 cp`, `s3 mv` 및 `s3 sync` 명령에는 지정된 사용자 또는 그룹에게 객체에 대한 권한을 부여하기 위해 사용할 수 있는 `--grants` 옵션이 포함됩니다. 다음 구문을 사용하여 `--grants` 옵션을 권한 목록으로 설정합니다. `Permission`, `Grantee_Type` 및 `Grantee_ID`를 사용자의 값으로 바꿉니다.  
**구문**:  

```
--grants Permission=Grantee_Type=Grantee_ID
         [Permission=Grantee_Type=Grantee_ID ...]
```
각 값에는 다음 요소가 포함됩니다.  
+ *Permission* - 부여된 권한을 지정합니다. `read`, `readacl`, `writeacl` 또는 `full`로 설정할 수 있습니다.
+ *Grantee\$1Type* - 피부여자 식별 방법을 지정합니다. `uri`, `emailaddress` 또는 `id`로 설정할 수 있습니다.
+ *Grantee\$1ID* - *Grantee\$1Type*을 기준으로 피부여자를 지정합니다.
  + `uri` – 그룹의 URI입니다. 자세한 내용은 [피부여자란?](https://docs.aws.amazon.com/AmazonS3/latest/userguide/ACLOverview.html#SpecifyingGrantee)을 참조하세요.
  + `emailaddress` - 계정의 이메일 주소입니다.
  + `id` - 계정의 정식 ID입니다.
Amazon S3 액세스 제어에 대한 자세한 내용은 [액세스 제어](https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingAuthAccess.html)를 참조하세요.  
다음 예제에서는 버킷에 객체를 복사합니다. 여기서는 모든 사람에게 객체에 대한 `read` 권한을 부여하고 `full`과 연결된 계정에 `read` 권한(`readacl`, `writeacl` 및 `user@example.com`)을 부여합니다.  

```
$ aws s3 cp file.txt s3://amzn-s3-demo-bucket/ --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers full=emailaddress=user@example.com
```
Amazon S3에 업로드하는 객체에 대해 기본값이 아닌 스토리지 클래스(`REDUCED_REDUNDANCY` 또는 `STANDARD_IA`)를 지정할 수도 있습니다. 이렇게 하려면 `--storage-class` 옵션을 사용합니다.  

```
$ aws s3 cp file.txt s3://amzn-s3-demo-bucket/ --storage-class REDUCED_REDUNDANCY
```

**recursive**  
이 옵션을 사용하면 지정된 디렉터리 또는 접두사 아래의 모든 파일 또는 객체에 대해 명령이 수행됩니다. 다음 예제에서는 `s3://amzn-s3-demo-bucket/path` 및 모든 내용을 삭제합니다.  

```
$ aws s3 rm s3://amzn-s3-demo-bucket/path --recursive
```

## 리소스
<a name="using-s3-commands-managing-buckets-references"></a>

**AWS CLI 참조:** 
+ [https://docs.aws.amazon.com/cli/v1/reference/s3/index.html](https://docs.aws.amazon.com/cli/v1/reference/s3/index.html)
+ [https://docs.aws.amazon.com/cli/v1/reference/s3/cp.html](https://docs.aws.amazon.com/cli/v1/reference/s3/cp.html)
+ [https://docs.aws.amazon.com/cli/v1/reference/s3/mb.html](https://docs.aws.amazon.com/cli/v1/reference/s3/mb.html)
+ [https://docs.aws.amazon.com/cli/v1/reference/s3/mv.html](https://docs.aws.amazon.com/cli/v1/reference/s3/mv.html)
+ [https://docs.aws.amazon.com/cli/v1/reference/s3/ls.html](https://docs.aws.amazon.com/cli/v1/reference/s3/ls.html)
+ [https://docs.aws.amazon.com/cli/v1/reference/s3/rb.html](https://docs.aws.amazon.com/cli/v1/reference/s3/rb.html)
+ [https://docs.aws.amazon.com/cli/v1/reference/s3/rm.html](https://docs.aws.amazon.com/cli/v1/reference/s3/rm.html)
+ [https://docs.aws.amazon.com/cli/v1/reference/s3/sync.html](https://docs.aws.amazon.com/cli/v1/reference/s3/sync.html)

**서비스 참조:**
+ **Amazon S3 사용 설명서의 [Amazon S3 버킷 작업](https://docs.aws.amazon.com//AmazonS3/latest/userguide/UsingBucket.html)
+ **Amazon S3 사용 설명서의 [Amazon S3 버킷 작업](https://docs.aws.amazon.com//AmazonS3/latest/userguide/UsingObjects.html)
+ **Amazon S3 사용 설명서의 [접두사 및 구분 기호를 사용하여 계층적 구조로 키 나열](https://docs.aws.amazon.com//AmazonS3/latest/userguide/ListingKeysHierarchy.html)
+ **Amazon S3 사용 설명서의 [AWS SDK for .NET(낮은 수준)를 사용하여 S3 버킷에 대한 멀티파트 업로드 중단](https://docs.aws.amazon.com//AmazonS3/latest/userguide/LLAbortMPUnet.html)