Skip to content

Commit 22fefb8

Browse files
committed
instance details to list
1 parent 7c1bc37 commit 22fefb8

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/python
2+
3+
import boto3
4+
import csv
5+
from pprint import pprint
6+
7+
8+
aws_mgmt_console = boto3.session.Session(profile_name="default")
9+
ec2_mgmt_console = aws_mgmt_console.client(service_name="ec2", region_name="us-east-1")
10+
11+
volume_response=ec2_mgmt_console.describe_volumes()['Volumes']
12+
13+
attachments=[]
14+
volume_instance_infos=[]
15+
for each_item in volume_response:
16+
attachments.append(each_item['Attachments'])
17+
18+
for each_attachment in attachments:
19+
for each_item in each_attachment:
20+
volume_instance_infos.append(each_item['InstanceId'])
21+
volume_instance_infos.append(each_item['VolumeId'])
22+
volume_instance_infos.append(each_item['State'])
23+
volume_instance_infos.append(each_item['Device'])
24+
25+
26+
27+
28+
29+
30+
# Get list of all volumes
31+
#for each_volume in volume_response:
32+
# print(each_volume['VolumeId'],each_volume['Size'],each_volume['State'],each_volume['VolumeType'],each_volume['AvailabilityZone'])
33+
34+

0 commit comments

Comments
 (0)