- Newest
- Most votes
- Most comments
I understand that you are trying to implement CRUD serverless application written in NodeJS/Typescript. However, you have some queries with the sam project structure. Kindly note that the folder location that you are specifying for a function in 'CodeUri' property should have package.json in case you are using any dependencies in your function code.
A template snippet with a function resource should have an individual folder structure as referred below -
TestFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: function1/
Runtime: nodejs18.x
Handler: index.lambda_handler
|--function1/
|---index.js
|---package.json
Any dependencies you want to use along with this function, you need to add that either in package.json or ship the js files/folders within 'function1' folder so that they are included in the deployment package. For common dependencies that need to be shared across multiple functions, it is better to package the module as layer archive file. You may refer to this pattern which shows how you can package an archive file as a layer for your function. Though the example is in python, you can refer to our public documentation to follow the steps to create one for nodejs counterpart.
Should you have any additional queries or you are seeking a guidance from one of our support engineers, please do not hesitate to reach out over a support case.
Relevant content
- asked 2 years ago
- AWS OFFICIALUpdated 9 months ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 3 years ago