You have multiple AWS account, one for Development, another for Testing and another for Production. You have provisioned EC2 servers in each of these accounts in multiple regions depending on your application deployment.
Now you want to list all the instances in all regions across all accounts using awscli. Also you want to export this data into csv format so that you can view it in excel. You want to list following data for each EC2-
There is no way to get this data exported from AWS console.
You can export this data into csv file which can be viewed in excel. You have to configure profile to access each of these AWS accounts. Then use the Profile names in the script provided.
Here is this script, I have 3 profiles configured- 1 each by name dev, test and prod. Using these profile name awscli is able to access EC2 instance data. Also it finds all the regions available in that AWS account and then fetches instances information with in that region. Then this data is saved in csv file in path ec2/<profilename>/<regionname>.csv
This way separate file for each region is created in the AWS account folder.
The output in folder will be like