问题
I am writing a serverless app by using SAM. I created a config folder to keep some table information and some other info. then I load it in my app.js.
when I deploy the app.js locally by using SAM deploy, I observe that the config folder will not include. would you mind advise me how to add config folder in final build folder in .aws-sam\build folder?
my Yaml file
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Sample SAM Template for test
Globals:
Function:
Timeout: 120
Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: hello-world/
Handler: app.lambdaHandler
Runtime: nodejs10.x
Events:
HelloWorld:
Type: Api
Properties:
Path: /hello
Method: get
Also when I run the project in debug mode I am getting this error:
{
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module '../config/config.js'"
}
I load the js file as below:
"use strict";
let response;
const AWS = require('aws-sdk');
const config = require('../config/config.js');
来源:https://stackoverflow.com/questions/58502648/how-to-add-a-custom-folder-and-file-via-yaml-in-serverless-app