This commit is contained in:
2025-10-03 19:31:41 -03:00
parent 48ed8d8345
commit 5ae2128dee
29 changed files with 996 additions and 168 deletions

View File

@@ -8,14 +8,13 @@ if TYPE_CHECKING:
else:
DynamoDBClient = object
AWS_SAM_LOCAL = os.getenv('AWS_SAM_LOCAL')
def get_dynamodb_client() -> DynamoDBClient:
if not AWS_SAM_LOCAL:
if os.getenv('AWS_LAMBDA_FUNCTION_NAME'):
return boto3.client('dynamodb')
host = 'host.docker.internal' if AWS_SAM_LOCAL else '127.0.0.1'
# Use the Docker network address when running in a container
host = 'host.docker.internal' if os.getenv('AWS_SAM_LOCAL') else '127.0.0.1'
return boto3.client('dynamodb', endpoint_url=f'http://{host}:8000')