

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# 를 사용하여 Amazon S3 버킷에서 다른 계정 및 리전으로 데이터 복사 AWS CLI
<a name="copy-data-from-an-s3-bucket-to-another-account-and-region-by-using-the-aws-cli"></a>

*Appasaheb Bagali, Purushotham G K, Amazon Web Services*

## 요약
<a name="copy-data-from-an-s3-bucket-to-another-account-and-region-by-using-the-aws-cli-summary"></a>

이 패턴은 AWS 계정의 소스 Amazon Simple Storage Service(Amazon S3) 버킷에서 동일한 AWS 리전 또는 다른 리전의 다른 AWS 계정의 대상 Amazon S3 버킷으로 데이터를 마이그레이션하는 방법을 설명합니다.

소스 Amazon S3 버킷은 연결된 리소스 정책을 사용하여 AWS Identity and Access Management (IAM) 액세스를 허용합니다. 대상 계정의 사용자는 소스 버킷에 대한 권한이 있는 `PutObject` 및 `GetObject`의 역할을 맡아야 합니다. 마지막으로 `copy` 및 `sync` 명령을 실행하여 소스 Amazon S3 버킷에서 대상 Amazon S3 버킷으로 데이터를 전송합니다.

계정은 Amazon S3 버킷에 업로드하는 객체를 소유합니다. 계정 및 리전 간에 객체를 복사하는 경우 대상 계정에 복사한 객체의 소유권을 부여합니다. [액세스 제어 목록(ACL)](https://docs.aws.amazon.com/AmazonS3/latest/dev/S3_ACLs_UsingACLs.html) 을 `bucket-owner-full-control`로 변경하여 객체의 소유권을 변경할 수 있습니다. 그러나 여러 객체에 대해 ACL을 관리하기가 어려울 수 있으므로 대상 계정에 프로그래밍 방식의 교차 계정 권한을 부여하는 것이 좋습니다.

**주의**  
이 시나리오에서는 프로그래밍 방식 액세스 권한과 장기 보안 인증이 있는 IAM 사용자가 필요하며 이는 보안 위험을 내포합니다. 이 위험을 줄이려면 이러한 사용자에게 작업을 수행하는 데 필요한 권한만 제공하고 더 이상 필요하지 않을 경우 이러한 사용자를 제거하는 것이 좋습니다. 필요한 경우 액세스 키를 업데이트할 수 있습니다. 자세한 내용은 IAM 설명서의 [액세스 키 업데이트를](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html#Using_RotateAccessKey) 참조하세요.

## 사전 조건 및 제한 사항
<a name="copy-data-from-an-s3-bucket-to-another-account-and-region-by-using-the-aws-cli-prereqs"></a>

*사전 조건 *
+ 둘이 동일하거나 다른 AWS 계정 에서 활성 상태입니다 AWS 리전.
+ 소스 계정의 기존 Amazon S3 버킷입니다. 
+ 소스 또는 대상 Amazon S3 버킷에 [기본 암호화](https://docs.aws.amazon.com/AmazonS3/latest/dev/bucket-encryption.html)가 활성화된 경우 AWS Key Management Service (AWS KMS) 키 권한을 수정해야 합니다. 자세한 내용은이 주제에 대한 [AWS re:Post 문서를](https://repost.aws/knowledge-center/s3-bucket-access-default-encryption) 참조하세요.
+ 교차 계정 권한에 대해 잘 알고 있어야 합니다.

*제한 사항 *
+ 이 패턴에서는 일회성 마이그레이션을 다룹니다. 소스 버킷에서 대상 버킷으로 새 객체를 지속적으로 자동 마이그레이션해야 하는 시나리오의 경우 [Amazon S3 배치 복제](https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-batch-replication-batch.html)를 사용할 수 있습니다.
+ 이 패턴은 임시적이고 비영구적인 세션 자격 증명(`AccessKeyId``SecretAccessKey`, 및 `SessionToken`)을 사용합니다. 출력의 만료 타임스탬프는 이러한 자격 증명이 만료되는 시기를 나타냅니다. 역할은 최대 세션 기간으로 구성됩니다. 세션이 만료되면 복사 작업이 취소됩니다.

## 아키텍처
<a name="copy-data-from-an-s3-bucket-to-another-account-and-region-by-using-the-aws-cli-architecture"></a>

 

![\[Amazon S3 데이터를 다른 계정 또는 리전으로 복사\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/images/pattern-img/a574c26b-fdd9-4472-842b-b34c3eb2bfe9/images/5e4dec53-dfc8-478b-a7c4-503d63c8ac4e.png)


## 도구
<a name="copy-data-from-an-s3-bucket-to-another-account-and-region-by-using-the-aws-cli-tools"></a>
+ [AWS Command Line Interface (AWS CLI)](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html)는 명령줄 셸의 명령을 AWS 서비스 통해와 상호 작용하는 데 도움이 되는 오픈 소스 도구입니다.
+ [AWS Identity and Access Management (IAM)](https://docs.aws.amazon.com/IAM/latest/UserGuide/introduction.html)는 AWS 리소스에 대한 액세스를 인증하고 사용할 수 있는 권한을 부여받은 사용자를 제어하여 리소스에 대한 액세스를 안전하게 관리하는 데 도움이 됩니다.
+ [Amazon Simple Storage Service(S3)](https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html)는 원하는 양의 데이터를 저장, 보호 및 검색하는 데 도움이 되는 클라우드 기반 객체 스토리지 서비스입니다.

## 모범 사례
<a name="copy-data-from-an-s3-bucket-to-another-account-and-region-by-using-the-aws-cli-best-practices"></a>
+ [IAM의 보안 모범 사례](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html)(IAM 설명서)
+ [최소 권한 적용](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege)(IAM 설명서)

## 에픽
<a name="copy-data-from-an-s3-bucket-to-another-account-and-region-by-using-the-aws-cli-epics"></a>

### 대상에 IAM 사용자 및 역할 생성 AWS 계정
<a name="create-an-iam-user-and-role-in-the-destination-aws-account"></a>


| 작업 | 설명 | 필요한 기술 | 
| --- | --- | --- | 
| IAM 사용자를 생성하고 액세스 키를 받습니다. | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/copy-data-from-an-s3-bucket-to-another-account-and-region-by-using-the-aws-cli.html) | DevOps | 
| 자격 증명 기반 IAM 정책을 생성합니다. | 다음 권한을 `S3MigrationPolicy` 사용하여 라는 IAM 자격 증명 기반 정책을 생성합니다. 사용 사례에 따라 원본 및 대상 버킷 이름을 수정합니다. 이 ID 기반 정책을 통해 이 역할을 수임하는 사용자는 원본 버킷과 대상 버킷에 액세스할 수 있습니다. 자세한 지침은 [IAM 설명서의 IAM 정책 생성을](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_create-console.html) 참조하세요.<pre>{<br />    "Version": "2012-10-17",		 	 	 <br />    "Statement": [<br />        {<br />            "Effect": "Allow",<br />            "Action": [<br />                "s3:ListBucket",<br />                "s3:ListObjectsV2",<br />                "s3:GetObject",<br />                "s3:GetObjectTagging",<br />                "s3:GetObjectVersion",<br />                "s3:GetObjectVersionTagging"<br />            ],<br />            "Resource": [<br />                "arn:aws:s3:::amazon-s3-demo-source-bucket",<br />                "arn:aws:s3:::amazon-s3-demo-source-bucket/*"<br />            ]<br />        },<br />        {<br />            "Effect": "Allow",<br />            "Action": [<br />                "s3:ListBucket",<br />                "s3:PutObject",<br />                "s3:PutObjectAcl",<br />                "s3:PutObjectTagging",<br />                "s3:GetObjectTagging",<br />                "s3:ListObjectsV2",<br />                "s3:GetObjectVersion",<br />                "s3:GetObjectVersionTagging"<br />            ],<br />            "Resource": [<br />                "arn:aws:s3:::amazon-s3-demo-destination-bucket",<br />                "arn:aws:s3:::amazon-s3-demo-destination-bucket/*"<br />            ]<br />        }<br />    ]<br />}</pre> | DevOps | 
| IAM 역할을 생성합니다. | 다음 신뢰 정책을 `S3MigrationRole` 사용하여 라는 IAM 역할을 생성합니다. 사용 사례에 따라 신뢰 정책에 있는 대상 IAM 역할 또는 사용자 이름의 Amazon 리소스 이름 ARN)을 수정합니다. 이 신뢰 정책은 새로 생성한 IAM 사용자가 `S3MigrationRole`을 가정하도록 허용합니다. 이전에 생성한를 연결합니다`S3MigrationPolicy`. 자세한 단계는 IAM 설명서의 [역할을 생성하여 IAM 사용자에게 권한 위임](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-user.html)을 참조하세요.<pre>{<br />    "Version": "2012-10-17",		 	 	 <br />    "Statement": [<br />        {<br />            "Effect": "Allow",<br />            "Principal": {<br />                "AWS": "arn:aws:iam::<destination_account>:user/<user_name>"<br />            },<br />            "Action": "sts:AssumeRole",<br />            "Condition": {}<br />        }<br />    ]<br />}</pre> | DevOps | 

### 소스 계정에서 Amazon S3 버킷 정책 생성 및 연결
<a name="create-and-attach-the-s3-bucket-policy-in-the-source-account"></a>


| 작업 | 설명 | 필요한 기술 | 
| --- | --- | --- | 
| Amazon S3 버킷 정책을 생성하고 연결합니다. | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/copy-data-from-an-s3-bucket-to-another-account-and-region-by-using-the-aws-cli.html) | 클라우드 관리자 | 

### 대상 Amazon S3 버킷 구성
<a name="configure-the-destination-s3-bucket"></a>


| 작업 | 설명 | 필요한 기술 | 
| --- | --- | --- | 
| 대상 Amazon S3 버킷을 생성합니다. | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/copy-data-from-an-s3-bucket-to-another-account-and-region-by-using-the-aws-cli.html) | 클라우드 관리자 | 

### 대상 Amazon S3 버킷에 데이터 복사
<a name="copy-data-to-the-destination-s3-bucket"></a>


| 작업 | 설명 | 필요한 기술 | 
| --- | --- | --- | 
| 새로 생성된 사용자 자격 증명 AWS CLI 으로를 구성합니다. | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/copy-data-from-an-s3-bucket-to-another-account-and-region-by-using-the-aws-cli.html) | DevOps | 
| Amazon S3 마이그레이션 역할을 수임합니다. | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/copy-data-from-an-s3-bucket-to-another-account-and-region-by-using-the-aws-cli.html)자세한 내용은 [를 사용하여 IAM 역할을 수임 AWS CLI 하려면 어떻게 해야 하나요?를](https://repost.aws/knowledge-center/iam-assume-role-cli) 참조하세요. | 관리자 | 
| 소스 버킷에서 대상 버킷으로 데이터를 복사하고 동기화합니다. | 역할을 수임한 경우 [복사](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3/cp.html)(`cp`) 또는 [동기화](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3/sync.html)(`sync`) 명령을 사용하여 데이터를 복사`S3MigrationRole`할 수 있습니다.복사:<pre>aws s3 cp s3://amazon-s3-demo-source-bucket/ \<br />    s3://amazon-s3-demo-destination-bucket/ \<br />    --recursive --source-region SOURCE-REGION-NAME --region DESTINATION-REGION-NAME</pre>동기화:<pre>aws s3 sync s3://amazon-s3-demo-source-bucket/ \<br />    s3://amazon-s3-demo-destination-bucket/ \<br />    --source-region SOURCE-REGION-NAME --region DESTINATION-REGION-NAME</pre> | 클라우드 관리자 | 

## 문제 해결
<a name="copy-data-from-an-s3-bucket-to-another-account-and-region-by-using-the-aws-cli-troubleshooting"></a>


| 문제 | Solution | 
| --- | --- | 
| `ListObjects` 작업을 호출할 때 오류(`AccessDenied`)가 발생했습니다. | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/copy-data-from-an-s3-bucket-to-another-account-and-region-by-using-the-aws-cli.html) | 

## 관련 리소스
<a name="copy-data-from-an-s3-bucket-to-another-account-and-region-by-using-the-aws-cli-resources"></a>
+ [Amazon S3 버킷 생성](https://docs.aws.amazon.com/AmazonS3/latest/userguide/create-bucket-overview.html)(Amazon S3 설명서)
+ [Amazon S3 버킷 정책 및 사용자 정책](https://docs.aws.amazon.com/AmazonS3/latest/dev/using-iam-policies.html)(Amazon S3 설명서)
+ [IAM 자격 증명(사용자, 그룹 및 역할)](https://docs.aws.amazon.com/IAM/latest/UserGuide/id.html?icmpid=docs_iam_console)(IAM 설명서)
+ [cp 명령](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3/cp.html)(AWS CLI 문서화)
+ [동기화 명령](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3/sync.html)(AWS CLI 문서화)