[server]: Add default AWS_DEFAULT_REGION value if not set

This commit is contained in:
2025-03-10 00:07:15 +00:00
parent c6b04b6525
commit e15a3acd67
4 changed files with 6 additions and 2 deletions

View File

@ -12,6 +12,7 @@ from concurrent.futures import ThreadPoolExecutor
session = requests.Session()
# Setup DynamoDB client for Lambda
os.environ.setdefault('AWS_DEFAULT_REGION', 'us-east-1')
dynamodb = boto3.resource("dynamodb")
table_name = os.environ.get("DYNAMODB_TABLE", "permanent_data")
table = dynamodb.Table(table_name)
@ -208,4 +209,4 @@ if __name__ == "__main__":
for future in futures:
data.extend(future.result())
print(json.dumps(data))
print(json.dumps(data))

View File

@ -3,6 +3,7 @@ import os
import boto3
from boto3.dynamodb.conditions import Key, Attr
os.environ.setdefault('AWS_DEFAULT_REGION', 'us-east-1')
dynamodb = boto3.resource('dynamodb')
def lambda_handler(event, context):

View File

@ -3,6 +3,7 @@ import json
import os
from boto3.dynamodb.conditions import Key, Attr
os.environ.setdefault('AWS_DEFAULT_REGION', 'us-east-1')
dynamodb = boto3.resource('dynamodb')
gsi_name = "objectType-index"

View File

@ -11,6 +11,7 @@ from concurrent.futures import ThreadPoolExecutor
session = requests.Session()
# Setup DynamoDB client
os.environ.setdefault('AWS_DEFAULT_REGION', 'us-east-1')
dynamodb = boto3.resource("dynamodb")
table_name = os.environ.get("DYNAMODB_TABLE", "transient_data")
table = dynamodb.Table(table_name)
@ -224,4 +225,4 @@ if __name__ == "__main__":
for future in futures:
data.extend(future.result())
print(json.dumps(data))
print(json.dumps(data))