Description
Description:
Up to version v1.12.0, I was able to test my API Gateway REST API using sam local start-api
with a Lambda built on top of https://github.com/awslabs/aws-lambda-rust-runtime. However, this functionality stopped working in v1.13.0 due to the missing lambda-runtime-invoked-function-arn
header that the runtime expects:
2020-12-04 17:54:54,881 | Found one Lambda function with name 'ApiFunction'
2020-12-04 17:54:54,881 | Invoking ignored (provided)
2020-12-04 17:54:54,881 | Environment variables overrides data is standard format
2020-12-04 17:54:54,881 | Loading AWS credentials from session with profile 'None'
2020-12-04 17:54:54,896 | Resolving code path. Cwd=/Users/daramos/...[redacted], CodeUri=.aws-sam/build-backend/ApiFunction
2020-12-04 17:54:54,897 | Resolved absolute path to code is /Users/daramos/...[redacted].../.aws-sam/build-backend/ApiFunction
2020-12-04 17:54:54,897 | Code /Users/daramos/...[redacted].../.aws-sam/build-backend/ApiFunction is not a zip/jar file
2020-12-04 17:54:54,940 | Skip pulling image and use local one: amazon/aws-sam-cli-emulation-image-provided:rapid-1.13.0.
2020-12-04 17:54:54,940 | Mounting /Users/daramos/Documents/Projects/...[redacted].../.aws-sam/build-backend/ApiFunction as /var/task:ro,delegated inside runtime container
2020-12-04 17:54:55,581 | Starting a timer for 3 seconds for function 'ApiFunction'
START RequestId: 5d85e30d-cda5-47dc-a1a6-4ed2ed87268c Version: $LATEST
thread 'main' panicked at 'no entry found for key "lambda-runtime-invoked-function-arn"', /Users/daramos/.cargo/git/checkouts/aws-lambda-rust-runtime-7c865cce90132439/13aa8f0/lambda/src/types.rs:131:35
The code runs fine on production AWS Lambda, so I believe this is a bug in the SAM CLI's local emulation, not in the Rust runtime. For reference, the runtime expects several headers to be provided by Lambda:
https://github.com/awslabs/aws-lambda-rust-runtime/blob/13aa8f01813e6949ca91aedafb286591fdf32217/lambda/src/types.rs#L123-L139
It looks like aws/aws-sam-cli#2425 may have introduced this regression (cc @sriram-mv). The code that previously set these headers was removed in that PR:
https://github.com/aws/aws-sam-cli/blob/559e4a564ba37906f2081c0de415b39bc9b2c3c1/samcli/local/rapid/init.go#L482-L486
Steps to reproduce:
Use sam local start-api
to test a REST API locally. In my case, using AWS Labs's Rust runtime.
Observed result:
Lambda function panics due to missing headers (the same Lambda works fine on AWS).
Expected result:
Lambda should execute without error.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
- OS: Mac OS 10.15.7
sam --version
: 1.13.0 (also tested on 1.13.2 and latestdevelop
HEAD).
Add --debug flag to command you are running