I have an AWS Lambda function that needs to connect to an internal website which is behind a proxy. In my code I am doing the following:
from botocore.vendored import requests
https_proxy = "https://myproxy:myport"
proxyDict = {
"https" : https_proxy
}
request.get("https://myurl.json", proxies=proxyDict)
Running this gives me the following error message:
HTTPSConnectionPool(host='myproxyhost', port=443): Max retries exceeded with url: myurl.json (Caused by ProxyError('Cannot connect to proxy.', gaierror(-2, 'Name or service not known')))
I have tried replacing the proxied URL with google.com to confirm I can connect to other sites (without the proxy).
It looks like the address space that Lambda runs it gets blocked by the proxy.
Is there something else I need to set with requests and lambda to get this to work?