AWS
[AWS] 파이썬 boto3로 전체 EC2 리스트 불러오기
Always-Try
2022. 2. 11. 01:54
def get_instance_name():
try:
response = ec2.describe_instances()
for reservation in response['Reservations']:
for instance in reservation['Instances']:
print("Instance: " + instance['InstanceId'])
for securityGroup in instance['SecurityGroups']:
print("SG ID: {}, Name: {}".format(securityGroup['GroupId'], securityGroup['GroupName']))
except Exception as e:
print('get_instance_error', e)
pass