I've been trying to read a config json in my python AWS lambda package (I don't want to use the config in the console as I generate it with my code and it has odd properties), I zip it with everything else. I get the following error:
{"errorMessage": "unknown url type: '/var/taskconstants/aws.json'", "errorType": "ValueError", "stackTrace": [ " File \"/var/lang/lib/python3.7/imp.py\", line 234, in load_module\n return load_source(name, filename, file)\n", " File \"/var/lang/lib/python3.7/imp.py\", line 171, in load_source\n module = _load(spec)\n", " File \"\", line 696, in _load\n", " File \"\", line 677, in _load_unlocked\n", " File \"\", line 728, in exec_module\n", " File \"\", line 219, in _call_with_frames_removed\n", " File \"/var/task/lambda_function.py\", line 13, in \n AWS_JSON = json.load(urllib.request.urlopen(os.getcwd()+\"constants/aws.json\"))\n", " File \"/var/lang/lib/python3.7/urllib/request.py\", line 222, in urlopen\n return opener.open(url, data, timeout)\n", " File \"/var/lang/lib/python3.7/urllib/request.py\", line 510, in open\n req = Request(fullurl, data)\n", " File \"/var/lang/lib/python3.7/urllib/request.py\", line 328, in init\n self.full_url = url\n", " File \"/var/lang/lib/python3.7/urllib/request.py\", line 354, in full_url\n self._parse()\n", " File \"/var/lang/lib/python3.7/urllib/request.py\", line 383, in _parse\n raise ValueError(\"unknown url type: %r\" % self.full_url)\n" ] }
I've tried the solution from here and I got the above. The same thing happens with our without, it's just a different url to get an error on. Here's the relevant code
import json, random, boto3, os
import urllib.request
# Loading constants from aws json
AWS_JSON = json.load(urllib.request.urlopen(os.getcwd()+"constants/aws.json"))
What am I missing?