> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-8a08bda2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Step-by-step guide on how to set up Amazon DocumentDB as a source for ClickPipes

# Amazon DocumentDB source setup guide

export const Image = ({img, alt, size}) => {
  return <Frame>
      <img src={img} alt={alt} />
    </Frame>;
};

<h2 id="supported-documentdb-versions">
  Supported DocumentDB versions
</h2>

ClickPipes supports DocumentDB version 5.0.

<h2 id="configure-change-stream-log-retention">
  Configure change stream log retention
</h2>

By default, Amazon DocumentDB has a 3-hour change stream log retention period, while initial load may take much longer depending on existing data volume in your DocumentDB. We recommend setting the change stream log retention to 72 hours or longer to ensure that it isn't truncated before the initial snapshot is completed.

<h3 id="update-change-stream-log-retention-via-aws-console">
  Update change stream log retention via AWS Console
</h3>

1. Click `Parameter groups` in the left panel, find the parameter group used by your DocumentDB cluster (if you're using the default parameter group, you will need to create a new parameter group first in order to modify it).

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-8a08bda2/fIitds1IWScZ_PSw/images/integrations/data-ingestion/clickpipes/mongodb/docdb-select-parameter-group.png?fit=max&auto=format&n=fIitds1IWScZ_PSw&q=85&s=690215d4f7728e072e1c669662c29ae7" alt="Select parameter group" size="lg" border width="2534" height="1266" data-path="images/integrations/data-ingestion/clickpipes/mongodb/docdb-select-parameter-group.png" />

2. Search for `change_stream_log_retention_duration`, select and edit it to `259200` (72 hours)

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-8a08bda2/fIitds1IWScZ_PSw/images/integrations/data-ingestion/clickpipes/mongodb/docdb-modify-parameter-group.png?fit=max&auto=format&n=fIitds1IWScZ_PSw&q=85&s=57d2c3ab3ec169476e02adc9bd5ffbbd" alt="Modify parameter group" size="lg" border width="2524" height="1332" data-path="images/integrations/data-ingestion/clickpipes/mongodb/docdb-modify-parameter-group.png" />

3. Click `Apply Changes` to apply the modified parameter group to your DocumentDB cluster immediately. You should see the status of the parameter group transition to `applying`, and then to `in-sync` when the change is applied.

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-8a08bda2/fIitds1IWScZ_PSw/images/integrations/data-ingestion/clickpipes/mongodb/docdb-apply-parameter-group.png?fit=max&auto=format&n=fIitds1IWScZ_PSw&q=85&s=91824d3de5fc954334158385641a65f4" alt="Apply parameter group" size="lg" border width="2520" height="1596" data-path="images/integrations/data-ingestion/clickpipes/mongodb/docdb-apply-parameter-group.png" />

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-8a08bda2/fIitds1IWScZ_PSw/images/integrations/data-ingestion/clickpipes/mongodb/docdb-parameter-group-status.png?fit=max&auto=format&n=fIitds1IWScZ_PSw&q=85&s=2bf922a8d29429e942efb090e08fec7d" alt="Parameter group status" size="lg" border width="2538" height="694" data-path="images/integrations/data-ingestion/clickpipes/mongodb/docdb-parameter-group-status.png" />

<h3 id="update-change-stream-log-retention-via-aws-cli">
  Update change stream log retention via AWS CLI
</h3>

Alternatively, you can configure this via AWS CLI.

To check the current change stream log retention period:

```shell theme={null}
aws docdb describe-db-cluster-parameters --db-cluster-parameter-group-name <PARAMETER_GROUP_NAME> --query "Parameters[?ParameterName=='change_stream_log_retention_duration'].{Name:ParameterName,Value:ParameterValue}"
```

To set the change stream log retention period to 72 hours:

```shell theme={null}
aws docdb modify-db-cluster-parameter-group --db-cluster-parameter-group-name <PARAMETER_GROUP_NAME> --parameters "ParameterName=change_stream_log_retention_duration,ParameterValue=259200,ApplyMethod=immediate"
```

<h2 id="configure-database-user">
  Configure a database user
</h2>

Connect to your DocumentDB cluster as an admin user and execute the following command to create a database user for MongoDB CDC ClickPipes:

```javascript theme={null}
db.getSiblingDB("admin").createUser({
    user: "clickpipes_user",
    pwd: "some_secure_password",
    roles: ["readAnyDatabase", "clusterMonitor"],
})
```

<Note>
  Make sure to replace `clickpipes_user` and `some_secure_password` with your desired username and password.
</Note>

<h2 id="whats-next">
  What's next?
</h2>

You can now [create your ClickPipe](/integrations/clickpipes/mongodb) and start ingesting data from your DocumentDB instance into ClickHouse Cloud.
Make sure to note down the connection details you used while setting up your DocumentDB cluster as you will need them during the ClickPipe creation process.
