Testing the Amazon Time Sync NTP Service with Python

I’d just read a new article describing Amazon’s new publicly available NTP service (Amazon Time Sync). You can read the article here:

https://aws.amazon.com/about-aws/whats-new/2022/11/amazon-time-sync-internet-public-ntp-service/

I thought I’d give it a try with a Python script.

I first needed to add ntplib to my local Python libraries:

pip install ntplib

Then, I put together this short script (amazontime.py):

import ntplib
from time import ctime
ntp = ntplib.NTPClient()
response = ntp.request("time.aws.com")
print(ctime(response.tx_time))

Here’s the invocation and the output:

amazontime.py
Fri Nov 11 09:08:46 2022