/aws-serverless-ddns-terraform

Deployment of DDNS into AWS resources through terraform

Primary LanguageHCLMIT LicenseMIT

aws-serverless-ddns-terraform

The repository to deploy ddns through terraform into aws environment, using API Gateway, Route53 and Lambda. It implements the architecture suggested by Building a serverless dynamic DNS system with AWS and improves it by introducing API-Gateway so DDNS is protected away from non-intended users.

architecture

How to run?

  1. Set up the infrastructure by terraform.
    cd architecture
    terraform init
    terraform apply -auto-approve
  2. Export environment variables for python script.
    export APIGW_INVOKE_URI=
    export X_API_KEY=
  3. Run cronjob to regularly update. python src/local/main.py
    # linux
    sudo apt update
    sudo apt install cron
    # macos -> need permission settings
    brew install cron
    
    # common after installation
    crontab -e
    # add this
    */2 * * * * APIGW_INVOKE_URI= X_API_KEY= python src/local/main.py >> log.txt 2>&1

References

  1. https://www.youtube.com/watch?v=yzT92pEcIvM
  2. https://aws.amazon.com/blogs/startups/how-to-build-a-serverless-dynamic-dns-system-with-aws/#:~:text=AWS%20Services%20We%20Use%20in%20Our%20Dynamic%20DNS%20system&text=Your%20code%20is%20always%20ready,events%20from%20other%20AWS%20services.
  3. https://www.bejarano.io/fixing-cron-jobs-in-mojave/