- Newest
- Most votes
- Most comments
I was puzzled to see that all my lambdas had their own dir and inside each dir were ALL the lambdas again.
sam build
command will build each of the Lambda and store the output in .aws-sam/build
. After that, you have a Lambda source, and a built Lambda code.
So I'm worried that means loading one lambda, loads all 12 for th execution of one lambda.
If you deploy those Lambda code to AWS Lambda (e.g., sam deploy
), each Lambda code goes to separate runtime environment, and they cannot even locate each other. Therefore, loading one Lambda function will not make other Lambda being loaded.
Hope it helps.
For my own peace-of-mind, I've created a new Cloud9 environment with 12 dirs, one for each function and the C9 env with all 12 in one dir. There is a corresponding deployed package size difference. So for now, I'm going to put dynamodb read (reads get 1M x more use a day, than puts) lambdas in their own dirs.
This is all new to me, so any insights are appreciated. And thanks again HS for your feedback.
HS, as I just posted the above comment, I saw your latest post. So, in answer to you latest post. WRT the all 12 in one dir, when I post these 12 lambdas and then look at one of them in the Lambda console, there is the dir of the same name of the particular lambda, but there are twelve lambdas files in the 'Code' tab and when I open any one of them I see their code. Plus the package size is about 12 times larger.
Since I'm new to all this, I believe you are right and I'm also right, BUT I'm missing some template.yaml directive that is causing my issue.
One other factor, until I put the dynamodb node modules in a layer, this is what I'd see anytime I tried to look at my deployed code in the Lambda Console > "The deployment package of your Lambda function "sam-att-v1-5-postEventFunction-RJkSwRTCGoPP" is too large to enable inline code editing. However, you can still invoke your function." So only after I introduced layers did I see the lambdas showing up in each other's directories.
So until I get more experience, I'm putting all lambdas that read dynamodb into their own dirs.
Thanks for your support.
Did you specify the
CodeUri
properly? For example, if you store 12 Lambda insrc
, the following will deploy a Lambda function that contains all the 12 Lambda codes.FunctionA: Type: AWS::Serverless::Function Properties: CodeUri: src
Instead, you need to use this.
FunctionA: Type: AWS::Serverless::Function Properties: CodeUri: src/funcA FunctionB: Type: AWS::Serverless::Function Properties: CodeUri: src/funcB
Relevant content
- asked 4 years ago
- Accepted Answerasked 2 years ago
- asked 6 months ago
- asked 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 2 years ago
Thanks for responding. Regarding the first part of your response about 'build'; So the size of the built artifact is the size of just the single function and not the size of all twelve shown in that same dir. So if there are three function being built funcA, funcB, and funcC, and after building it looks like this >
.aws-sam (dir) funcA (dir) funcA.js funcB.js funcC.js funcB (dir) funcA.js funcB.js funcC.js funcC (dir) funcA.js funcB.js funcC.js Each of the three function's size doesn't include the other two func in the dir?
No, it doesn't. This directory tree lies only on your local machine. After you deploy, there is no
.aws-sam
that contains all the artifacts in the Lambda runtime. Instead, it will create 12 Lambda functions and each has the similar directory tree as follows: