400 Bad Request when retrieving instances using Amazon

Can anyone tell me why I am getting this error?

I get this by pulling instances after connecting to the amazon server.

import boto con = boto.connect_ec2(aws_access_key_id='XXX',aws_secret_access_key='XXX') con.get_all_instances() Traceback (most recent call last): File "getAllinstanc.py", line 7, in <module> reservations = ec2conn.get_all_instances() File "c:\jiva\py26\lib\site-packages\boto-2.3.0-py2.6.egg\boto\ec2\connection.py", line 467, in get_all_instances [('item', Reservation)], verb='POST') File "c:\Jiva\py26\lib\site-packages\boto-2.3.0-py2.6.egg\boto\connection.py", line 896, in get_list raise self.ResponseError(response.status, response.reason, body) boto.exception.EC2ResponseError: EC2ResponseError: 400 Bad Request <?xml version="1.0" encoding="UTF-8"?> <Response><Errors><Error><Code>RequestExpired</Code><Message>Request has expired. Timestamp date is 2012-04-09T06:54:53Z</Message></Error></Errors><RequestID>44 08be18-5d2b-420b-af48-e2cb03</RequestID></Response> 
+6
source share
2 answers

Each request made by boto (or any other AWS client library) is cryptographically signed and has a timestamp associated with it (usually the date header in the request). Timestamps should be close enough, usually within 15 minutes, from Amazon's idea of ​​the current time. If the timestamp is outside of this acceptable window, you will get this error.

So, the short answer is to check the system time on the client machine. This seems inaccurate.

+7
source

There is a good method for checking clock skew described on the Amazon forum .

A type:

 wget -S "https://email.us-east-1.amazonaws.com" 

This returns an error, but includes the remote system time in the Date header. Then compare this with the date results on your system (suppose it's derived from unix).

If your OS is Ubuntu or another version of Debian, you can save the current time by installing the ntp daemon as follows:

 sudo apt-get install ntp 
+2
source

Source: https://habr.com/ru/post/912736/


All Articles