For anyone struggling with DocumentDB, I was able to configure it:
- get CA .pem file
wget https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem and save it on the same level as server.ts file
- set correct MONGODB_URI
mongodb://<user_with_access_to_database>:<password>@<documentdb_domain_from_aws_dashboard>:27017/<database>
- update configuration passed to payload.init in server.ts file:
payload.init({
...
mongoURL: process.env.MONGODB_URI,
mongoOptions: {
ssl: true,
sslCA: path.resolve(__dirname, 'rds-combined-ca-bundle.pem'),
useFacet: false,
retryWrites: false
}
});
I've also encountered MongoServerSelectionError: Server selection timed out after 30000 ms error but it was fixed by provided mongoOptions (it was probably fixed by changing tlsCAFile to sslCA). Hope it'll help someone ✌️