import os

import boto3


def get_dynamodb_client():
    sam_local = os.getenv('AWS_SAM_LOCAL')

    if os.getenv('AWS_LAMBDA_FUNCTION_NAME') and not sam_local:
        return boto3.client('dynamodb')

    url = 'host.docker.internal' if sam_local else 'localhost'
    return boto3.client('dynamodb', endpoint_url=f'http://{url}:8000')


dynamodb_client = get_dynamodb_client()
idp_client = boto3.client('cognito-idp')
