DocumentDB
Connecting a DocumentDB cluster to a DevZero workspace.
Connecting to DocumentDB running in the private subnet of AWS VPC from your DevBox.
Architecture Diagram
Existing Database
Step 1: Accessing DocumentDB from a DevBox
- Follow the Connecting to AWS guide.
- Go to Amazon DocumentDB > Clusters > Your Cluster.
- Select Connectivity & Security. You will see the commands and DocumentDB hostname for accessing it.
- In your DevBox, import the MongoDB public GPG key:
curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | \
sudo gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg \
--dearmor
- Add MongoDB package repository source:
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list
- Reload local package database:
sudo apt-get update
- Install MongoDB:
sudo apt-get install -y mongodb-org
- Download the certificate:
wget https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem
- Connect to the database:
mongosh --tls --host <your-cluster-endpoint>:27017 --tlsCAFile /path/to/global-bundle.pem --username <your-username> --password <your-password>
where the cluster endpoint will be available in Connectivity & Security section.
New Database
Step 1: Creating a DocumentDB Instance
- Follow the Connecting to AWS guide.
- Go to Amazon DocumentDB > Create Cluster.
- Select Instance Based Cluster.
- In the Configuration section choose Instance Class, number of instances for your cluster.
- Set Username and Password.
- Turn on Show advanced settings.
- In the Network settings , choose the VPC where your bastion host is running, subnet group and assign a security group which has inbound access to only VPC.
- Click Create cluster.
Step 2: Accessing DocumentDB from a DevBox
- In your DevBox, import the MongoDB public GPG key:
curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | \
sudo gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg \
--dearmor
- Add MongoDB package repository source:
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list
- Reload local package database:
sudo apt-get update
- Install MongoDB:
sudo apt-get install -y mongodb-org
- Download the certificate:
wget https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem
- Connect to the database:
mongosh --tls --host <your-cluster-endpoint>:27017 --tlsCAFile /path/to/global-bundle.pem --username <your-username> --password <your-password>
where the cluster endpoint will be available in Connectivity & Security section.