feat: added caching to aws region query

This commit is contained in:
KenF
2026-01-23 10:23:45 +08:00
parent c047662f78
commit a39c39a636
18 changed files with 91 additions and 79 deletions
+2 -5
View File
@@ -10,11 +10,8 @@ import boto3
import concurrent.futures
from openpyxl import load_workbook
from openpyxl.worksheet.worksheet import Worksheet
import projectlib.aws
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 getResources(region_name: str) -> list[list[str | int]]:
return_data = []
@@ -34,7 +31,7 @@ def main() -> None:
ws.append(["FunctionName","Runtime","Architectures","region"])
with concurrent.futures.ThreadPoolExecutor(max_workers=8) as executor:
results = executor.map(getResources, getRegions())
results = executor.map(getResources, projectlib.aws.getRegions())
for region_rows in results:
# append to worksheet only if resoruces are found in the region
if region_rows: