Created
November 28, 2022 05:36
-
-
Save JAlexoid/c2f6b066f47c40974f7072764fbc803c to your computer and use it in GitHub Desktop.
Update Route53 IP with your current external IP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
from requests import get | |
client = boto3.client('route53') | |
ip = get('https://api.ipify.org').text | |
ipv6 = get('https://api64.ipify.org').text | |
HostedZoneId='(HOSTED ZONE ID)' | |
hostname = '(hosyname)' | |
response = client.change_resource_record_sets( | |
ChangeBatch={ | |
'Changes': [ | |
{ | |
'Action': 'UPSERT', | |
'ResourceRecordSet': { | |
'Name': hostname, | |
'ResourceRecords': [ | |
{ | |
'Value': ip, | |
}, | |
], | |
'TTL': 7200, | |
'Type': 'A', | |
},{ | |
'Name': hostname, | |
'ResourceRecords': [ | |
{ | |
'Value': ipv6, | |
}, | |
], | |
'TTL': 7200, | |
'Type': 'AAA', | |
}, | |
}, | |
], | |
'Comment': 'Dynamic IP', | |
}, | |
HostedZoneId=HostedZoneId, | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment