Files
ddns/README.md
Joe Monk 0164290830
All checks were successful
Build and deploy / deploy (push) Successful in 41s
Init the ddns service, create app, aws and ip modules
2024-11-11 14:47:39 +00:00

1.3 KiB

Description

A nestjs service that grabs your ip from https://ifconfig.co and updates a record in route 53 to point to that.
Effectively aws dynamic dns as a docker.

Project setup

$ npm install

Env vars

You can use a .env file for local dev

# The keys from the IAM user below
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
PORT=3000
CRON=0 0 */4 * * *
# The record name is your hostname, i.e. subdomain.domain.co.uk
RECORD_NAME=
# From hosted zone details
HOSTED_ZONE_ID=

AWS

Create a new IAM user and attach a policy to change the records in your zone:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": ["route53:ChangeResourceRecordSets"],
      "Resource": "arn:aws:route53:::hostedzone/HOSTED_ZONE_ID"
    }
  ]
}

Create a new access key and use the credentials in the env vars to allow access.

Compile and run the project

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Layout

ip module

This module is just to send provide your current ip, whether this is by asking your router, or using a service like

aws module

This connects to aws and updates the record name to the ip passed in

app module

Connects everything together