In this tutorial, we will learn how to run Debezium Server with Pub/Sub sink and Artie Transfer locally using Docker.
Prerequisites
Terraform
Docker
gcloud CLI
GCP Project
Set-up
gcloud CLI
Please visit this link to download the CLI. Once you have done so, run this command:
gcloudauthapplication-defaultlogin
Pub/Sub API
To use Pub/Sub in your GCP project, you will also need to enable it. Visit this link to enable it.
Creating a service account
locals { project ="PROJECT_ID" role ="roles/pubsub.editor"}provider "google" { project = local.project// Authenticate via gcloud auth application-default login// This requires the gcloud CLI downloaded: https://cloud.google.com/sdk/docs/install// Need to enable PubSub API: https://console.cloud.google.com/marketplace/product/google/pubsub.googleapis.com}resource "google_service_account" "artie-svc-account" { account_id ="artie-service-account" display_name ="Service Account for Artie Transfer and Debezium"}resource "google_project_iam_member" "transfer" { project = local.project role = local.role member ="serviceAccount:${google_service_account.artie-svc-account.email}"}
$terraforminit# Install the necessary libraries.$terraformplan$terraformapply
Download the service account credentials
Once your service account has been created, head to the GCP console and create a key for the service account. Save the key as we will be referencing it in the later steps.
Create the Pub/Sub topic and subscriptions
Debezium will not automatically create topics or subscriptions for you.
When running this, the PostgreSQL database already has some seeded data. As a result, we can see the merge statement being issued to add the seeded data.
Now that PostgreSQL is running locally on 0.0.0.0:5432, you can open up a SQL editor to interact with the data model. The example below, we are updating the first_name of a customer object and the change is directly streamed to Artie.