Boto3 Bug in response when creating a hosted zone in route53 with Python

0

I had boto3 1.16.7 libraries and went to 1.23.24, to see if this could still be replicated.

When I run the following code to create a hosted zone, I get a response that contains a call to the the datetime library as a value for the SubmittedAt key in the json/dictionary: 'SubmittedAt': datetime.datetime(2021, 12, 17, 16, 40, 21, 154000, tzinfo=tzutc()). This had caused some problems when I was trying to extract data, but I have worked around that.

When I run this with the aws cli (aws route53 create-hosted-zone --name contoso.com --caller-reference 20211217), I get an expected value: "SubmittedAt": "2021-12-18T01:40:44.781000+00:00"

Am I doing something wrong or is this a bug?

Code:

import boto3
import datetime
 
awsProfile = 'default'
awsRegion = 'us-east-1'
hostedZoneName = 'dev.contoso.com'
timeStamp = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
 
boto3.setup_default_session(profile_name=awsProfile, region_name=awsRegion)
 
client = boto3.client('route53')
 
hostedZoneParams = {
    'Name': hostedZoneName,
    'CallerReference': timeStamp,
}
 
response = client.create_hosted_zone(**hostedZoneParams)
print(response)

Output:

{'ResponseMetadata': {'RequestId': 'redacted', 'HTTPStatusCode': 201, 'HTTPHeaders': {'x-amzn-requestid': 'redacted', 'location': 'https://route53.amazonaws.com/2013-04-01/hostedzone/redacted', 'content-type': 'text/xml', 'content-length': '762', 'date': 'Fri, 17 Dec 2021 16:40:20 GMT'}, 'RetryAttempts': 0}, 'Location': 'https://route53.amazonaws.com/2013-04-01/hostedzone/redacted', 'HostedZone': {'Id': '/hostedzone/redacted', 'Name': 'dev.contoso.com.', 'CallerReference': '20211217114020', 'Config': {'PrivateZone': False}, 'ResourceRecordSetCount': 2}, 'ChangeInfo': {'Id': '/change/redacted', 'Status': 'PENDING', 'SubmittedAt': datetime.datetime(2021, 12, 17, 16, 40, 21, 154000, tzinfo=tzutc())}, 'DelegationSet': {'NameServers': ['ns-144.awsdns-18.com', 'ns-1956.awsdns-52.co.uk', 'ns-550.awsdns-04.net', 'ns-1307.awsdns-35.org']}}

asked 2 years ago247 views
1 Answer
0

This is the expected behavior as per the document, SubmittedAt will be datetime object. Route53 - Boto3

SubmittedAt (datetime) --

The date and time that the change request was submitted in ISO 8601 format and Coordinated Universal Time (UTC). For example, the value 2017-03-27T17:48:16.751Z represents March 27, 2017 at 17:48:16.751 UTC.

If you can share what problems you ran into because of that I might be able to figure out a solution for that.

answered 2 years ago
  • Thanks, I guess my question was not clear, I understand that that format is correct, but if you look at the second code block, you can see I am not getting a UTC time value. I am getting python code in the response from AWS: 'SubmittedAt': datetime.datetime(2021, 12, 17, 16, 40, 21, 154000, tzinfo=tzutc())} Unless you are telling me that datetime.datetime and tzinfo=tzutc() is part of ISO 8601 format.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions