This is a small tool that updates a record in AWS Route53 with a dynamic IP address.
It works on two stages:
In order to resolve the local IP address, this tool requires an external service that accepts a GET request and returns a JSON response in the following form:
{
"ip": "127.0.0.1"
}
An example for the code of such a service can be found here
Once the local IP address has been obtained, it calls Route53 and updates an A
record with the value of said IP address.
This tool depends entirely on environment variables, if unset or empty, it will fail.
RESOLVER_URL
: The URL of the IP resolver to which a GET request will be sent.API_KEY
: The API key of the URL resolver. This API key will be sent as a header under the valuex-api-key
, following the AWS Lambda conventions.HOSTED_ZONE_ID
: The ID of the AWS Route53 hosted zone.RECORD_SET
: The FQDN of the record set to update.
RESOLVER_URL='<AN_URL>' \
API_KEY='<AN_API_KEY>' \
HOSTED_ZONE_ID='<YOUR_ZONE_ID>' \
RECORD_SET='<YOUR_RECORD_SET>' \
go run ./main.go
RESOLVER_URL='https://resolver.example.org/whatsmyip' \
API_KEY='123456' \
HOSTED_ZONE_ID='FOO' \
RECORD_SET='dynamic.example.org' \
go run ./main.go