I've been using logic to specify disk size when launching new instances. However, the problem is that it requires knowing DeviceName
which depends on instance type. It's usually /dev/sda1
but on p3dn.24xlarge
instances, the default disk comes up /dev/xvda
device instead, so my instance ends up with 2 volumes:
/dev/xvda 8 gp2 vol-06402d0bcb07d3b96
/dev/sda1 500 gp2 vol-0e2593027d73fbc52
I could hardwire p3dn as special case but not sure if this is likely to break in the future, any suggestions of a better way of doing this?
Code
assert disk_size > 0
ebs = {
'VolumeSize': disk_size,
'VolumeType': 'gp2',
}
args['BlockDeviceMappings'] = [{
'DeviceName': '/dev/sda1',
'Ebs': ebs
}]
instances = ec2.create_instances(**args)