forked from pprometey/wireguard_aws
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aws-create-route53-record.sh
27 lines (24 loc) · 1002 Bytes
/
aws-create-route53-record.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash -l
HOSTED_ZONE_ID=$(aws route53 list-hosted-zones-by-name --dns-name $DOMAIN_NAME | jq -r '.HostedZones[0].Id' | cut -d'/' -f3)
WIREGUARD_HOSTNAME="vpn-${AWS_DEFAULT_REGION,,}.${DOMAIN_NAME}"
CHANGE_BATCH=$(jq -n \
--arg name $WIREGUARD_HOSTNAME \
--arg value "$WIREGUARD_IP" \
'{
Comment: "Create an A record for VPN",
Changes: [
{
Action: "UPSERT",
ResourceRecordSet: {
Name: $name,
Type: "A",
TTL: 300,
ResourceRecords: [
{ Value: $value }
]
}
}
]
}')
aws route53 change-resource-record-sets --hosted-zone-id $HOSTED_ZONE_ID --change-batch "$CHANGE_BATCH"
echo "Hostname is: $WIREGUARD_HOSTNAME"