> ## Documentation Index
> Fetch the complete documentation index at: https://www.propeldata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Amazon DynamoDB setup guide

> Ingesting data from Amazon DynamoDB to Propel

<div />

This guide covers how to:

1. [Configure the DynamoDB Stream](#step-1-configure-the-dynamodb-stream)
2. [Create a Propel DynamoDB Data Pool](#step-2-create-a-propel-dynamodb-data-pool)
3. [Create the Data Firehose stream to deliver events to Propel](#step-3-create-the-data-firehose-stream-to-deliver-events-to-propel)
4. [Transform DynamoDB events in Propel](#step-4-transform-dynamodb-events-in-propel)

***

## Requirements

* You have a [Propel account](https://console.propeldata.com/get-started).
* You have an AWS account.

***

## Step 1: Configure the DynamoDB Stream

<Steps>
  <Step title="Go to DynamoDB dashboard">
    Go to your DynamoDB dashboard in the AWS Console and click "**Tables**".

    When you are in the tables section, click on the table that you need to replicate to Propel.

    <Frame>
      <img src="https://mintcdn.com/propeldocs/EJuEs6SO8KXtRuWH/images/docs/2024-12-amazon-dynamodb-setup-01.png?fit=max&auto=format&n=EJuEs6SO8KXtRuWH&q=85&s=302cc4b010ef7f4b1a6fb07fdd9a885f" alt="Screenshot 2024-05-08 at 1.20.37 PM.png" width="1373" height="358" data-path="images/docs/2024-12-amazon-dynamodb-setup-01.png" />
    </Frame>
  </Step>

  <Step title="Configure DynamoDB Stream">
    Go to "**Exports and streams**" and then click on "**Turn on**" the "**Amazon Kinesis stream details**".

    <Frame>
      <img src="https://mintcdn.com/propeldocs/EJuEs6SO8KXtRuWH/images/docs/2024-12-amazon-dynamodb-setup-02.png?fit=max&auto=format&n=EJuEs6SO8KXtRuWH&q=85&s=3b8b4a7b25fdadb0619328678d1a2dc8" alt="Screenshot 2024-05-08 at 1.21.12 PM.png" width="1387" height="885" data-path="images/docs/2024-12-amazon-dynamodb-setup-02.png" />
    </Frame>

    Choose an existing Kinesis data stream or create a new one.

    <Frame>
      <img src="https://mintcdn.com/propeldocs/EJuEs6SO8KXtRuWH/images/docs/2024-12-amazon-dynamodb-setup-03.png?fit=max&auto=format&n=EJuEs6SO8KXtRuWH&q=85&s=87ff3d4b2f8ce76be9d4bb14dbf0ece4" alt="Screenshot 2024-05-08 at 1.26.29 PM.png" width="782" height="610" data-path="images/docs/2024-12-amazon-dynamodb-setup-03.png" />
    </Frame>
  </Step>

  <Step title="Create or verify stream">
    If you need to create a new one, click on "**Create New**".

    <Frame>
      <img src="https://mintcdn.com/propeldocs/EJuEs6SO8KXtRuWH/images/docs/2024-12-amazon-dynamodb-setup-04.png?fit=max&auto=format&n=EJuEs6SO8KXtRuWH&q=85&s=ab94a79a77e7415ebd4265280d0239b3" alt="Screenshot 2024-05-08 at 1.25.14 PM.png" width="767" height="1195" data-path="images/docs/2024-12-amazon-dynamodb-setup-04.png" />
    </Frame>

    Once turned on, you will see your stream with an "**On**" status.

    <Frame>
      <img src="https://mintcdn.com/propeldocs/EJuEs6SO8KXtRuWH/images/docs/2024-12-amazon-dynamodb-setup-05.png?fit=max&auto=format&n=EJuEs6SO8KXtRuWH&q=85&s=5d3e5a502d5f79aef6f486d29f721049" alt="Screenshot 2024-05-08 at 1.50.27 PM.png" width="1115" height="898" data-path="images/docs/2024-12-amazon-dynamodb-setup-05.png" />
    </Frame>

    And you are all set for this step. You have all your DynamoDB changes flowing into a Kinesis data stream.
  </Step>
</Steps>

## Step 2: Create a Propel DynamoDB Data Pool

Next, we'll need to create a DynamoDB Data Pool in Propel. This is the table where the data will be stored.

<Steps>
  <Step title="Create a Data Pool">
    Log into the [Propel Console](https://console.propeldata.com/login), click on "Data Pools" on the left menu, and then click on "**Create Data Pool**."

    Then, select "**DynamoDB**".

    <Frame>
      <img src="https://mintcdn.com/propeldocs/EJuEs6SO8KXtRuWH/images/docs/2024-12-dynamo-data-pool-01.png?fit=max&auto=format&n=EJuEs6SO8KXtRuWH&q=85&s=8abb363b644d81cb97f36e6a5ebb93c0" alt="Screenshot showing the DynamoDB Data Pool selection." width="1657" height="771" data-path="images/docs/2024-12-dynamo-data-pool-01.png" />
    </Frame>
  </Step>

  <Step title="Define schema">
    In the "**Define schema**" section, leave the defaults as we want to land the data in its original DynamoDB change data format and transform it later using Materialized Views if necessary.

    <Frame>
      <img src="https://mintcdn.com/propeldocs/EJuEs6SO8KXtRuWH/images/docs/2024-12-dynamo-data-pool-02.png?fit=max&auto=format&n=EJuEs6SO8KXtRuWH&q=85&s=e91e4d60a8ff5951cd3ec8a366a7cb05" alt="Screenshot showing the schema definition page." width="1656" height="1068" data-path="images/docs/2024-12-dynamo-data-pool-02.png" />
    </Frame>
  </Step>

  <Step title="Configure authentication">
    Enter a user and password for the Basic Authentication required by Amazon Data Firehose.

    <Frame>
      <img src="https://mintcdn.com/propeldocs/EJuEs6SO8KXtRuWH/images/docs/2024-12-dynamo-data-pool-03.png?fit=max&auto=format&n=EJuEs6SO8KXtRuWH&q=85&s=e9a261d45ae86703e7572512f93903b3" alt="Screenshot showing the authentication configuration page." width="1671" height="542" data-path="images/docs/2024-12-dynamo-data-pool-03.png" />
    </Frame>
  </Step>

  <Step title="Configure the table settings">
    Select whether your data is **"Append-only"** or **"Mutable data"**. For collecting change data capture events, select **"Append-only data"**.

    To learn more, read out guide on [Selecting table engine and sorting key](/docs/guides/table-engine-and-sorting-key).

    <Frame>
      <img src="https://mintcdn.com/propeldocs/EJuEs6SO8KXtRuWH/images/docs/2024-12-dynamo-data-pool-04.png?fit=max&auto=format&n=EJuEs6SO8KXtRuWH&q=85&s=a9793beeb2c96e892ba6105ff8bf15c3" alt="Selecting table settings for a DynamoDB Data Pool" width="1671" height="542" data-path="images/docs/2024-12-dynamo-data-pool-04.png" />
    </Frame>

    Answer the questions in the wizard to complete the setup.

    <Frame>
      <img src="https://mintcdn.com/propeldocs/EJuEs6SO8KXtRuWH/images/docs/2024-12-dynamo-data-pool-05.png?fit=max&auto=format&n=EJuEs6SO8KXtRuWH&q=85&s=b689a54cc704914b5a557cfcd1eea58a" alt="Completing the table settings wizard for a DynamoDB Data Pool" width="1671" height="542" data-path="images/docs/2024-12-dynamo-data-pool-05.png" />
    </Frame>

    Confirm your table settings and click **"Continue"**.

    <Frame>
      <img src="https://mintcdn.com/propeldocs/EJuEs6SO8KXtRuWH/images/docs/2024-12-dynamo-data-pool-06.png?fit=max&auto=format&n=EJuEs6SO8KXtRuWH&q=85&s=7ae05a7f9b5edf069b0c6a4036e017a4" alt="Confirming table settings for a DynamoDB Data Pool" width="1671" height="856" data-path="images/docs/2024-12-dynamo-data-pool-06.png" />
    </Frame>
  </Step>

  <Step title="Name your Data Pool">
    Name your Data Pool and give it a description

    <Frame>
      <img src="https://mintcdn.com/propeldocs/EJuEs6SO8KXtRuWH/images/docs/2024-12-dynamo-data-pool-07.png?fit=max&auto=format&n=EJuEs6SO8KXtRuWH&q=85&s=297db7225817d8edf6a7fc2ff5cf3901" alt="Screenshot showing the Data Pool naming page." width="1671" height="548" data-path="images/docs/2024-12-dynamo-data-pool-07.png" />
    </Frame>
  </Step>

  <Step title="Get the Data Pool's HTTP endpoint">
    You're done! You've created a DynamoDB Data Pool. Note the Amazon Data Firehose HTTP endpoint and `X-Amz-Firehose-Access-Key` key, you'll need this to configure the Amazon Data Firehose.

    <Frame>
      <img src="https://mintcdn.com/propeldocs/EJuEs6SO8KXtRuWH/images/docs/2024-12-dynamo-data-pool-08.png?fit=max&auto=format&n=EJuEs6SO8KXtRuWH&q=85&s=4aede92633c1c0ede7edffc7c8be0520" alt="Screenshot showing the Data Pool URL." width="1548" height="1053" data-path="images/docs/2024-12-dynamo-data-pool-08.png" />
    </Frame>
  </Step>
</Steps>

## Step 3: Create the Data Firehose stream to deliver events to Propel

Once you have the DynamoDB Data Pool created, we'll need to create an Amazon Data Firehose that takes the events from the Kinesis data stream and sends them to Propel via HTTP POST request.

<Steps>
  <Step title="Go to Amazon Data Firehose console">
    Navigate to the "**Amazon Data Firehose**" console and click on "**Create Firehose stream**".

    <Frame>
      <img src="https://mintcdn.com/propeldocs/EJuEs6SO8KXtRuWH/images/docs/2024-12-amazon-dynamodb-setup-06.png?fit=max&auto=format&n=EJuEs6SO8KXtRuWH&q=85&s=ef5c579bb83077ce7e508cd2a3c32dda" alt="Screenshot 2024-05-08 at 1.50.27 PM.png" width="926" height="373" data-path="images/docs/2024-12-amazon-dynamodb-setup-06.png" />
    </Frame>
  </Step>

  <Step title="Select source and destination">
    Select "**Kinesis Data streams**" as the source and "**HTTP Endpoint**" as the destination.

    <Frame>
      <img src="https://mintcdn.com/propeldocs/EJuEs6SO8KXtRuWH/images/docs/2024-12-amazon-dynamodb-setup-07.png?fit=max&auto=format&n=EJuEs6SO8KXtRuWH&q=85&s=5a6b47db4beb8dea43c472a29aea8e79" alt="Screenshot showing the source and destination selection." width="950" height="533" data-path="images/docs/2024-12-amazon-dynamodb-setup-07.png" />
    </Frame>
  </Step>

  <Step title="Configure the source">
    In the "**Source settings**," click "**Browse**."

    <Frame>
      <img src="https://mintcdn.com/propeldocs/EJuEs6SO8KXtRuWH/images/docs/2024-12-amazon-dynamodb-setup-08.png?fit=max&auto=format&n=EJuEs6SO8KXtRuWH&q=85&s=1a15f686e48f00b05db7a5eab6051fbc" alt="Screenshot showing the source settings." width="741" height="184" data-path="images/docs/2024-12-amazon-dynamodb-setup-08.png" />
    </Frame>

    Select the Kinesis data stream from your DynamoDB table.

    <Frame>
      <img src="https://mintcdn.com/propeldocs/EJuEs6SO8KXtRuWH/images/docs/2024-12-amazon-dynamodb-setup-09.png?fit=max&auto=format&n=EJuEs6SO8KXtRuWH&q=85&s=2efb8b90dbdfa7dd9c4f026dedcd0b20" alt="Screenshot showing the Kinesis data stream selection." width="1316" height="312" data-path="images/docs/2024-12-amazon-dynamodb-setup-09.png" />
    </Frame>
  </Step>

  <Step title="Name your stream">
    Give your stream a name for future reference.

    <Frame>
      <img src="https://mintcdn.com/propeldocs/EJuEs6SO8KXtRuWH/images/docs/2024-12-amazon-dynamodb-setup-10.png?fit=max&auto=format&n=EJuEs6SO8KXtRuWH&q=85&s=e844adeed79b5041f851fde02c4a31da" alt="Screenshot showing the stream name." width="730" height="180" data-path="images/docs/2024-12-amazon-dynamodb-setup-10.png" />
    </Frame>
  </Step>

  <Step title="Configure the destination">
    We'll need the information about the Propel Data Pool we created earlier.

    <Frame>
      <img src="https://mintcdn.com/propeldocs/EJuEs6SO8KXtRuWH/images/docs/2024-12-amazon-dynamodb-setup-10-1.png?fit=max&auto=format&n=EJuEs6SO8KXtRuWH&q=85&s=9e9b97d8f110ed8907323bd25010f814" alt="Screenshot showing the Propel Data Pool URL." width="1360" height="342" data-path="images/docs/2024-12-amazon-dynamodb-setup-10-1.png" />
    </Frame>

    1. Enter the destination details:

    * **"HTTP endpoint name"** - Name your endpoint (e.g. "Propel Orders")
    * **"HTTP endpoint URL"** - Enter the DynamoDB Data Pool HTTP endpoint URL.
    * **"Access key"** - Enter the `X-Amz-Firehose-Access-Key` key that you'll find under the Data Pool's HTTP endpoint in the Propel Console.
    * **"Retry duration"** - Set to "7200"
    * **"Content encoding"** - Set to "**Not enabled**"

    <Frame>
      <img src="https://mintcdn.com/propeldocs/EJuEs6SO8KXtRuWH/images/docs/2024-12-amazon-dynamodb-setup-11.png?fit=max&auto=format&n=EJuEs6SO8KXtRuWH&q=85&s=5936a423ba3a2a2d891bac4d4fecb0d5" alt="Screenshot showing the Propel Data Pool URL." width="738" height="799" data-path="images/docs/2024-12-amazon-dynamodb-setup-11.png" />
    </Frame>

    * **"Buffer hints"** - Set Buffer size to 1MiB

    <Frame>
      <img src="https://mintcdn.com/propeldocs/EJuEs6SO8KXtRuWH/images/docs/2024-12-amazon-dynamodb-setup-12.png?fit=max&auto=format&n=EJuEs6SO8KXtRuWH&q=85&s=99837b4db25bf1bd9e0ca7e87190fff0" alt="Screenshot showing the destination settings." width="867" height="441" data-path="images/docs/2024-12-amazon-dynamodb-setup-12.png" />
    </Frame>
  </Step>

  <Step title="Configure backup S3 bucket">
    Set up an S3 bucket for failed deliveries under "**Backup settings**".

    <Frame>
      <img src="https://mintcdn.com/propeldocs/EJuEs6SO8KXtRuWH/images/docs/2024-12-amazon-dynamodb-setup-13.png?fit=max&auto=format&n=EJuEs6SO8KXtRuWH&q=85&s=0a2a2a65fea52411b731719ae78f723a" alt="Screenshot showing the backup S3 bucket configuration." width="732" height="496" data-path="images/docs/2024-12-amazon-dynamodb-setup-13.png" />
    </Frame>
  </Step>

  <Step title="Create the stream">
    Click "**Create Firehose stream**" to complete the setup.
  </Step>
</Steps>

<Steps>
  <Step title="Monitor for delivery failures">
    If everything is set up correctly, you should not see any deliveries to the S3 bucket.

    <Frame>
      <img src="https://mintcdn.com/propeldocs/EJuEs6SO8KXtRuWH/images/docs/2024-12-amazon-dynamodb-setup-14.png?fit=max&auto=format&n=EJuEs6SO8KXtRuWH&q=85&s=fe2c7ba09e0ac6ca5b5472c1cd917893" alt="Screenshot showing no deliveries to the S3 bucket." width="1030" height="322" data-path="images/docs/2024-12-amazon-dynamodb-setup-14.png" />
    </Frame>
  </Step>

  <Step title="Preview data">
    Once items are inserted into your DynamoDB table, they stream directly to Propel. By going to your Data Pool and clicking **"Preview Data"**, you'll be able to see the records as they land.
  </Step>
</Steps>

<Frame>
  <img src="https://mintcdn.com/propeldocs/EJuEs6SO8KXtRuWH/images/docs/2024-12-dynamo-data-pool-09.png?fit=max&auto=format&n=EJuEs6SO8KXtRuWH&q=85&s=01bf561c848b6505a2b7ac540954e860" alt="Screenshot showing the data preview in a DynamoDB Data Pool." width="1475" height="550" data-path="images/docs/2024-12-dynamo-data-pool-09.png" />
</Frame>

## Step 4: Transform DynamoDB events in Propel

Now that we are collecting DynamoDB change data capture events in Propel, we can transform them into an entity table.

The following is an example SQL query that flattens the DynamoDB event into an entity table.

```SQL theme={"system"}
SELECT
  -- The unique identifier for the entity
  keys.order_id.S AS order_id, -- DynamoDB Partition key
  parseDateTimeBestEffort(keys.timestamp.S) AS timestamp, -- DynamoDB Sorting key

	-- Save the deleted flag
  if(event_name = 'REMOVE', true, false) AS deleted,

  --All the columns you want to flatten, for example

  toString(new_image.taqueria.S) AS taqueria,
  toInt32OrNull(new_image.quantity.N) AS quantity,
  toFloat64OrNull(new_image.total_price.S) AS total_price,
  new_image.orderItems AS order_items,

	--Always save the new and old image
  new_image,
  old_image
FROM my_dynamo_orders_change_events
```

Replace `my_dynamo_orders_change_events` with your table's name and customize the columns to your needs.

You can test the SQL Query in the “SQL Console” to make sure it works for your events and make any necessary changes.

Once you've tested the SQL query, you can create a Materialized View.

1. Go to the **"Materialized Views"** section in the Console and click **"Create Materialized View"**.

2. Enter the SQL above in the SQL to define the Materialized View.

3. Select **"New Data Pool"**.

4. Give your new Data Pool a name, for example, `dynamodb_<TABLE_NAME>`. Replace `<TABLE_NAME>` with the name of your table.

5. Select **"Mutable records"**, as the records are updatable.

6. Answer the following questions to set the Table settings.

   1. **"Which columns uniquely identify your records?"**

   Select the columns that uniquely identify a record. In DynamoDB, the combination of the PartitionKey and the SortingKey uniquely identifies a record. In the example above, `order_id` uniquely identifies a record.

   2. **"Will you query your data by time?"**

   Select the timestamp column.

   3. **"Are there columns you always filter by?"**

   For small tables (under 100M records), leave empty. For very large tables, see the [Handling updates in large tables guide](https://www.propeldata.com/docs/serverless-clickhouse/guides/table-engine-and-sorting-key#handling-large-updating-tables).

   4. **"Is there an `updated_at` or `version` column?"**

   Leave empty. New records that arrive will replace old ones.

7. Confirm the table settings. You should see:
   1. Table engine: `REPLACING_MERGE_TREE`
   2. Sorting key: `order_id`
   3. Default timestamp: `timestamp`

8. Select **"Backfill"** to ensure that existing records get copied over.

9. Give your Materialized View a name and description, for example, `flattened_dynamodb_<TABLE_NAME>_materialized_view` .

Now that you have created a Data Pool for your table, you can go to the **"Data Pools"** section and click on your  Data Pool. You can click on **"Preview Data"** to see your transformed data.
