Example Terraform template for provisioning AWS and Confluent Cloud resources for atm-fraud demo.
Before you get started, you're going to need a few things.
- Terraform
- Install Terraform by following the instructions here.
- Confluent Cloud account
- Sign up for a Confluent Cloud account.
- AWS account
- Sign up for an AWS account.
- Confluent Cloud Cloud API Key & Secret
- Create Confluent Cloud API Key & Secret by following the instructions here. You will need to create a new API Key and Secret for this demo or use an existing one. Terraform will use these credentials to create the resources in Confluent Cloud and will prompt you when you run
terraform apply
for the values.
- Create Confluent Cloud API Key & Secret by following the instructions here. You will need to create a new API Key and Secret for this demo or use an existing one. Terraform will use these credentials to create the resources in Confluent Cloud and will prompt you when you run
- MongoDB Atlas
- Create a MongoDB Atlas cluster by following the instructions here. You will need to create a new cluster for this demo or use an existing one.
- AWS CLI and AWS credentials
If you don't have these things, create and collect them. Make sure to create resources in us-east-1.
To begin, the absolute first thing you'll need to do is clone this repo.
git clone git@github.com:mvfolino68/terraform-aws-confluent-cloud-atm-usage.git && cd terraform-aws-confluent-cloud-atm-usag
Provisioning should be easy. This example is meant to create an almost end-to-end setup of components in AWS and Confluent Cloud (still waiting on the Ksql Query part). To provision everything follow the next few steps.
Initialize Terraform in the /terraform
directory.
terraform init
Create a plan.
terraform plan
Apply the whole thing!
terraform apply -auto-approve
Note: the
-auto-approve
flag automagically accepts the implicit plan created byapply
.
Give your configuration some time to create. When it's done, head to the Confluent UI and check out what was provisioned.
To create the streaming topology, paste the following into you Ksql editor. Be sure to set auto.offset.reset
to earliest
!
see ksql.sql
for more details
Once everything has been created, go check out Stream Lineage to see your topology in action.
When you have the MongoDB Atlas cluster created, you can create the connector to connect to it. These are example parameters for the connector.
- In CC cluster
Add MongoDB Atlas Sink connector
- hostname:
cluster0.xprwruk.mongodb.net
- connection user:
mongodbuser
- password:
abcABC123
- database:
dev
- collection:
atm_fraud
- schema:
json sr
- hostname:
Once you're satisfied with what you've built, do ahead and destroy it.
terraform destroy
Allowing this to continue to run will incur charges or consume all of the free tier. To avoid this, you can destroy the resources that exceed free tier or are not free tier eligible. You can reapply the resources that are free tier eligible when you're ready to continue.
terraform destroy -target=confluent_connector.postgres_cdc_atm \
-target=aws_vpc.main \
-target=aws_subnet.public_subnets \
-target=aws_internet_gateway.igw \
-target=aws_route_table.route_table \
-target=aws_security_group.postgres_sg \
-target=random_id.atm_id \
-target=cloudinit_config.pg_bootstrap_atm \
-target=aws_instance.postgres_atm \
-target=aws_eip.postgres_atm_eip