Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 21

Connecting External Systems with MSK Connect

Recommended resources

Hello! Welcome back to our preparation for the AWS Certified Data Engineer - Associate exam.

In our last lesson, we focused on writing custom producer and consumer applications to send and receive data from our MSK cluster. This gave you full control over the data flow, but required you to write, package, and manage your own application code.

Today, we'll explore a powerful, often more efficient, way to build data pipelines with MSK. We will be covering how to integrate external systems with MSK using MSK Connect. This feature allows you to stream data from common sources (like databases) into MSK and from MSK to common destinations (like S3) using pre-built components, often without writing any custom code. This is a key capability for data engineers looking to build robust pipelines quickly.

1. What is Amazon MSK Connect?

MSK Connect is AWS's fully managed service for Apache Kafka Connect. Kafka Connect is an open-source framework for reliably streaming data between Apache Kafka and other systems. MSK Connect takes care of the operational overhead of running this framework, like provisioning servers, managing scaling, and handling failures, so you can focus on the data pipeline logic itself.

To get a concise, high-level overview of what MSK Connect is and why it's useful, let's start with a short video from AWS.

Introduction to Amazon MSK Connect | Amazon Web Services

This video, 'Introduction to Amazon MSK Connect' from the official Amazon Web Services channel, provides a great summary of the service's purpose and benefits.

Watch the video from the beginning to 02:14, and then from 03:13 to the end (03:46). Focus on: The problems MSK Connect solves compared to self-managed Kafka Connect. The common use cases, such as Change Data Capture (CDC) from databases to S3. The key benefits: being serverless, fully managed, and compatible with Kafka Connect.

The core of MSK Connect revolves around two types of components:

  • Source Connectors: These connectors "source" data from an external system (like a database, a SaaS application, or a file system) and publish it into an MSK topic.
  • Sink Connectors: These connectors "sink" data from an MSK topic and write it to an external system (like a data warehouse, a search index, or an object store like S3).
Amazon MSK Connect for Backup and Restore with S3
This diagram clearly illustrates the two fundamental flows. A **Sink Connector** backs up data from an MSK topic to S3. A **Source Connector** restores or ingests data from S3 into an MSK topic. This push/pull model is central to MSK Connect.

2. A Hands-On Pipeline: Streaming Database Changes to S3

Theory is great, but seeing MSK Connect in action provides the best understanding. We will now walk through a complete, practical project that demonstrates a common data engineering pattern: capturing changes from a relational database in real time and streaming them to a data lake in Amazon S3.

Since you're already very familiar with S3 and Athena, you can imagine how this pattern forms the ingestion foundation for a data lake. Once the data lands in S3, it's ready to be cataloged and queried.

The following video is a comprehensive, step-by-step tutorial. We'll break it down into logical phases. The goal isn't for you to replicate every click, but to understand the process and the configuration at each stage.

Real-Time Data Pipeline with Apache Kafka and AWS | AWS MSK | Hands-on Data Engineering Project

The video 'Real-Time Data Pipeline with Apache Kafka and AWS' by AWS Made Easy is a fantastic, in-depth project that builds exactly the kind of pipeline you'll encounter in real-world scenarios and on the exam.

This is a detailed walkthrough. Follow the key stages below to understand how the pipeline is constructed: Architecture and Concepts (00:00 - 02:06): Pay close attention to the architecture diagram. It shows an RDS SQL Server as the source, MSK as the broker, and S3 as the destination. The video also gives a great explanation of what Kafka Connect is and the roles of source and sink connectors. Preparing the Connector Plugins (24:47 - 26:34): MSK Connect needs the actual connector code, called plugins. This section shows the downloading of two key plugins: the Debezium SQL Server CDC Source Connector (for capturing database changes) and the Amazon S3 Sink Connector. Configuring the Source Connector (26:34 - 35:35): This is a critical section. Observe how the connector is created in the AWS console. The configuration includes the database connection details, the tables to monitor (table.include.list), the Kafka cluster to write to, and the IAM role that grants permissions. Configuring the Sink Connector (45:14 - 47:44): Now, for the other side of the pipeline. The S3 sink connector is configured to read from the topic populated by the source connector and write the data to a specific S3 bucket. Verification and End-to-End Flow (47:44 - 51:27): This part confirms the pipeline is working. Data appears in the S3 bucket. Most importantly, a DELETE operation in the source database is captured and streamed to S3, demonstrating the real-time Change Data Capture (CDC) capability.

This hands-on example shows how you can build a powerful, real-time ingestion pipeline with configuration, not code. You're simply "connecting" the pieces together.

Test your understanding!

You are tasked with ingesting customer data from a Salesforce system into your AWS environment. The goal is to analyze this data in near real-time using Amazon OpenSearch Service. Which MSK Connect components would you need to implement this pipeline?

Show answer

You would need two connectors:

  1. A Salesforce Source Connector to pull data changes from Salesforce and publish them to an MSK topic.
  2. An OpenSearch Sink Connector to read the data from the MSK topic and write it into your OpenSearch domain for indexing and analysis.

3. A Deeper Look at Connector Configuration

The video provided a great visual walkthrough. Now, let's examine the configuration properties more closely. As an engineer, understanding these settings is crucial for customizing and troubleshooting connectors.

The following article gives a detailed breakdown of the properties for a Debezium (PostgreSQL variant) source connector and a JDBC sink connector. While the specific connectors are different from the video, the principles and many of the properties are analogous.

Building a data pipeline with AWS MSK and ...

The blog post 'Building a data pipeline with AWS MSK' from IT Gix provides an excellent deep dive into the specific configuration properties for source and sink connectors. This will build on the practical steps you saw in the video.

Read sections 7. Source Connector and 7.5 Sink Connector configuration. Don't worry about memorizing every property. Instead, focus on understanding the purpose of these key configuration groups: Connection Details: Properties for connecting to the source/sink system (e.g., database.hostname, connection.url). Data Selection: Properties that define what data to move (e.g., table.include.list for the source, topics for the sink). Behavior Control: Properties that control how the connector operates (e.g., insert.mode for the sink, transforms for the source to manipulate topic names). Worker Configuration: Note the discussion around offset.storage.topic. This topic is used by Kafka Connect to track its progress, making it resilient to restarts. Defining it explicitly prevents losing state if a connector is re-created.

Understanding these properties is key to passing scenario-based exam questions where you might need to identify a misconfiguration or choose the right setting for a given requirement.


Conclusion

In this lesson, we transitioned from writing custom Kafka clients to using the managed, configuration-driven approach of MSK Connect. This is a vital tool for any data engineer using the AWS ecosystem, enabling rapid development of reliable data ingestion and egress pipelines.

Key Takeaways:

  • MSK Connect is a fully managed service for running Apache Kafka Connect, removing the need to manage the underlying infrastructure.
  • It uses Source Connectors to ingest data from external systems into MSK topics and Sink Connectors to export data from topics to external systems.
  • Popular use cases include Change Data Capture (CDC) from databases like RDS and streaming data to storage layers like S3.
  • Configuration is key: you define the connector logic, connection details, and data scope through a set of properties rather than custom application code.

You now have two powerful methods for getting data in and out of your MSK cluster: custom clients for maximum flexibility and MSK Connect for rapid, standardized integration.

Next Up: As we start moving structured data through our pipelines with connectors, the format, or schema, of that data becomes critical. In our next lesson, we will address this by learning how to "Manage schemas for Kafka topics using the AWS Glue Schema Registry," a service that integrates seamlessly with MSK Connect.