Do you ever wonder what all the attached volumes add up to, for a given AWS EC2 instance? You can find that out with a single command via AWS CLI. You can also parameterize the command to add in to a loop and run for each EC2.
#set to your AWS profile pointing to the required account.
#This can be populated dynamically in a loop.
storage_size=$(aws ec2 describe-volumes \
--profile $aws_profile \
--filter Name=attachment.instance-id,Values=$instance_id \
--query 'Volumes[*].[Size]' --output text | paste -s -d"+"|bc)
storage_size will hold the sum of all the attached volumes in GB. The
describe-volumes command returns one row per attache volume with size in GB. Multiple rows need to be rolled up into a single line with
paste and then added by