-
-
Save OksanaH/256ab38d178bf3865fe9d95eaeca6657 to your computer and use it in GitHub Desktop.
lambda.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def imagesUsedInEC2s(region): | |
print(f'Checking instances that are not in ASGs in region {region}...') | |
amis = [] | |
ec2_resource = boto3.resource('ec2', region_name = region) | |
instances = ec2_resource.instances.filter( | |
Filters= | |
[ | |
{ | |
'Name': 'instance-state-name', | |
'Values': [ 'running' ] | |
} | |
]) | |
for instance in list(instances): | |
amis.append(instance.image_id) | |
return amis |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment