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 and Azure detection is broken #7

Closed shikharbhardwaj closed 3 years ago

shikharbhardwaj commented 3 years ago

Tried to run the detection on a Sagemaker instance, the response keys seem to have changed (case mismatch):

curl http://169.254.169.254/latest/dynamic/instance-identity/document
{
...
  "imageId" : "ami-08xxxxxxxxxxx",
  "instanceId" : "i-00xxxxxxxxxxxx",
...
}

Also, the Azure detection does not check the response code, and thus ends up being falsely detected in this case instead of unknown (since the metadata server does exist at the same IP).

https://github.com/dgzlopes/cloud-detect/blob/0eac0b4ef6480f8b1e054db22e5ee8c641e39422/cloud_detect/providers/azure_provider.py#L33

dgzlopes commented 3 years ago

Hey :)

Good catches, thanks!

I changed the cases on the AWS provider, merged a PR that had a fix for the Azure problem, and created a new release.

Hopefully everything works fine now.