

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

# S3 버킷을 AWS CloudFormation 스택으로 가져오기 성공
<a name="successfully-import-an-s3-bucket-as-an-aws-cloudformation-stack"></a>

*Ram Kandaswamy, Amazon Web Services*

## 요약
<a name="successfully-import-an-s3-bucket-as-an-aws-cloudformation-stack-summary"></a>

Amazon Simple Storage Service(S3) 버킷과 같은 Amazon Web Services(AWS) 리소스를 사용하고 코드형 인프라(IaC) 접근 방식을 사용하려는 경우, 리소스를 AWS CloudFormation으로 가져와서 스택으로 관리할 수 있습니다.

이 패턴은 S3 버킷을 AWS CloudFormation 스택으로 성공적으로 가져오기 위한 단계를 제공합니다. 이 패턴의 접근 방식을 사용하면 S3 버킷을 한 번의 작업으로 가져올 때 발생할 수 있는 오류를 피할 수 있습니다.

## 사전 조건 및 제한 사항
<a name="successfully-import-an-s3-bucket-as-an-aws-cloudformation-stack-prereqs"></a>

**사전 조건 **
+ 활성 상태의 AWS 계정.
+ 기존 S3 버킷 및 S3 버킷 정책. 이에 대한 자세한 내용은 AWS 지식 센터의 [AWS Config 규칙 s3-bucket-ssl-requests-only를 준수하기 위해 사용해야 하는 S3 버킷 정책은 무엇입니까?](https://aws.amazon.com/premiumsupport/knowledge-center/s3-bucket-policy-for-config-rule/)를 참조하십시오.
+ 기존 AWS Key Management Service(AWS KMS) 키 및 별칭입니다. 이에 대한 자세한 내용은 AWS KMS 설명서의 [별칭 작업](https://docs.aws.amazon.com/kms/latest/developerguide/programming-aliases.html)을 참조하십시오.
+ `CloudFormation-template-S3-bucket` AWS CloudFormation 템플릿(첨부)을 로컬 컴퓨터로 다운로드합니다.

## 아키텍처
<a name="successfully-import-an-s3-bucket-as-an-aws-cloudformation-stack-architecture"></a>

![\[CloudFormation 템플릿을 사용하여 S3 버킷을 가져올 CloudFormation 스택을 생성하는 워크플로.\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/images/pattern-img/aea7f6fe-8e67-46c4-8b90-1ab06b879111/images/ee143374-a0a4-42d9-b7ca-16593a597a84.png)


 

이 다이어그램은 다음 워크플로를 보여줍니다.

1. 사용자는 JSON 또는 YAML 형식의 AWS CloudFormation 템플릿을 생성합니다.

1. 템플릿은 S3 버킷을 가져오기 위한 AWS CloudFormation 스택을 생성합니다.

1. AWS CloudFormation 스택은 템플릿에서 지정한 S3 버킷을 관리합니다.

**기술 스택**
+ AWS CloudFormation
+ Identity and Access Management(IAM)
+ KMS
+ Amazon S3

 

**도구**
+ [AWS CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html) – AWS CloudFormation을 사용하면 AWS 인프라 배포를 예상한 대로 반복해서 생성 및 프로비저닝할 수 있습니다.
+ [AWS Identity and Access Management(IAM)](https://docs.aws.amazon.com/IAM/latest/UserGuide/introduction.html) – IAM은 AWS 서비스에 대한 액세스를 안전하게 제어하는 웹 서비스입니다.
+ [AWS KMS](https://docs.aws.amazon.com/kms/latest/developerguide/overview.html) – AWS Key Management Service(AWS KMS)는 클라우드에 맞게 규모를 조정한 암호화 및 키 관리 서비스입니다.
+ [Amazon S3](https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html) – Amazon Simple Storage Service(S3)는 인터넷 스토리지 서비스입니다.

## 에픽
<a name="successfully-import-an-s3-bucket-as-an-aws-cloudformation-stack-epics"></a>

### AWS CloudFormation 스택으로 AWS KMS key기반 암호화가 있는 S3 버킷 가져오기
<a name="import-an-s3-bucket-with-kms-key-long--based-encryption-as-an-aws-cloudformation-stack"></a>


| 작업 | 설명 | 필요한 기술 | 
| --- | --- | --- | 
| 템플릿을 생성하여 S3 버킷과 KMS 키를 가져옵니다. | 로컬 컴퓨터에서 다음 샘플 템플릿을 사용하여 S3 버킷과 KMS 키를 가져올 템플릿을 생성합니다.<pre>AWSTemplateFormatVersion: 2010-09-09<br /><br />Parameters:<br /><br />  bucketName:<br /><br />    Type: String<br /><br />Resources:<br /><br />  S3Bucket:<br /><br />    Type: 'AWS::S3::Bucket'<br /><br />    DeletionPolicy: Retain<br /><br />    Properties:<br /><br />      BucketName: !Ref bucketName<br /><br />      BucketEncryption:<br /><br />        ServerSideEncryptionConfiguration:<br /><br />          - ServerSideEncryptionByDefault:<br /><br />              SSEAlgorithm: 'aws:kms'<br /><br />              KMSMasterKeyID: !GetAtt <br /><br />                - KMSS3Encryption<br /><br />                - Arn<br /><br />  KMSS3Encryption:<br /><br />    Type: 'AWS::KMS::Key'<br /><br />    DeletionPolicy: Retain<br /><br />    Properties:<br /><br />      Enabled: true<br /><br />      KeyPolicy: !Sub |-<br /><br />        {<br /><br />            "Id": "key-consolepolicy-3",<br /><br />            "Version": "2012-10-17",		 	 	 <br /><br />            "Statement": [<br /><br />                {<br /><br />                    "Sid": "Enable IAM User Permissions",<br /><br />                    "Effect": "Allow",<br /><br />                    "Principal": {<br /><br />                        "AWS": ["arn:aws:iam::${AWS::AccountId}:root"]<br /><br />                    },<br /><br />                    "Action": "kms:*",<br /><br />                    "Resource": "*"<br /><br />                }<br /><br />                }<br /><br />            ]<br /><br />        }<br /><br />      EnableKeyRotation: true</pre> | DevOps | 
| 스택을 생성합니다. | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/successfully-import-an-s3-bucket-as-an-aws-cloudformation-stack.html) | AWS DevOps | 
| KMS 키 별칭을 생성합니다. | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/successfully-import-an-s3-bucket-as-an-aws-cloudformation-stack.html)<pre>KMSS3EncryptionAlias:<br /><br />    Type: 'AWS::KMS::Alias'<br /><br />    DeletionPolicy: Retain<br /><br />    Properties: <br /><br />    AliasName: alias/S3BucketKey<br /><br />    TargetKeyId: !Ref KMSS3Encryption</pre>이에 대한 자세한 내용은 AWS CloudFormation 설명서의 [AWS CloudFormation 스택이란 무엇입니까?](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks.html)를 참조하십시오.  | AWS DevOps | 
| S3 버킷 정책을 포함하도록 스택을 업데이트합니다. | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/successfully-import-an-s3-bucket-as-an-aws-cloudformation-stack.html)<pre>S3BucketPolicy:<br /><br />  Type: 'AWS::S3::BucketPolicy'<br /><br />  Properties:<br /><br />    Bucket: !Ref S3Bucket<br /><br />    PolicyDocument: !Sub |-<br /><br />      {<br /><br />                  "Version": "2008-10-17",		 	 	 <br /><br />                  "Id": "restricthttp",<br /><br />                  "Statement": [<br /><br />                      {<br /><br />                          "Sid": "denyhttp",<br /><br />                          "Effect": "Deny",<br /><br />                          "Principal": {<br /><br />                              "AWS": "*"<br /><br />                          },<br /><br />                          "Action": "s3:*",<br /><br />                          "Resource": ["arn:aws:s3:::${S3Bucket}","arn:aws:s3:::${S3Bucket}/*"],<br /><br />                          "Condition": {<br /><br />                              "Bool": {<br /><br />                                  "aws:SecureTransport": "false"<br /><br />                              }<br /><br />                          }<br /><br />                      }<br /><br />                  ]<br /><br />              }</pre>이 S3 버킷 정책에는 안전하지 않은 API 직접 호출을 제한하는 거부 명령문이 있습니다.  | DevOps | 
| 키 정책을 업데이트합니다. | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/successfully-import-an-s3-bucket-as-an-aws-cloudformation-stack.html)자세한 내용은 AWS KMS 설명서에서 [AWS KMS의 키 정책](https://docs.aws.amazon.com/kms/latest/developerguide/key-policies.html)을 참조하세요. | 관리자 | 
| 리소스 수준 태그를 추가합니다. | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/successfully-import-an-s3-bucket-as-an-aws-cloudformation-stack.html)<pre>Tags:<br /><br />  - Key: createdBy<br /><br />    Value: Cloudformation</pre> | AWS DevOps | 

## 관련 리소스
<a name="successfully-import-an-s3-bucket-as-an-aws-cloudformation-stack-resources"></a>
+ [AWS CloudFormation 관리로 기존 리소스 가져오기 ](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resource-import.html)
+ [AWS re:Invent 2017: AWS CloudFormation 심층 분석](https://www.youtube.com/watch?v=01hy48R9Kr8)(비디오)

## 첨부
<a name="attachments-aea7f6fe-8e67-46c4-8b90-1ab06b879111"></a>

이 문서와 관련된 추가 콘텐츠에 액세스하려면 [attachment.zip](samples/p-attach/aea7f6fe-8e67-46c4-8b90-1ab06b879111/attachments/attachment.zip) 파일의 압축을 풉니다.