

# Gerar o modelo do CloudFormation usando a AWS CLI
<a name="flow-logs-generate-template-cli"></a>

Depois que os primeiros logs de fluxo forem entregues ao bucket do S3, você poderá gerar e usar um modelo do CloudFormation para fazer a integração ao Athena.

Use o comando a seguir [get-flow-logs-integration-template](https://docs.aws.amazon.com/cli/latest/reference/ec2/get-flow-logs-integration-template.html) para gerar o modelo do CloudFormation.

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

Este é um exemplo do arquivo `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"
            }
        ]
    }
}
```

Use o comando a seguir [create-stack](https://docs.aws.amazon.com/cli/latest/reference/cloudformation/create-stack.html) para criar uma pilha usando o modelo do CloudFormation gerado.

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