Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWS IMDSv2 not supported #27

Closed
arossert opened this issue Dec 27, 2023 · 6 comments
Closed

AWS IMDSv2 not supported #27

arossert opened this issue Dec 27, 2023 · 6 comments

Comments

@arossert
Copy link
Contributor

I have an issue that I'm getting 'unknown' even when on an AWS instance (windows).
It seems that the API for http://169.254.169.254/latest/dynamic/instance-identity/document is returning a 401 status code.

According to the documentation we need first to acquire a token and then to the call instance-metadata-returns

You can look at this project to see how it is implemented in here https://pypi.org/project/ec2-metadata/

@arossert
Copy link
Contributor Author

There are also some alternatives that I can think of, like looking to see if one of these directories exists

  • C:\Program Files\Amazon
  • C:\ProgramData\Amazon

Also according to this https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/identify_ec2_instances.html, we can also use wmic to check if the UUID starts with EC2

@kshivakumar
Copy link
Collaborator

@arossert I think this package was never tested on Window VMs. Even the CI only covers Ubuntu.
It's highly probable it fails with other vendors as well.
I think Windows was never in the scope of this package(or the go package Satellite where it's inspired from). @dgzlopes can you confirm?

@arossert
Copy link
Contributor Author

Since this lib is using the metadata API I will assume this can also happen in Linux if only V2 is supported.

@arossert
Copy link
Contributor Author

arossert commented Jan 27, 2024

@dgzlopes @kshivakumar Any suggestions on this issue? I'm using it to detect if running on cloud for multiple OS (Windows + Linux).

Also I have a Linux instance that does return 401 error without the authentication token

I can give some suggestions:

  • Add support in V2.
  • Count 401 error as "success" since other cloud providers will probably not return 401 on this API call.
  • Add files detection for Windows locations.

I'm willing to create a PR on any of these suggestions

If this module is only intended for Linux, it should be in the project details.

@arossert
Copy link
Contributor Author

I created a pull request, can you consider adding this?

@kshivakumar
Copy link
Collaborator

Resolved by #28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants