Here's my problem - I'm using Hashicorp terraform to programmatically set up an Amazon c5 EC2 instance that has a couple of attached EBS drives. The c5 instances use nvme and end up remapping the names I assign in terraform (e.g. /dev/sdf) to nvme names (e.g. /dev/nvme1n1). The problem is that the mapping doesn't appear to be consistent. Upon reboot the drives sometimes get mapped in a different order. This means that my /etc/fstab which specifies /dev/nvme1n1 gets one drive one time and a different drive the next.
One solution to this is to use the UUID in the /etc/fstab file. This works fine, and I can get the UUID using ls -al /dev/disk/by-uuid/
, however htis is a very clumsy process to automate.
Is there a way to just get the UUID directly from terraform so that I can put that in the fstab directly rather than having to do it by hand after the fact (or write a special script to automate this)?