Linking AWS Cost Explorer as a source

Let AI connect your sources for you

Skip the manual setup — run this in your project and the wizard auto-detects your databases and APIs and connects them to PostHog.

Learn more
PostHog Wizard hedgehog

Contents

Alpha release

This source is currently in alpha. The interface and available tables may change.

The AWS Cost Explorer connector syncs your AWS cost and usage data into PostHog, so you can analyze cloud spend alongside your product data.

Prerequisites

You need an AWS account with Cost Explorer enabled. Cost Explorer can take up to 24 hours to prepare data after it is first enabled.

You also need an IAM user or role with the following permissions:

  • ce:GetCostAndUsage
  • ce:GetReservationUtilization
  • ce:GetSavingsPlansUtilization

To see spend across every member account, connect the management (payer) account.

Adding a data source

  1. In PostHog, go to the Sources tab of the data pipeline section.
  2. Click + New source and click Link next to this source.
  3. Enter your credentials (see Configuration below) and click Next.
  4. Select the tables you want to sync, choose a sync method and frequency, then click Import.

Once the syncs are complete, you can start querying this data in PostHog.

When linking AWS Cost Explorer, you'll need:

  • AWS access key ID – the access key ID for your IAM user or role (starts with AKIA...).
  • AWS secret access key – the corresponding secret access key.
  • AWS session token (optional) – only required if you are using temporary STS credentials.
  • Start date (optional) – the earliest date to sync from, in YYYY-MM-DD format. Defaults to 12 months ago.

Creating IAM credentials

  1. In the AWS Console, go to IAM > Users and create a new user (or use an existing one).
  2. Attach a policy with the following permissions:
JSON
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ce:GetCostAndUsage",
"ce:GetReservationUtilization",
"ce:GetSavingsPlansUtilization"
],
"Resource": "*"
}
]
}
  1. Create an access key for the user under Security credentials > Access keys.
  2. Copy the Access key ID and Secret access key – you'll need both when linking the source in PostHog.

Note: AWS charges $0.01 per Cost Explorer API request. PostHog uses wide date windows per request to keep costs low.

Sync modes

Each table can be synced in one of several modes, depending on what the source supports:

  • Webhook (when available) – the source pushes changes to PostHog in real time. Fastest freshness, lowest ongoing cost, and the only mode that reliably captures updates and deletes.
  • Incremental – only new or updated rows are synced on each run, using a cursor field (such as an updated_at timestamp). Cheaper than a full refresh, but deletes aren't captured.
  • Append only – new rows are appended using a cursor field; existing rows are never updated. Ideal for immutable, append-only tables like event logs.
  • Full refresh – the whole table is reloaded on every sync. Use it when a table has no reliable cursor or when you need deletions reflected.

See sync methods for a full explanation of how each mode works and how to choose between them.

All four tables support incremental sync using period_start as the cursor.

AWS restates recent cost periods until bills finalize (rows come back marked as estimated). To capture these corrections, incremental syncs automatically re-read a trailing window behind the last synced value:

TableLookback window
cost_and_usage_daily7 days
cost_and_usage_monthly45 days
reservation_utilization_daily7 days
savings_plans_utilization_daily7 days

Duplicate rows are merged by primary key, so re-read periods don't create duplicates.

Configuration

OptionTypeRequired
AWS access key IDtextYes
AWS secret access keypasswordYes
AWS session token (only for temporary credentials)passwordNo
Start date (defaults to 12 months ago)textNo

Supported tables

TableDescriptionSync methodIncremental fieldPrimary key
cost_and_usage_daily

Daily cost and usage metrics grouped by AWS service and linked account.

Incremental, Full refreshperiod_start
cost_and_usage_monthly

Monthly cost and usage metrics grouped by AWS service and linked account.

Incremental, Full refreshperiod_start
reservation_utilization_daily

Daily Reserved Instance utilization and savings totals.

Incremental, Full refreshperiod_start
savings_plans_utilization_daily

Daily Savings Plans commitment utilization and net savings.

Incremental, Full refreshperiod_start

Troubleshooting

  • If you see "AWS rejected the access key", check that the access key ID and secret access key are correct and that the key is still active in IAM.
  • If you see a signature error, re-enter the secret access key. If you are using temporary credentials, the session token may have expired.
  • If you see "missing Cost Explorer permissions", grant ce:GetCostAndUsage, ce:GetReservationUtilization, and ce:GetSavingsPlansUtilization to the IAM user or role.
  • If you see "no Cost Explorer data", make sure Cost Explorer is enabled on the AWS account. It can take up to 24 hours after enabling for data to appear.
  • If you see "dates are older than the data AWS keeps", move the start date forward and try again.

If your sync is failing or data looks wrong, see the Data warehouse troubleshooting guide. If that doesn't help, contact support – we're happy to help.

Was this page useful?