

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

# Troposphere를 사용하여 AWS Config 관리형 규칙이 포함된 AWS CloudFormation 템플릿을 생성합니다.
<a name="generate-an-aws-cloudformation-template-containing-aws-config-managed-rules-using-troposphere"></a>

*Lucas Nation, Freddie Wilson, Amazon Web Services*

## 요약
<a name="generate-an-aws-cloudformation-template-containing-aws-config-managed-rules-using-troposphere-summary"></a>

많은 조직이 [AWS Config 관리형](https://docs.aws.amazon.com/config/latest/developerguide/evaluate-config_use-managed-rules.html) 규칙을 사용하여 일반적인 모범 사례에 대한 Amazon Web Services(AWS) 리소스의 규정 준수를 평가합니다. 하지만 이러한 규칙은 유지 관리하는 데 시간이 많이 걸릴 수 있으며 이 패턴을 사용하면 Python 라이브러리인 [Troposphere](https://troposphere.readthedocs.io/en/latest/quick_start.html)를 활용하여 AWS Config 관리형 규칙을 생성하고 관리할 수 있습니다.

이 패턴은 Python 스크립트를 사용하여 AWS 관리형 규칙이 포함된 Microsoft Excel 스프레드시트를 AWS CloudFormation 템플릿으로 변환함으로써 AWS Config 관리형 규칙을 관리하는 데 도움이 됩니다. Troposphere는 코드형 인프라(IAC) 역할을 하므로 JSON 또는 YAML 형식의 파일을 사용하는 대신 관리형 규칙을 사용하여 Excel 스프레드시트를 업데이트할 수 있습니다. 그런 다음 템플릿을 사용하여 AWS 계정에서 관리형 규칙을 생성하고 업데이트하는 AWS CloudFormation 스택을 시작합니다.

AWS CloudFormation 템플릿은 Excel 스프레드시트를 사용하여 각 AWS Config 관리형 규칙을 정의하므로 AWS Management Console 에서 개별 규칙을 수동으로 생성하지 않아도 됩니다. 스크립트는 각 관리형 규칙의 파라미터를 빈 딕셔너리로 기본 설정하고 범위의 `ComplianceResourceTypes` 기본값은 `THE_RULE_IDENTIFIER.template file`에서 초기화합니다.** 규칙 식별자에 대한 자세한 내용은 AWS Config 설명서의 [AWS CloudFormation 템플릿을 사용하여 AWS Config 관리형 규칙 생성](https://docs.aws.amazon.com/config/latest/developerguide/aws-config-managed-rules-cloudformation-templates.html)을 참조하세요.

## 사전 조건 및 제한 사항
<a name="generate-an-aws-cloudformation-template-containing-aws-config-managed-rules-using-troposphere-prereqs"></a>

**사전 조건 **
+ 활성 상태의 AWS 계정.
+ AWS CloudFormation 템플릿을 사용하여 AWS Config 관리형 규칙을 생성하는 방법에 대한 지식. 이에 대한 자세한 내용은 AWS Config 설명서의 [AWS CloudFormation 템플릿을 사용하여 AWS Config 관리형 규칙 생성](https://docs.aws.amazon.com/config/latest/developerguide/aws-config-managed-rules-cloudformation-templates.html)을 참조하세요. 
+ 설치 및 구성된 Python 3. 이에 대한 자세한 내용은 [Python 설명서](https://www.python.org/)를 참조하세요.
+ 기존의 통합 개발 환경(IDE). 
+ 첨부된 샘플 `excel_config_rules.xlsx` Excel 스프레드시트의 열에서 조직 단위(OU)를 식별합니다.

## 에픽
<a name="generate-an-aws-cloudformation-template-containing-aws-config-managed-rules-using-troposphere-epics"></a>

### AWS Config 관리형 규칙을 사용자 지정하고 구성합니다.
<a name="customize-and-configure-the-aws-config-managed-rules"></a>


| 작업 | 설명 | 필요한 기술 | 
| --- | --- | --- | 
| 샘플 Excel 스프레드시트를 업데이트합니다. | 첨부된 샘플 `excel_config_rules.xlsx` Excel 스프레드시트와 레이블을 다운로드하여 사용하려는 AWS Config 관리형 규칙으로 `Implemented`로 레이블을 지정합니다. `Implemented`로 표시된 규칙은 AWS CloudFormation 템플릿에 추가됩니다. | 개발자 | 
| (선택 사항) AWS Config 규칙 파라미터를 사용하여 config\$1rules\$1params.json 파일을 업데이트합니다. | 일부 AWS Config 관리형 규칙에는 파라미터가 필요하며 `--param-file` 옵션을 사용하여 Python 스크립트에 JSON 파일로 전달해야 합니다. 예를 들어, `access-keys-rotated` 관리형 규칙은 다음 `maxAccessKeyAge` 파라미터를 사용합니다.<pre>{<br />         "access-keys-rotated": {<br />             "InputParameters": {<br />                 "maxAccessKeyAge": 90<br />             }<br />         }<br />     }</pre>이 샘플 파라미터에서는 `maxAccessKeyAge`가 90일로 설정되어 있습니다. 스크립트는 파라미터 파일을 읽고 찾은 `InputParameters`를 추가합니다. | 개발자 | 
| (선택 사항) config\$1rules\$1params.json 파일을 AWS Config ComplianceResourceTypes로 업데이트합니다. | 기본적으로 Python 스크립트는 AWS 정의 템플릿에서 `ComplianceResourceTypes`를 검색합니다. 특정 AWS Config 관리형 규칙의 범위를 재정의하려면 `--param-file` 옵션을 사용하여 Python 스크립트에 JSON 파일로 전달해야 합니다.예를 들어, 다음 샘플 코드는 `ec2-volume-inuse-check`를 위한 `ComplianceResourceTypes`가 `["AWS::EC2::Volume"]` 목록에 어떻게 설정되는지 보여줍니다.<pre>{<br />         "ec2-volume-inuse-check": {<br />             "Scope": {<br />                 "ComplianceResourceTypes": [<br />                     "AWS::EC2::Volume"<br />                 ]<br />             }<br />         }<br />     }</pre> | 개발자 | 

### Python 스크립트 실행
<a name="run-the-python-script"></a>


| 작업 | 설명 | 필요한 기술 | 
| --- | --- | --- | 
| requirements.txt 파일에서 pip 패키지를 설치합니다. | 첨부된 `requirements.txt` 파일을 다운로드하고 IDE에서 다음 명령을 실행하여 Python 패키지를 설치합니다.`pip3 install -r requirements.txt` | 개발자 | 
|  Python 스크립트를 실행합니다. | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/generate-an-aws-cloudformation-template-containing-aws-config-managed-rules-using-troposphere.html)다음과 같은 선택적 파라미터도 추가할 수 있습니다.[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/generate-an-aws-cloudformation-template-containing-aws-config-managed-rules-using-troposphere.html) | 개발자 | 

### AWS Config 관리형 규칙을 배포합니다.
<a name="deploy-the-aws-config-managed-rules"></a>


| 작업 | 설명 | 필요한 기술 | 
| --- | --- | --- | 
| AWS CloudFormation 스택을 시작합니다. | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/generate-an-aws-cloudformation-template-containing-aws-config-managed-rules-using-troposphere.html) | 개발자 | 

## 첨부
<a name="attachments-07c1cfff-fc9e-4a1f-bd36-48f025808bd8"></a>

이 문서와 관련된 추가 콘텐츠에 액세스하려면 [attachment.zip](samples/p-attach/07c1cfff-fc9e-4a1f-bd36-48f025808bd8/attachments/attachment.zip) 파일의 압축을 풉니다.