Setting up your NestJS application to connect with Amazon DocumentDB can be challenging. You might face issues with TLS/SSL configuration or security groups.
This guide will walk you through the process smoothly, ensuring a hassle-free setup.
Understanding the Connectivity requirement of DocumentDb
Before creating your DocumentDB database, it's important to know that Amazon DocumentDB is accessible by Amazon EC2 instances and other AWS services within the same VPC. You can connect from different VPCs within the same AWS Region or across Regions using VPC peering.
If you need to access DocumentDB from outside the cluster's VPC, you can use SSH tunneling (port forwarding).
1. Creating a New Amazon DocumentDB Cluster
Step 1: Access the AWS Console
Login to your AWS console.
In the search bar at the top of the console, type "DocumentDB" and select Amazon DocumentDB from the search results.
Step 3: Configure Cluster Settings: Fill in the required information
DB Cluster Identifier: Provide a unique name for your cluster.
Authentication Method: Enter the necessary credentials (username and password) for your cluster.
AWS will take a few minutes to provision your new DocumentDB cluster. Once completed, you'll have a fully functional cluster ready for use.
2. Set Up a Security Group to Allow Connectivity to the DocumentDB Cluster Within the VPC
Next, we'll need to configure security groups to allow our Nest.js application to connect to the DocumentDB cluster within the VPC.
Step 1: Create a Security Group
In your AWS Console, Search for Security Groups
Under the Inbound rules tab, click Add Rule.
Set the Type to Custom TCP
For the Port Range, enter 27017 (the default port for DocumentDB)
In the Source field, specify
Anywhereor0.0.0.0/0this would allow us to connect from anywhere within the vpc
Step 3: Configure Outbound Rules
Go back to the Amazon DocumentDB service in the AWS Console
Select your newly created cluster.
On the VPC Security groups section replace the current security group with the new one you created.
Click Continue to proceed.
Navigate to your DocumentDB dashboard and click the Connectivity & Security tab. Find and copy the .
SOCIAL SHARE CARD GENERATOR