> For the complete documentation index, see [llms.txt](https://docs.blusapphire.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.blusapphire.io/log-forwarding/03_log-forwarding-guide/cloud-log-forwarding/cloudflare-logs-integration.md).

# Cloudflare Logs Integration

Cloudflare Logs integration using S3

You can configure Cloudflare Logpush to push logs directly to an AWS (Amazon Web Services) S3 (Simple Storage Service) bucket.

## Required Access

To push logs to an AWS (Amazon Web Services) S3 (Simple Storage Service) bucket, Log Share permissions must be enabled on the Cloudflare account or zone before reading or configuring a Logpush job.

## Considerations

* Logs are written to the bucket as gzipped objects using the S3 Access Control List (ACL) Bucket-owner-full-control permission.
* Logpush uses multipart upload for S3. Aborted uploads leave incomplete files in the bucket. Configure a lifecycle rule using the AbortIncompleteMultipartUpload action to minimize storage costs.
* Buckets in China regions (cn-north-1, cn-northwest-1) are not supported.
* Customers using AWS GovCloud locations should use the S3-compatible endpoint instead of the Amazon S3 endpoint.

## Prerequisites

You'll need:

* An existing AWS (Amazon Web Services) S3 (Simple Storage Service) bucket.
* A bucket policy that grants the Cloudflare IAM (Identity and Access Management) user PutObject permission on the bucket.
* Access to the Cloudflare dashboard at the account or zone level with permission to create a Logpush job.

## Log Types Covered

The following Logpush datasets are pushed to S3 and ingested into the SIEM. Together, they give full coverage for detecting attacks, tracking WAF/security actions, and auditing account changes.

| **Log Type**    | **Scope** | **What it covers**                                                                                                                                                                                      |
| --------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| HTTP Requests   | Zone      | Every request to the zone – client IP, URI, status, user agent, and TLS details. The base layer for investigating web attacks, scanning activity, and traffic anomalies.                                |
| Firewall Events | Zone      | Every action taken by WAF, rate limiting, IP reputation, bot management, and custom rules – blocks, challenges, and allows. The direct security-detection signal.                                       |
| Audit Logs v2   | Account   | Every configuration and admin change on the Cloudflare account – DNS record changes, firewall rule edits, user and API token changes, login events. Detects unauthorized changes or account compromise. |
| DNS Logs        | Zone      | DNS queries answered by Cloudflare for the zone. Included where the client uses Cloudflare DNS – supports DNS tunneling and exfiltration detection.                                                     |

## Procedure

To push logs to an AWS (Amazon Web Services) S3 (Simple Storage Service) bucket, complete the following steps.

#### Create the S3 bucket and attach the Cloudflare access policy.

Create an S3 bucket in the AWS console. Then, in S3 > Bucket > Permissions > Bucket Policy, paste the policy below, replacing the Resource value with your own bucket path. The AWS Principal is owned by Cloudflare and should not be changed.

{

"Id": "\<POLICY\_ID>",

"Version": "2012-10-17",

"Statement": \[

{

"Sid": "Stmt1506627150918",

"Action": \["s3:PutObject"],

"Effect": "Allow",

"Resource": "arn:aws:s3::://\*",

"Principal": {

"AWS": \["arn:aws:iam::391854517948:user/cloudflare-logpush"]

}

}

]

}

Go to the Logpush page in the Cloudflare dashboard.

Go to the account-level or domain (zone)-level Logpush page, depending on the scope of the dataset you want to push.

#### Create a Logpush job and select Amazon S3 as the destination.

Select Create a Logpush job, then in Select a destination, choose Amazon S3.

**Enter the destination details.**

* * Bucket – the S3 bucket name.
  * Path – the bucket location within the storage container.
  * Organize logs into daily subfolders (recommended).
  * Bucket region.
  * Enable AWS SSE-S3 AES256 Server Side Encryption if required by policy.

Select Continue once the details are entered.

**Verify bucket ownership.**

Cloudflare sends an ownership challenge file to the destination. Open the file, copy the token, paste it into the Ownership Token field in the dashboard, and select Continue.

**Select the dataset to push.**

A Logpush job pushes one dataset at a time. Create a separate job (repeating steps 3–9) for each of the following, per the Log Types Covered table above:

* * HTTP Requests
  * Firewall Events
  * Audit Logs v2 – account-scoped; created once at the account level, not per zone.
  * DNS Logs – only if the client uses Cloudflare DNS.

Configure the Logpush job.

* * Enter the Job name.
  * In Send the following fields, choose to push all log fields

**Select Submit to complete the Logpush job.**

Repeat these steps to create all 4 log push jobs.

#### Create an Amazon SQS queue for the S3 bucket.

In the SQS console, create the queue in the same region as the S3 bucket.

* * Choose queue type Standard (can't be changed after creation) and enter a queue name.
  * Set Visibility timeout to 60 seconds and leave the remaining settings at their defaults.
  * Select Create Queue, then copy the queue's ARN (Amazon Resource Name) and URL from its Details page – both are needed later.

**Allow the S3 bucket to send notifications to the queue.**

On the queue's Access Policy tab, add the following, replacing and with your own values:

{

"Version": "2012-10-17",

"Id": "example-ID",

"Statement": \[

{

"Sid": "example-statement-ID",

"Effect": "Allow",

"Principal": { "AWS": "\*" },

"Action": \["SQS:SendMessage"],

"Resource": "",

"Condition": {

"ArnLike": { "aws:SourceArn": "arn:aws:s3:\*:\*:" }

}

}

]

}

**Create the S3 event notification.**

On the bucket's Properties tab, under Event Notifications, create a new notification.

* * Provide an event name and, optionally, a prefix/suffix to scope which objects trigger it.
  * Under Event types, select All object create events.
  * Set Destination to SQS Queue and select the queue created above.

**Create an IAM policy for reading from the bucket and queue.**

In IAM > Policies, create a policy with the following, replacing \<AWS\_SQS-ARN> with the queue's ARN:

{

"Version": "2012-10-17",

"Statement": \[

{

"Sid": "VisualEditor0",

"Effect": "Allow",

"Action": \["s3:GetObject", "sqs:ReceiveMessage"],

"Resource": "\*"

},

{

"Sid": "VisualEditor1",

"Effect": "Allow",

"Action": "sqs:ChangeMessageVisibility",

"Resource": "\<AWS\_SQS-ARN>"

},

{

"Sid": "VisualEditor2",

"Effect": "Allow",

"Action": "sqs:DeleteMessage",

"Resource": "\<AWS\_SQS-ARN>"

},

{

"Sid": "VisualEditor3",

"Effect": "Allow",

"Action": \["sts:AssumeRole", "sqs:ListQueues"],

"Resource": "\*"

}

]

}

**Create an IAM role and attach the policy.**

In IAM > Roles, create a role using a Custom trust policy, replacing with the ARN of the IAM user BluSapphire will use:

{

"Version": "2012-10-17",

"Statement": \[

{

"Effect": "Allow",

"Principal": { "AWS": "" },

"Action": "sts:AssumeRole"

}

]

}

Attach the policy created above to the role, then provide a role name and description.

**Share access details with BluSapphire.**

Provide the following so the log agent can be configured to read from the queue:

* * Access Key ID and Secret Access Key of the IAM user.
  * Role ARN of the IAM role created above.
  * Queue URL of the SQS queue created above.
