I am trying to test aws lambda function locally and was successful in mocking aws resource like dynamo DB using moto library but when in introduced a component i.e request for invoking third party libaries i got error as connection refused.
requests.exceptions.ConnectionError: Connection refused: GET https://www.google.com/
It is mainly because of moto libraries reponse.py class i.e httpPretty library.
What are the other alternatives we can use to fix these or test lambda function locally having aws resources as well as call to third party libraries.
My lambda function source :
import boto3
import requests
def lambda_handler(event,context):
client=boto3.client('dynamodb')
response = client.put_item(TableName='divyanayan_test',
Item={'id': {'S': 'hello1'}})
r = requests.get('https://www.google.com/')
print(r)
Also did tried with localstack library and deployed the image to docker but it give a url not Could not connect to the endpoint URL: "http://localhost:4569/".
Reference : https://github.com/localstack/localstack