34 lines
1022 B
Python
Executable File
34 lines
1022 B
Python
Executable File
#!/usr/bin/env python3
|
|
r"""
|
|
Documentation
|
|
|
|
License: This program is released under the MIT License
|
|
"""
|
|
|
|
# Imports
|
|
import boto3
|
|
import concurrent.futures
|
|
|
|
|
|
def getRegions(all_regions=False):
|
|
ec2 = boto3.client('ec2')
|
|
response = ec2.describe_regions(AllRegions=all_regions)
|
|
return [region['RegionName'] for region in response['Regions']]
|
|
|
|
def printResources(region_name: str):
|
|
client = boto3.client('lambda', region_name=region_name)
|
|
response = client.list_functions()
|
|
for i in response['Functions']:
|
|
print(f"{i['FunctionName']}, {i['Runtime']}, {i['Architectures'][0]}, {region_name}")
|
|
|
|
# Main function
|
|
def main() -> None:
|
|
print("FunctionName,Runtime,Architectures,region")
|
|
with concurrent.futures.ProcessPoolExecutor(max_workers=6) as executor:
|
|
futures = [executor.submit(printResources, region_name=r) for r in getRegions()]
|
|
results = [future.result() for future in concurrent.futures.wait(futures).done]
|
|
|
|
# Call main function
|
|
if __name__ == '__main__':
|
|
main()
|