Search code examples
amazon-web-servicesaws-clisnapshotamazon-amiimage-size

AWS CLI command to get the Image size of the AMI in table/text format


I am running this AWS CLI command to get a list of AMI IDs along with their ImageSize but I am unable to list the ImageSize and display it as a separate column.

aws ec2 describe-images --owners self --region us-east-1 --profile prod 
--query 'Images[*].[Name,ImageId,VolumeSize,Description,ImageLocation,OwnerId,Public,State,CreationDate,Platform,RootDeviceType,VirtualizationType,Tags[?Key==`System`]|[0].Value,Tags[?Key==`SubSystem`]|[0].Value,BlockDeviceMappings[]|[].Ebs.VolumeSize]' 
--output text

Can anybody please help me here?so that I can have these sections in my table as shown in the mysampletable picture:

mysampletable


Solution

  • According to the documentation the aws ec2 describe-images CLI command doesn't return an ImageSize. However, it returns BlockDeviceMappings[*].Ebs.VolumeSize, which you already retrieve as part of your query.