~phroa/awsddns

ref: 1e7b4c9fad49a878f420443784d8260ec97b58aa awsddns/awsddns -rwxr-xr-x 579 bytes
1e7b4c9fJack Stratton Initial commit 1 year, 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env bash

set -eux

API="https://du0v02jxu4.execute-api.us-east-1.amazonaws.com/default/my-ip"
DOMAIN="${2-phroa.net}"
SUBDOMAIN="${1-$HOST}"

hosted_zone_id="$(aws --output json route53 list-hosted-zones | jq -r '.HostedZones | map(select(.Name == "'"$DOMAIN"'."))[0].Id')"
tempfile="$(mktemp)"

curl -so "$tempfile" "$API?name=$SUBDOMAIN.$DOMAIN."

response="$(aws --output json route53 change-resource-record-sets --hosted-zone-id "$hosted_zone_id" --change-batch "file://$tempfile")"

jq . <<EOF
{
    "request": $(cat "$tempfile"),
    "response": $response
}
EOF