Create a Serverless Dynamic DNS System with AWS Lambda

Jaisen Mathai
2 min readApr 5, 2016

--

Joule lets you easily deploy serverless apps so you can focus on the code. Sign up for an account and deploy an existing serverless application in seconds.

A friend sent me Sean Greathouse’s post on building a Dynamic DNS System using AWS Lambda. Sean presents an interesting application for using serverless architecture using AWS Lambda.

Joule makes it easy to deploy a dynamic DNS system without any prior knowledge of AWS Lambda or serverless architecture.

Deploy a serverless dynamic DNS system on AWS Lambda with a click.

My favorite feature from Sean’s post was the authentication model he used. To update the DNS entry for a domain the client needs to provide two factors. The client’s IP address is taken from the HTTP request and a shared secret is used to sign the request with a token.

Let’s get started, shall we?

Create an IAM Role

You’ll need credentials which allow for updating your Route53 recordset. The IAM policy below grants access to list your hosted zones and change it’s record sets. Replace your_zone_id with the zone id of the domain you’d like to use for dynamic DNS. You can find this in the URL of the AWS console when viewing your zone. It will look something like Z2MQPQRT1FQ4PS.

Save your credentials because you’ll need to add them to your Joule.

Create your Joule

Start by forking the dynamic DNS Joule for AWS Lambda I created that contains everything you need. This creates a fork of the source code in your GitHub account and deploys it as a Lambda function.

Now you’ll want to add some environment variables to your Joule. This includes the IAM key and secret from above, the zone, domain and a secret. Here are some sample values.

AWS_KEY: your_aws_key
AWS_SECRET: your_aws_secret
ZONE: example.com.
DOMAIN: test.example.com.
SECRET: a_secret_you_chose

Make sure you include the trailing “.” for ZONE and DOMAIN.

Pressing Save configures your Joule to dynamically update your DNS records.

Run your Joule

You should have a computer which calls your Joule. This updates the DNS record for your domain to match your computer’s public IP address. This Joule comes with a command-line client that makes it easy to set this up.

Clone your GitHub repository using the instructions provided on your Joule page. The client can is at clients/bash/client.sh. You’ll want to put this in some sort of crontab.

What’s next

Now that you’ve got everything working you can start poking around the source code for your Joule. You can clone your GitHub repository to look at the source code locally.

Our quickstart guide on getting started with Joule is a great place to start.

Feeling lazy? I’ve included the source code below.

--

--