latest-ami
latest-ami copied to clipboard
Exception handling if empty
This works for me locally. I pulled and changed Owners=['amazon'] to my ownerid and it returned an empty list.
This caused the following error:
[mash@localhost latest-ami]$ python latest-ami.py eu-central-1
[]
Traceback (most recent call last):
File "latest-ami.py", line 34, in <module>
print(source_image['ImageId'])
TypeError: 'NoneType' object has no attribute '__getitem__'
So I added a if check, if the list is populated then source_image, otherwise, trow message and end cleanly.