

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

API 수준 명령(`s3api` 명령 세트에 포함됨)을 사용하면 Amazon Simple Storage Service(Amazon S3) API에 직접 액세스할 수 있으며 상위 수준 `s3` 명령에 표시되지 않는 일부 작업을 활성화할 수 있습니다. 이러한 명령은 서비스의 기능에 대한 API 수준 액세스를 제공하는 다른 AWS 서비스와 동등합니다. `s3` 명령어에 대한 자세한 내용은 [AWS CLI에서 상위 수준(s3) 명령 사용](cli-services-s3-commands.md) 섹션을 참조하세요.

이 주제에서는 Amazon S3 API에 매핑되는 하위 수준 명령을 사용하는 방법을 보여주는 예제를 제공합니다. 또한 각 S3 API 명령에 대한 예제는 [AWS CLI 버전 2 참조 가이드](https://docs.aws.amazon.com/cli/latest/reference/s3api/index.html)의 `s3api` 섹션에서 찾을 수 있습니다.

**Topics**
+ [사전 조건](#cli-services-s3-apicommands-prereqs)
+ [사용자 지정 ACL 적용](#cli-services-s3-apicommands-acls)
+ [로깅 정책 구성](#cli-services-s3-apicommands-logpol)
+ [리소스](#cli-services-s3-apicommands-resources)

## 사전 조건
<a name="cli-services-s3-apicommands-prereqs"></a>

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

## 사용자 지정 ACL 적용
<a name="cli-services-s3-apicommands-acls"></a>

고급 명령을 사용하면 `--acl` 옵션을 사용하여 Amazon S3 객체에 미리 정의된 액세스 제어 목록(ACL)을 적용할 수 있습니다. 그러나 이 명령을 사용해도 버킷 전체 ACL을 설정할 수는 없습니다. 그러나 ```[put-bucket-acl](https://docs.aws.amazon.com/cli/latest/reference/s3api/put-bucket-acl.html)` API 수준 명령을 사용하여 이 작업을 수행할 수 있습니다.

다음 예제에서는 두 명의 AWS 사용자(*user1@example.com* 및 *user2@example.com*)에게 전체 제어 권한을 부여하고 모든 사람에게 읽기 권한을 부여하는 방법을 보여줍니다. "모든 사람"의 식별자는 파라미터로 전달하는 특수 URI에서 가져옵니다.

```
$ aws s3api put-bucket-acl --bucket {{amzn-s3-demo-bucket}} --grant-full-control 'emailaddress="{{user1@example.com}}",emailaddress="{{user2@example.com}}"' --grant-read 'uri="http://acs.amazonaws.com/groups/global/AllUsers"'
```

ACL을 구성하는 방법에 대한 자세한 내용은 *Amazon Simple Storage Service API 참조*에서 [PUT Bucket acl](https://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTacl.html)을 참조하세요. CLI에서 `s3api`와 같은 `put-bucket-acl` ACL 명령은 동일한 [간편 인수 표기법](https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-shorthand.html)을 사용합니다.

## 로깅 정책 구성
<a name="cli-services-s3-apicommands-logpol"></a>

API 명령인 `put-bucket-logging`은 버킷 로깅 정책을 구성합니다.

다음 예제에서 AWS 사용자 *user@example.com*에게는 로그 파일을 완전히 제어하는 권한이 부여되며, 모든 사용자는 읽기 액세스 권한을 갖게 됩니다. 로그를 읽고 버킷에 쓰는 데 필요한 권한을 Amazon S3 로그 전달 시스템(URI로 지정)에 부여하려는 경우에도 `put-bucket-acl` 명령이 필요합니다.

```
$ aws s3api put-bucket-acl --bucket {{amzn-s3-demo-bucket}} --grant-read-acp 'URI="http://acs.amazonaws.com/groups/s3/LogDelivery"' --grant-write 'URI="http://acs.amazonaws.com/groups/s3/LogDelivery"'
$ aws s3api put-bucket-logging --bucket {{amzn-s3-demo-bucket}} --bucket-logging-status file://logging.json
```

이전 명령의 `logging.json` 파일에도 다음 내용이 있습니다.

```
{
  "LoggingEnabled": {
    "TargetBucket": "amzn-s3-demo-bucket",
    "TargetPrefix": "amzn-s3-demo-bucketLogs/",
    "TargetGrants": [
      {
        "Grantee": {
          "Type": "AmazonCustomerByEmail",
          "EmailAddress": "{{user@example.com}}"
        },
        "Permission": "FULL_CONTROL"
      },
      {
        "Grantee": {
          "Type": "Group",
          "URI": "http://acs.amazonaws.com/groups/global/AllUsers"
        },
        "Permission": "READ"
      }
    ]
  }
}
```

## 리소스
<a name="cli-services-s3-apicommands-resources"></a>

**AWS CLI 참조:** 
+ [https://docs.aws.amazon.com/cli/latest/reference/s3api/index.html](https://docs.aws.amazon.com/cli/latest/reference/s3api/index.html)
+ [https://docs.aws.amazon.com/cli/latest/reference/s3api/put-bucket-acl.html](https://docs.aws.amazon.com/cli/latest/reference/s3api/put-bucket-acl.html)
+ [https://docs.aws.amazon.com/cli/latest/reference/s3api/put-bucket-logging.html](https://docs.aws.amazon.com/cli/latest/reference/s3api/put-bucket-logging.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)