Skip to main content

PostHog

Connecting PostHog works by using PostHog's Kinesis destination to send events to our AWS Kinesis connector. With this setup we're able to ingest events in real-time directly in a secure and scalable way.

This guide walks you through how to setup a a PostHog to AWS Kinesis destination, including creating the necessary IAM user permissions, and then how to setup a Shaped AWS Kinesis connector that consumes from the PostHog destination.


1. Create an IAM User

To allow Posthog to have the correct permissions to write to a Shaped AWS Kinesis consumer you will need to create an IAM user account with static credentials that can be provided to PostHog.

  1. In the AWS Console, go to IAM → User → Create user.
  2. Name the role ShapedKinesisPermissions.
  3. Attach a policy that grants write access to the Kinesis stream Shaped provisions for you. For example:
  {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"kinesis:PutRecord",
"kinesis:PutRecords"
],
"Resource": "arn:aws:kinesis:us-east-2:<your-aws-account-id>:stream/<your-stream-name>"
}
]
}

Replace <your-account-id> with your 12-digit AWS account ID.

  1. Retrieve the Access Key ID, Secret Access Key and the ARN for the user that was just created. We will need the keys to create the Posthog pipeline and the ARN to issue the Kinesis connector.

🔑 Access Key ID & Secret Access Key

  1. Go to IAM → Users → DevKinesisUser → Security credentials tab.
  2. Under Access keys, you’ll see the Access Key ID.
  3. The Secret Access Key is only shown once at creation time (when you click “Create access key”).
    • If you didn’t copy it then, you cannot view it again in the console.
    • You’ll need to create a new access key and delete the old one.

2. Setting up a Shaped AWS Kinesis connector

To automatically create a Kinesis Data Stream using Shaped’s connector: Shaped Kinesis Connector.

That guide outlines how to configure a dataset (including schema_type: KINESIS and the tenant_access_role_arn for the IAM user that was just created) and run the CLI command (shaped create-dataset --file dataset_schema.yml,) so that Shaped will provision the stream for you and manage its lifecycle.

Once the dataset becomes ACTIVE, you’ll receive the stream ARN from Shaped to enable event delivery.

The dataset schema mirrors the structure of a PostHog event. For example, an example schema for creating your dataset might look like:

name: example_kinesis_stream
schema_type: KINESIS
unique_keys: [event.uuid]
column_schema:
event:
uuid: String # Unique identifier for the PostHog event
distinct_id: String # The user/session identifier associated with the event
timestamp: DateTime # When the event occurred
event: String # Event name (e.g., "$pageview")
elements_chain: String # Serialized elements chain (used for autocapture)
url: String # URL of the page where the event was captured
properties: String # JSON string of custom event properties
tenant_access_role_arn: "arn:aws:iam::<ACCOUNT_ID>:user/test-user-kinesis"

3. Configure PostHog

  1. In PostHog, go to Data pipeline → Destinations → + Create → AWS Kinesis.

  2. Enter the following values:

    • AWS Access Key ID → from IAM user
    • AWS Secret Access Key → from IAM user
    • AWS Region → region of your stream
    • Kinesis Stream Name<your-provisioned-stream> which will be provided by Shaped
    • Kinesis Partition Key → optional (e.g. user_id)
  3. Click Create & Enable.