Data Ingestion using Database Migration Service(DMS) and Lambda
Last updated
Last updated
The AWS Database Migration Service(DMS) is a managed service to migrate data into AWS. It can replicate data from operational databases and data warehouses (on premises or AWS) to a variety of targets, including S3 datalakes. In this architecture, DMS is used to capture changed records from relational databases on RDS or EC2 and write them into S3. AWS Lambda, a serverless compute service, is used to transform and partition datasets based on their arrival time in S3 for better query performance.
Create a Relational databases on EC2 or RDS within a VPC.
Create a Staging S3 location to store changes captured by DMS.
Create a Replication Instance using the DMS API's or console
Specify the Source & Target Endpoints for the Replication Instance.
Create an IAM role for AWS Lambda which has read access on the staging S3 bucket and write access on target datalake location.
Create a Lambda function to trigger custom code execution with s3:ObjectCreated:*
requests to the staging S3 bucket. The function writes the same objects to the target datalake location on S3 with partitions based on the LastModified
metadata attribute of S3 objects.
Create a DMS Task to migrate data from your source system to target location.
The DMS Replication Instance will then connect to the source via elastic network interface(ENI), and write to the S3 staging location. AWS Lambda will receive the PutObject events, and use the S3 Copy API to reorganise the data into your datalake.