I am trying to follow step 1 but getting this os.environ error. Any help would be greatly appreciated.
File "/usr/local/lib/python3.8/runpy.py", line 194, in run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/local/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.8/site-packages/awslambdaric/main.py", line 21, in
main(sys.argv)
File "/usr/local/lib/python3.8/site-packages/awslambdaric/main.py", line 14, in main
lambda_runtime_api_addr = os.environ["AWS_LAMBDA_RUNTIME_API"]
File "/usr/local/lib/python3.8/os.py", line 675, in __getitem_
raise KeyError(key) from None
KeyError: 'AWS_LAMBDA_RUNTIME_API'
I guess you're trying to build lambda image from alternative base image but I recommend to use image base from AWS such as public.ecr.aws/lambda/python:3.8 or amazon/aws-lambda-python:3.8
For your issue, you're missing setting ENV AWS_LAMBDA_RUNTIME_API=, this variable env must be defined but you will still get following error after that
File "/function/awslambdaric/lambda_runtime_client.py", line 76, in wait_next_invocation
response_body, headers = runtime_client.next()
RuntimeError: Failed to get next
you should use aws-lambda-rie (emulator) instead of aws-lambda-ric - docs.aws.amazon.com/lambda/latest/.... I believe that environment variable is set by AWS, so if it's not present that script will execute the emulator. This is an example
I am trying to follow step 1 but getting this os.environ error. Any help would be greatly appreciated.
File "/usr/local/lib/python3.8/runpy.py", line 194, in run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/local/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.8/site-packages/awslambdaric/main.py", line 21, in
main(sys.argv)
File "/usr/local/lib/python3.8/site-packages/awslambdaric/main.py", line 14, in main
lambda_runtime_api_addr = os.environ["AWS_LAMBDA_RUNTIME_API"]
File "/usr/local/lib/python3.8/os.py", line 675, in __getitem_
raise KeyError(key) from None
KeyError: 'AWS_LAMBDA_RUNTIME_API'
Hi Jason,
I guess you're trying to build lambda image from alternative base image but I recommend to use image base from AWS such as
public.ecr.aws/lambda/python:3.8
oramazon/aws-lambda-python:3.8
For your issue, you're missing setting
ENV AWS_LAMBDA_RUNTIME_API=
, this variable env must be defined but you will still get following error after thatyou should use aws-lambda-rie (emulator) instead of aws-lambda-ric - docs.aws.amazon.com/lambda/latest/.... I believe that environment variable is set by AWS, so if it's not present that script will execute the emulator. This is an example
entry_script.sh
Dockerfile