Skip to content

Can't able to connect Mongodb Atlas with AWS glue

0

In Glue I tried to connect Mongodb Atlas in Data connection option (where I found default connector component). I provided the all required detail that asked in that connector, then I tried the test connection option but it failed. Many time I tried I'm facing the same problem.! Enter image description here. So is there any option to connect it .

2 Answers
0

Hi Hari,

You're not alone — connecting AWS Glue to MongoDB Atlas can be tricky due to network and protocol differences. Here's a checklist to help troubleshoot and resolve the issue:

Key Things to Double-Check:

  1. Connection String Format Avoid using mongodb+srv:// — AWS Glue does not support SRV DNS format. Instead, use the standard format:

php-template Copy Edit mongodb://<username>:<password>@<cluster-address>:27017/<dbname>?authSource=admin 2. MongoDB Atlas Network Access Make sure the public IP address of your Glue connection’s subnet or NAT gateway is allowed in your Atlas Network Access settings. For testing, you can temporarily allow access from all IPs (0.0.0.0/0), then restrict it once verified.

  1. Glue VPC Configuration If you’re using Glue in a VPC, confirm:

The subnet has a route to the internet (via a NAT or Internet Gateway).

The security group allows outbound traffic to *.mongodb.net on port 27017.

  1. Test the Connection Use the "Test Connection" option in Glue. If it fails, it's often due to network access or IP address restriction, not credentials.

  2. IAM Role Permissions Ensure the IAM role attached to Glue has permissions to access secrets if you're using AWS Secrets Manager to store your MongoDB credentials.

Bonus Tips: Try connecting to your Atlas cluster from an EC2 instance in the same VPC as Glue to verify network path and permissions.

If Glue still can't connect, consider using a Glue Python shell job or Spark job with the MongoDB Spark Connector.

Let me know what error message you’re seeing and I can help dig deeper!

answered 5 months ago
  • Hi TheQuietbuilder, Thanks for the replay and update, My mongodb is not in any VPC,it's outside and all network are used in network access even region ip, is there any specific IAM role permission for mongodb, but still I'm using SRV dns format because Atlas connection itself given example to use that +SRV, so if I use without them whether it will work?

0

It seems you're experiencing difficulties connecting AWS Glue to MongoDB Atlas. This is a common issue that can occur due to various reasons. Here are some steps you can take to troubleshoot and potentially resolve the connection problem:

  1. Double-check your connection details: Ensure that all the information you've provided in the AWS Glue connection configuration is accurate. This includes the connection string, username, password, and any other parameters. Even small typos or extra spaces can cause connection failures.

  2. Verify network configuration: Make sure that the network settings in your AWS environment allow outbound connections to MongoDB Atlas. This involves checking security groups, network ACLs, and other networking settings that might be blocking the connection.

  3. Review MongoDB Atlas security settings: Confirm that the IP address or range associated with your AWS Glue environment is whitelisted in MongoDB Atlas. Also, verify that the user credentials you're using have the necessary permissions to access the database.

  4. Use the correct connection string format: For MongoDB Atlas connections in AWS Glue, you should use the standard "mongodb" protocol instead of "mongodb+srv". Your connection string should look something like this:

  • Host: hostname.mongodb.net
  • Port: 27017
  • Database Name: your_database_name (in the connection properties)
  1. Update JDBC connector: Ensure you're using the latest version of the JDBC connector for MongoDB, as newer versions may include bug fixes and improvements.

  2. Try alternative connection methods: If the default connector component isn't working, you might consider connecting to MongoDB Atlas using a URI string, username, and password directly in your Glue job script.

  3. Test connection from AWS Glue console: Attempt to test the connection directly from the AWS Glue console to isolate whether the issue is specific to the job or related to the connection configuration itself.

If you continue to face issues after trying these steps, it may be helpful to review the specific error messages you're receiving and consider reaching out to AWS support for more tailored assistance.
Sources
AWS Glue Connector will not connect to mongoDB Atlas | AWS re:Post
AWS Glue Notebook Cannot Identify Schema Consistently for MongoDB Atlas Source | AWS re:Post
Athena Federated Connector - DocumentDb - MongoDb Altas - connection string contains an invalid host 'mongodb+srv' | AWS re:Post

answered 5 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.