

# AWS CLI를 사용하여 CloudFormation 템플릿 생성
<a name="flow-logs-generate-template-cli"></a>

첫 번째 흐름 로그가 S3 버킷으로 전송된 후 CloudFormation 템플릿을 생성하고 해당 템플릿을 사용하여 Athena와 통합할 수 있습니다.

다음 [get-flow-logs-integration-template](https://docs.aws.amazon.com/cli/latest/reference/ec2/get-flow-logs-integration-template.html) 명령을 사용하여 CloudFormation 템플릿을 생성합니다.

```
aws ec2 get-flow-logs-integration-template --cli-input-json file://config.json
```

다음은 `config.json` 파일의 예입니다.

```
{
    "FlowLogId": "fl-12345678901234567",
    "ConfigDeliveryS3DestinationArn": "arn:aws:s3:::my-flow-logs-athena-integration/templates/",
    "IntegrateServices": {
        "AthenaIntegrations": [
            {
                "IntegrationResultS3DestinationArn": "arn:aws:s3:::my-flow-logs-analysis/athena-query-results/",
                "PartitionLoadFrequency": "monthly",
                "PartitionStartDate": "2021-01-01T00:00:00",
                "PartitionEndDate": "2021-12-31T00:00:00"
            }
        ]
    }
}
```

다음 [create-stack](https://docs.aws.amazon.com/cli/latest/reference/cloudformation/create-stack.html) 명령을 사용하여 생성된 CloudFormation 템플릿으로 스택을 생성합니다.

```
aws cloudformation create-stack --stack-name my-vpc-flow-logs --template-body file://my-cloudformation-template.json
```