aws-samples / aws-samples/sample-connected-mobility-solution-on-aws
APIHandler of Chalice in Simulator is not importing 3rd party dependencies
- Dominant language
- Python
- Stars
- 24
- Forks
- 15
- PR merge metrics
- No merged PRs in 30d
Description
#### Describe the bug
APIHandler of Chalice in Simulator is not importing 3rd party dependencies
#### To Reproduce
Deploy the modules in order with the make modulename-deploy command and deploy cms_vehicle_simulator
#### Expected behavior
Simulator module works correctly. If there is a bug, the Simulator web app does not work with CORS and 502 errors.
#### Please complete the following information about the solution
- [ v2.1.1 ] Version: [e.g. v1.0.0]
- [ ap-northeast-1 ] Region: [e.g. us-east-1]
- [ No ] Was the solution modified from the version published on this repository?
- [ x ] If the answer to the previous question was yes, are the changes available on GitHub?
- [ x ] Have you checked your [service quotas](https://docs.aws.amazon.com/general/latest/gr/aws_service_limits.html)
for the sevices this solution uses?
- [ Yes ] Were there any errors in the CloudWatch Logs?
#### Screenshots
Not applicable, see Additional context for details.
#### Additional context
This Issue is related to Issue #56.
When deploying a simulator module, the Lambda, which is an APIHandler, was outputting an import error for a third party module.
The target Lambda is cms-app-cms-vehicle-simulator-APIHandler-${hash}. The error is as follows.
```
[ERROR] Runtime.ImportModuleError: Unable to import module 'app': No module named 'arrow'
Traceback (most recent call last):
```
Due to the above error, APIGateway returns error, which caused the CORS to occur, and if the CORS was ignored, the 502 error would have been observed.
After investigating the cause, I found that there is no implementation to resolve package dependencies for Chalice used in this module.
To use third-party modules in Chalice, we need to place requirement.txt in the project root or specify the Lambda Layer when building Chalice.
I think None of these methods are implemented.
As a trial, we implemented an implementation that explicitly passes the Lambda Layer to Chalice using cms_common, which is used in this project.
After deploying this modification, APIHandler recognized the third-party module and worked correctly.
Can you please fix this issue? I will create a pull request if necessary.
Contributor guide
Assessment
This issue has not been assessed yet.