-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist_s3_ec2_iam_client.py
41 lines (30 loc) · 1.07 KB
/
list_s3_ec2_iam_client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# George Milliken
# 02-15-2021
# Entered following examples in Udemy Class
# "AWS Automation of Boto3 of Python and AWS Lambda"
# https://www.udemy.com/course/aws-automation-with-boto3-of-python-and-lambda-functions/learn/lecture/14614056#overview
# No copyright claimed, no license claimed or granted
#
# uses client access
#
import boto3
aws_mag_con=boto3.session.Session(profile_name="developer")
iam_con_cli=aws_mag_con.client(service_name="iam")
ec2_con_cli=aws_mag_con.client(service_name="ec2")
s3_con_cli=aws_mag_con.client(service_name="s3")
# List all iam users using client object
response = iam_con_cli.list_users()
for each_user in response['Users']:
print(each_user['UserName'])
ec2_response=ec2_con_cli.describe_instances()
#print(ec2_response)
for each_instance in ec2_response['Reservations']:
for each_item in each_instance['Instances']:
print('---------')
print(each_item['InstanceId'])
print('---------')
s3_response=s3_con_cli.list_buckets()
for s3_bucket in s3_response['Buckets']:
print('*************')
print(s3_bucket['Name'])
print('*************')