> For the complete documentation index, see [llms.txt](https://docs.p0.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.p0.dev/integrations/siem-integrations/amazon-sqs-setup.md).

# Amazon SQS setup

Send P0 audit logs to an Amazon SQS queue in your AWS account.

{% hint style="info" %}
The Amazon SQS audit log integration is in beta. Functionality and configuration may change.
{% endhint %}

P0 sends each audit log event from your P0 tenant as one message to an Amazon SQS queue in your AWS account. Any tool that reads from SQS can consume the queue, and you can batch the events into S3 for tools that read from S3.

## Prerequisites

* Existing P0 account at [p0.app](https://p0.app/)
* P0's [AWS](https://docs.p0.dev/integrations/resource-integrations/aws.md) integration installed for the AWS account that owns the queue
* An SQS queue, standard or FIFO
* Permission to create IAM roles in that AWS account

## Set up the Amazon SQS integration

{% hint style="info" %}
This setup takes about 10 minutes.
{% endhint %}

1. **Copy your queue's ARN.** In the AWS console, open **Amazon SQS**, select your queue, and copy the **ARN** from the **Details** panel. It has the form `arn:aws:sqs:<region>:<account-id>:<queue-name>`.

   <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>The SQS console lists queues for one region at a time. If you don't see your queue, switch the console to the queue's region.</p></div>
2. **Add the queue in P0.** Log in to [p0.app](https://p0.app) and select **Integrations**. Under **Security Information & Event Managers**, select **Amazon SQS**, then the **Queue ARN** component, and add a queue.
3. **Enter the queue details** and click **Next**. See [#configure-amazon-sqs](#configure-amazon-sqs "mention") for the fields.
4. **Create P0's role.** P0 shows the commands that create the `P0RoleIamEventSender` role in your account. Run the shell commands in [AWS CloudShell](https://docs.aws.amazon.com/cloudshell/latest/userguide/welcome.html) or a terminal signed in to that account, or apply the Terraform. Then click **Next**. P0 checks that the role exists and that its policies match.
5. **Click Finish.** P0 sends one test message to your queue to confirm it can deliver events. The test message looks like this:

   ```json
   {"type":"test","action":"p0.integration.test","timestamp":"2026-10-22T19:09:08.670Z","source":"p0","tenant":"your-org","id":"p0-test-1792696148670"}
   ```

P0 supports one Amazon SQS queue per P0 organization.

## Configure Amazon SQS

### Queue ARN

The ARN of the queue P0 sends audit events to. FIFO queues have names that end in `.fifo`.

### KMS key ARN

Optional. Leave this blank unless your queue is encrypted with a customer managed KMS key. If it is, enter the key's ARN, in the form `arn:aws:kms:<region>:<account-id>:key/<key-id>`. P0 adds permission to use that key to its role.

Queues that use SQS-managed encryption or the AWS managed key (`alias/aws/sqs`) need no key here.

## Message format

Each message body is one audit log event as single-line JSON, in the format described in [Audit log format](https://docs.p0.dev/integrations/siem-integrations/audit-log-format.md). P0 adds three fields to every event:

| Field    | Description                                                                                                     |
| -------- | --------------------------------------------------------------------------------------------------------------- |
| `source` | Always `p0`                                                                                                     |
| `tenant` | Your P0 organization identifier                                                                                 |
| `id`     | A unique identifier for the event. Use it to drop duplicates, because SQS can deliver a message more than once. |

The `timestamp` field is an ISO 8601 string. P0 does not set SQS message attributes.

For FIFO queues, P0 sets the message group ID to your P0 organization identifier and the deduplication ID to the event's `id`.

## Send events to S3 (optional)

Some log tools read from SQS directly. Others only read files from S3. To batch the queued events into S3 files, connect the queue to Amazon Data Firehose with an EventBridge pipe:

```
SQS queue → EventBridge Pipes → Amazon Data Firehose → S3 bucket
```

You create and own these resources. P0's responsibility ends when an event arrives in your queue.

1. **Create a Firehose stream** with an S3 destination. Turn on the newline delimiter so each event lands on its own line, and choose a compression format. These are the settings that matter:

   ```json
   {
     "RoleARN": "arn:aws:iam::<account-id>:role/<firehose-role>",
     "BucketARN": "arn:aws:s3:::<bucket-name>",
     "CompressionFormat": "GZIP",
     "ProcessingConfiguration": {
       "Enabled": true,
       "Processors": [
         {
           "Type": "AppendDelimiterToRecord",
           "Parameters": [{ "ParameterName": "Delimiter", "ParameterValue": "\\n" }]
         }
       ]
     }
   }
   ```

   ```bash
   aws firehose create-delivery-stream \
     --delivery-stream-name p0-audit-to-s3 \
     --delivery-stream-type DirectPut \
     --extended-s3-destination-configuration file://firehose.json
   ```
2. **Create a pipe** from your queue to the Firehose stream, with this input template:

   ```bash
   aws pipes create-pipe \
     --name p0-audit-to-firehose \
     --role-arn arn:aws:iam::<account-id>:role/<pipe-role> \
     --source arn:aws:sqs:<region>:<account-id>:<queue-name> \
     --target arn:aws:firehose:<region>:<account-id>:deliverystream/p0-audit-to-s3 \
     --target-parameters '{"InputTemplate": "{\"event\": <$.body>}"}'
   ```

Each line in the S3 files is then `{"event": { ... }}`, with the P0 event under `event`. In your log tool, P0's fields appear as `event.<field>`, for example `event.action`.

{% hint style="warning" %}
Use the input template above. Without a template, each line holds the whole SQS record with the P0 event as an escaped string. The template `<$.body>` on its own strips the quotes from the JSON, so the lines are not valid JSON.
{% endhint %}

The pipe's role needs `sqs:ReceiveMessage`, `sqs:DeleteMessage`, and `sqs:GetQueueAttributes` on the queue, and `firehose:PutRecord` and `firehose:PutRecordBatch` on the stream. For details, see the AWS documentation for [EventBridge Pipes](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-pipes.html) and [Firehose to S3](https://docs.aws.amazon.com/firehose/latest/dev/create-destination.html#create-destination-s3).

## Troubleshooting

### P0 stopped sending events

If P0 can't send to your queue because the queue was deleted, P0's role was removed or changed, or the KMS key was disabled, P0 stops sending to the queue. Events from that period are not delivered.

To resume, fix the cause, then install the Amazon SQS integration again from the **Queue ARN** component. P0 checks the role, sends a test message, and resumes sending new events.

### An event is too large

SQS accepts messages up to 1 MiB, and a queue can set a lower limit. P0 does not send an event that exceeds the limit.

{% hint style="success" %}
Congratulations! You are now set up with the Amazon SQS audit logs integration.
{% endhint %}
