Phase 4: Spin Up, DNS and Frontend Redirect
Overview
At this point, we have our first Lambda where we handle meeting scheduling. Now we're gonna go ballistic on the Lambdas. Things are gonna go pretty quick, but don't worry, wherever we get a bit funky I'll slow down.
Warning - Domain Required
BEFORE WE START: you need a domain. If you haven't had any issues with SSL certificates and connectivity yet, you are about to. The moment you start using the DCV SDK, using WebSocket or anything TCP / UDP, you will get screwed.
You don't need to use Cloudflare like me, but these docs will discuss Cloudflare. The main steps are the same for all DNS providers: you will need to be able to install an origin certificate on the EC2, enable HTTPS / SSL certificates, including locally, and be able to create an A certificate for a specific domain. You can use Route 53 and other DNS management services in AWS if you are more comfortable.
This will probably be the most complex section of this project.
What We're Building
Here's what we're going to do:
- After
schedule-meeting, EventBridge scheduler will runlaunch-ec2, which will spin up two EC2 instances from an AMI. ElephantDNSWatchdogwill wait for the state of the EC2 to change from "initializing" to "running". Once it does, it will use the Cloudflare API to create a new A certificate on your domain. It will also write the EC2 URL to the DynamoDB.- Then
dcv-urlwill fetch the URL and redirect the user in the frontend.
Later on, when we configure the spin down, we're going to have a 15 minute safety net where we kill any EC2 instances not being used. Then our actual meeting termination will be handled by the Stream feature with DynamoDB, that will send any modifications as an object to the termination Lambda.

Note - Lambda Architecture
So yeah, like 6 Lambdas in this section? And honestly, the functions of some of them could be decoupled into more. The moment you need data to move across an architecture, or have one service to talk to another, that's a new Lambda. They're really like spaghetti strands.
What You'll Learn
This phase covers:
- Certificates in Cloudflare - Set up SSL certificates for secure DCV connections
- Getting a Token from Cloudflare - Obtain API token for DNS management
- Launch EC2 - Create Lambda to programmatically spin up EC2 instances
- ElephantDNSWatchdog - Monitor EC2 state changes and manage DNS records
- Frontend Implementation - Integrate meeting links and redirects
- Get DCV URL - Lambda to fetch and redirect users to their EC2 instances
- Spin Down - Configure termination Lambdas for safe EC2 instance shutdown
Let's get started with Certificates in Cloudflare →