|
| 1 | +# 🚀 ZDM Dual Write Proxy for Amazon Keyspaces Migration |
| 2 | + |
| 3 | +This project extends the official [ ZDM Proxy](https://github.com/datastax/zdm-proxy) to support seamless **zero-downtime migration** from **Apache Cassandra** to **Amazon Keyspaces (for Apache Cassandra)** with AWS best practices. |
| 4 | + |
| 5 | +It introduces key enhancements: |
| 6 | + |
| 7 | +- A custom Docker image hosted in **Amazon ECR** for VPC-accessible deployments. |
| 8 | +- A **CloudFormation template** to deploy the proxy on **AWS Fargate**, ensuring a scalable, serverless, and secure setup within your existing AWS infrastructure. |
| 9 | + |
| 10 | + |
| 11 | +The proxy is deployed with Amazon ECS on Fargate which can scale up and down based on application demand. The Network load balancer allows application traffic to be distributed across a number of ECS tasks. |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | +## 📁 Project Structure |
| 18 | + |
| 19 | +| File | Description | |
| 20 | +| ------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | |
| 21 | +| `Dockerfile` | Builds the custom ZDM Proxy image with Keyspaces-compatible networking and TLS support. | |
| 22 | +| `entrypoint.sh` | Entry script for the container. Resolves DNS, manages proxy routing via `socat`, and sets environment variables dynamically. | |
| 23 | +| `move-docker-to-ecr.sh` | Automates Docker image build, tagging, and pushing to Amazon ECR. Also downloads the required TLS root cert. | |
| 24 | +| `zdm-proxy-cloudformation.yaml` | CloudFormation template for deploying the proxy as a Fargate task behind an NLB in a private VPC. | |
| 25 | + |
| 26 | +--- |
| 27 | + |
| 28 | +## 🛠️ Parameters (CloudFormation Template) |
| 29 | + |
| 30 | +### 🔌 Network Configuration |
| 31 | + |
| 32 | +- **VPCId**: ID of your target VPC. |
| 33 | +- **PrivateSubnetIds**: List of private subnet IDs. |
| 34 | +- **SecurityGroupId**: Security Group for the Network Load Balancer. |
| 35 | +- **RouteTableId**: Optional; for route management if using PrivateLink. |
| 36 | + |
| 37 | +### 🔄 Origin & Target Cassandra Config |
| 38 | + |
| 39 | +- **ZDMOriginContactPoints**, **ZDMTargetContactPoints**: IP/DNS for the clusters. |
| 40 | +- **ZDMOriginPort**, **ZDMTargetPort**: Usually 9042 for Cassandra, 9142 for Amazon Keyspaces. |
| 41 | +- **ZDMOriginUsername/Password**, **ZDMTargetUsername/Password**: Auth credentials. |
| 42 | + |
| 43 | +### ⚙️ Proxy Config |
| 44 | + |
| 45 | +- **ServiceReplicaCount**: Number of ECS tasks to launch. |
| 46 | +- **ZDMProxyPort**: Port for the proxy service. Default is `14002`. |
| 47 | + |
| 48 | +--- |
| 49 | + |
| 50 | +## 📦 Deployment Instructions |
| 51 | + |
| 52 | +### 1. 🧱 Build and Push Image |
| 53 | + |
| 54 | +```bash |
| 55 | +./move-docker-to-ecr.sh |
| 56 | +``` |
| 57 | + |
| 58 | +### 2. ☁️ Launch CloudFormation Stack |
| 59 | + |
| 60 | +Upload the `zdm-proxy-cloudformation.yaml` to S3 or the AWS Console and deploy it. Provide required parameters (e.g., subnets, contact points). |
| 61 | + |
| 62 | +--- |
| 63 | + |
| 64 | +## 🔐 Security and TLS |
| 65 | + |
| 66 | +- TLS is handled via Amazon Keyspaces' default requirement. The proxy ensures secure, in-transit communication. |
| 67 | + |
| 68 | +--- |
| 69 | + |
| 70 | +## ✅ Best Practices for Amazon Keyspaces |
| 71 | + |
| 72 | +- Uses **port 9142** for CQL over TLS as required by Amazon Keyspaces. |
| 73 | +- Supports **DNS-based discovery** of Amazon Keyspaces via `entrypoint.sh`. |
| 74 | +- Deployable **entirely within a VPC** for added security and compliance. |
| 75 | + |
| 76 | +--- |
| 77 | + |
| 78 | +## 🧪 Testing & Validation |
| 79 | + |
| 80 | +Once deployed: |
| 81 | + |
| 82 | +- Point your application to the NLB DNS created by the CloudFormation stack. |
| 83 | +- Test dual writes by verifying data in both origin and target clusters. |
| 84 | + |
| 85 | +--- |
| 86 | + |
| 87 | +## 📚 References |
| 88 | + |
| 89 | +- [Amazon Keyspaces Developer Guide](https://docs.aws.amazon.com/keyspaces/latest/devguide/) |
| 90 | +- [Official ZDM Proxy Repo](https://github.com/datastax/zdm-proxy) |
| 91 | + |
0 commit comments