There's no immedialy obvious way to determine which block device is definitely an AWS ephemeral storage device, so this quick snippet will grab it.
No error checking, so if you don't actually have an ephemeral storage device it will return the string "/dev/".
EPHEMERAL_STORAGE=/dev/$(lsblk -o +MODEL |grep "EC2 NVMe Instance Storage" | sed "s/ .*//")
# Get ephemereral storage device by block model data:
EPHEMERAL_STORAGE=/dev/$(\
lsblk -o +MODEL |\
grep "EC2 NVMe Instance Storage" |\
sed "s/ .*//" \
)
Licence: do whatever, no warranty, as-is. If your org has a strict OSS policy, then it's MIT licenced.