Score:1

How to detect AWS EC2 architecture from inside?

al flag

Assuming we have instance running, what can we run on that instance to detect whether it's x86_64 or graviton-based/ARM?

I thought about curl -s http://169.254.169.254/latest/meta-data/... but found nothing useful in this case. Also, it's possible to detect using instance type (e.g. t4g.* vs t3.*) but I'd like to have more straightforward way.

Is there any?

in flag
Could you parse `uname` to determine the architecture? Eg could you treat this question as if it has nothing to do with AWS?
al flag
@jaredready in theory, yes. Just want to make sure it's really reliable way _in AWS_
Score:3
id flag
MLu

Quick and easy check: uname -m

Intel / AMD:

t3a.large:~ $ uname -m
x86_64

Graviton / ARM:

t4g.large:~ $ uname -m
aarch64

Display more details: lscpu

For example for AMD CPU:

t3a.large:~ $ lscpu
Architecture:                    x86_64
CPU op-mode(s):                  32-bit, 64-bit
Byte Order:                      Little Endian
Address sizes:                   48 bits physical, 48 bits virtual
CPU(s):                          2
On-line CPU(s) list:             0,1
Thread(s) per core:              2
Core(s) per socket:              1
Socket(s):                       1
NUMA node(s):                    1
Vendor ID:                       AuthenticAMD
CPU family:                      23
Model name:                      AMD EPYC 7571
CPU MHz:                         2199.880
BogoMIPS:                        4399.76
Hypervisor vendor:               KVM
Virtualization type:             full
L1d cache:                       32 KiB
L1i cache:                       64 KiB
L2 cache:                        512 KiB
L3 cache:                        8 MiB
NUMA node0 CPU(s):               0,1
...

You can also display the output in JSON format for easier consumption in scripts (here for Graviton):

t4g.large:~ $ lscpu -J
{
   "lscpu": [
      {"field":"Architecture:", "data":"aarch64"},
      {"field":"CPU op-mode(s):", "data":"32-bit, 64-bit"},
      {"field":"Byte Order:", "data":"Little Endian"},
      {"field":"CPU(s):", "data":"2"},
      {"field":"On-line CPU(s) list:", "data":"0,1"},
      {"field":"Thread(s) per core:", "data":"1"},
      {"field":"Core(s) per socket:", "data":"2"},
      {"field":"Vendor ID:", "data":"ARM"},
      {"field":"Model name:", "data":"Neoverse-N1"},
      ...
   ]
}

Hope that helps :)

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.