dgzlopes / cloud-detect

Module that determines a host's cloud provider.
https://pypi.org/project/cloud-detect/
MIT License
35 stars 13 forks source link

AWS instance not recognized #15

Closed arossert closed 2 years ago

arossert commented 2 years ago

I have an older AWS instance that is not detected, after investigating I noticed 2 issues

  1. /sys/class/dmi/id/product_version file is empty
  2. http://169.254.169.254/latest/dynamic/instance-identity/document call returns Content-Type: text/plain, this cause the response.json() function to fail
    WARNING:cloud_detect.providers.aws_provider:0, message='Attempt to decode JSON with unexpected mimetype: text/plain', url=URL('http://169.254.169.254/latest/dynamic/instance-identity/document')

Will you accept a PR to ignore the content-type header? response.json(content_type=None)

Also maybe the file flow can be revisited, do we have to look at the file content? isn't it good enough if it exists?

kshivakumar commented 2 years ago

@arossert Can you elaborate "older AWS instance"? What exactly is old?

arossert commented 2 years ago

It was created at Sun Oct 27 2019 11:00:59 GMT+0200 (Israel Standard Time) (over 2 years)

arossert commented 2 years ago

@kshivakumar @dgzlopes I did some digging on my instance and discovered that the information exists in /sys/class/dmi/id/bios_vendor

[root@centos]# cat /sys/class/dmi/id/bios_vendor
Amazon EC2

But it does not exist in this file on other (newer) instances, so I can just assume that the metadata API was changed over the years and the same for the content of the dmi files.

I will create a PR

arossert commented 2 years ago

Resolved by #17