Skip to content

Instantly share code, notes, and snippets.

@JAlexoid
Created November 28, 2022 05:36
Show Gist options
  • Save JAlexoid/c2f6b066f47c40974f7072764fbc803c to your computer and use it in GitHub Desktop.
Save JAlexoid/c2f6b066f47c40974f7072764fbc803c to your computer and use it in GitHub Desktop.
Update Route53 IP with your current external IP
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