By using AWS re:Post, you agree to the Terms of Use

Get current instance features from within said instance

0

I've been working on some code that would benefit from some level of awareness about the platform on which its running. When it runs on bare metal, several options are available (lshw, hwloc and so on). In EC2 instances, this task is not so straight forward, as they run on virtualization (excluding bare metal instances, evidently). Running 'lshw' for instance, lists the hardware, that not necessarily corresponds with available resources. As an example, running lshw on a t2.micro instance, which has 1 default core available, gives the actual model of the CPU on which it is running, a Intel Xeon with 12 cores. I understand that I am able to fetch instance metadata, find which instance type the code is running on and use AWS CLI and/or EC2 API to get the description of the instance. The issue with that workaround is that it presupposes that the current instance has either the AWS CLI configured with proper credentials or that the user credentials are available as environment variables to the system, which may or may not be true. I've been looking for a more general solution, that could work, at least, on the most popular Linux distros, such as querying the system about actually available resources (cpus cores, threads, memory, cache and accelerators) but have so far failed to find a suitable solution. Is this possible? Or in this circumstances such query is not a possibility?

1 Answers
1

I think your concern about credential availability is easily solved by assigning an Instance Profile (IAM Role) to the instance.

profile picture
EXPERT
answered 2 months ago
  • I see, but I believe that is not the optimal solution. Something that I failed to make clear on my original post is that the code on which I'm currently working on is intended to, eventually, become part of an open source project. This implies that third parties, unaware of the code inner workings, should be able to get it running out of the box with little to no setup required. I understand that are several ways to assure that credentials are available, but, I was hopping on finding a way to get such information, without relying on the user to correctly follow such instructions.

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