2 個答案
- 最新
- 最多得票
- 最多評論
0
Have you tried .npmignore as mentioned on this Github thread - https://github.com/aws/serverless-application-model/issues/308 - "sam build command uses npm to package up the build folder (for nodejs projects), so you can use .npmignore to tell it which files should be excluded from the build"
0
I have found in my template.yaml file under each resource you can declare a CodeUri - it appears to only build files from this directory. This works well for my use case as I have a seperate lambda layer I use which holds all dependencies needed. I will now just structure my lambdas under seperate directories and share code where needed. Snippet of tamplate.yaml:
listProvisioningTemplates:
Type: AWS::Serverless::Function
Properties:
CodeUri: src/provisioning/listProvisioningTemplates/
Handler: index.handler
Layers:
- !Ref awsCommandsLayer
Runtime: nodejs16.x
Architectures:
- x86_64
MemorySize: 128
Timeout: 100
Description: A Lambda function that returns a static string.
Policies:
# Give Lambda basic execution Permission to the helloFromLambda
- AWSLambdaBasicExecutionRole
#Metadata:
# BuildMethod: makefile
Folder Structure
AWS-SAM-DIR:
-src:
-provisioning:
-listProvisioningTemplates:
index.js
-template.yaml
已回答 2 年前
相關內容
- 已提問 1 年前
- AWS 官方已更新 3 年前
- AWS 官方已更新 2 年前
- AWS 官方已更新 3 年前
- AWS 官方已更新 3 年前