Compose your ETL jobs for MongoDB Atlas with AWS Glue
A practical takeaway for platform teams is that this pattern is less about โmoving filesโ and more about standardizing data flow boundaries between operational and analytical systems. Using AWS Glue as the orchestration and transformation layer gives architects a managed execution model for batch ETL, while MongoDB Atlas acts as the operational target or source. The important design question is where transformation logic should live, how jobs are parameterized, and how credentials, schema assumptions, and runtime dependencies are governed across environments.
The integration also highlights a common trade-off in modern data platforms: serverless convenience versus control over execution behavior. Glue reduces infrastructure overhead, but teams still need to account for job startup time, Spark script maintenance, and the operational cost of large joins or reshaping tasks. That means data engineers should treat the ETL script as deployable code, with versioning, repeatable promotion, and clear ownership for changes that affect upstream ingestion or downstream analytics.
Security and access management are not incidental here. The workflow depends on AWS Secrets Manager, IAM role scoping, and network access to Atlas. In practice, those dependencies determine whether the pipeline is production-ready or merely functional in a demo. Teams should validate least-privilege permissions, secret rotation paths, and the blast radius of any misconfigured job parameters, especially when the same pattern is reused for both loading and extraction.
For architecture teams, the main value is interoperability. The pattern lets one ETL service bridge operational databases and S3-backed lakes without forcing a wholesale platform rewrite. That makes it useful for modernization programs where legacy data must be staged into Atlas or exported for analytics. The broader implication is maintainability: once the data contract, runtime, and observability model are defined, the same pipeline shape can support future data domains with less custom glue code.
Solution overview
In this post, we explore the following use cases:- Extracting data from MongoDB โ MongoDB is a popular database used by thousands of customers to store application data at scale. Enterprise customers can centralize and integrate data coming from multiple data stores by building data lakes and data warehouses. This process involves extracting data from the operational data stores. When the data is in one place, customers can quickly use it for business intelligence needs or for ML.
- Ingesting data into MongoDB โ MongoDB also serves as a no-SQL database to store application data and build operational data stores. Modernizing applications often involves migration of the operational store to MongoDB. Customers would need to extract existing data from relational databases or from flat files. Mobile and web apps often require data engineers to build data pipelines to create a single view of data in Atlas while ingesting data from multiple siloed sources. During this migration, they would need to join different databases to create documents. This complex join operation would need significant, one-time compute power. Developers would also need to build this quickly to migrate the data.
In order to implement this architecture, you will need a MongoDB Atlas cluster, an S3 bucket, and an AWS Identity and Access Management (IAM) role for AWS Glue. To configure these resources, refer to the prerequisite steps in the following GitHub repo.
The following figure shows the data load workflow from an S3 bucket into MongoDB Atlas using AWS Glue.
The same prerequisites are needed here: an S3 bucket, IAM role, and a MongoDB Atlas cluster.
Load data from Amazon S3 to MongoDB Atlas using AWS Glue
The following steps describe how to load data from the S3 bucket into MongoDB Atlas using an AWS Glue job. The extraction process from MongoDB Atlas to Amazon S3 is very similar, with the exception of the script being used. We call out the differences between the two processes.- Create a free cluster in MongoDB Atlas.
- Upload the sample JSON file to your S3 bucket.
- Create a new AWS Glue Studio job with the Spark script editor option.
- Depending on whether you want to load or extract data from the MongoDB Atlas cluster, enter the load script or extract script in the AWS Glue Studio script editor.
The code uses AWS Secrets Manager to retrieve the MongoDB Atlas cluster name, user name, and password. Then, it creates a DynamicFrame for the S3 bucket and file name passed to the script as parameters. The code retrieves the database and collection names from the job parameters configuration. Finally, the code writes the DynamicFrame to the MongoDB Atlas cluster using the retrieved parameters.
- Create an IAM role with the permissions as shown in the following screenshot.
- Give the job a name and supply the IAM role created in the previous step on the Job details tab.
- You can leave the rest of the parameters as default, as shown in the following screenshots.


- Next, define the job parameters that the script uses and supply the default values.

- Save the job and run it.
- To confirm a successful run, observe the contents of the MongoDB Atlas database collection if loading the data, or the S3 bucket if you were performing an extract.
- To troubleshoot your runs, review the Amazon CloudWatch logs using the link on the jobโs Run tab.
Conclusion
In this post, we described how to extract and ingest data to MongoDB Atlas using AWS Glue. With AWS Glue ETL jobs, we can now transfer the data from MongoDB Atlas to AWS Glue-compatible sources, and vice versa. You can also extend the solution to build analytics using AWS AI and ML services. To learn more, refer to the GitHub repository for step-by-step instructions and sample code. You can procure MongoDB Atlas on AWS Marketplace.About the Authors
Enjoyed this article? Sign up for our newsletter to receive regular insights and stay connected.
