

# 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"
            }
        ]
    }
}
```

生成された CloudFormation テンプレートを使用してスタックを作成するには、次の [create-stack ](https://docs.aws.amazon.com/cli/latest/reference/cloudformation/create-stack.html) コマンドを使用します。

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