peterlandis
peterlandis

Reputation: 835

AWS - how to find the total size of a lambda function that uses layers

How can you find the total size of a lambda function that uses your own layers including shared layers? There doesn't appear to a single place where you can find the total size of your lambda function that uses all the layers.

Lambda deployment package with all layers unzipped should not be more than 250 MB.

I want to avoid having to download each lambda layer and I can't find if you use a shared aws layer like numpy that aws provides on how to find the size. Would be nice if in your lambda function it had a total size of all packages used in MB (idea....AWS...please)!

Upvotes: 2

Views: 6421

Answers (1)

Shreyas Gaonkar
Shreyas Gaonkar

Reputation: 283

You can use the get-function call to retrieve CodeSize and check to see if there are any layers added to the function. If so, iterate them over to get their code size. The output section of the above doc is not updated. Here's a snippet of the Layers output of the same command:

...
 "CodeSize": 284,
 "Layers": [
            {
                "Arn": "arn:aws:lambda:us-west-2:XXXXXXXXXXXX:layer:PandasNumpyAndOtherGoodies:1",
                "CodeSize": 70877201
            }
        ]
...

I am on CLI version: aws-cli/1.17.9 Python/3.7.3 Windows/10 botocore/1.14.9

Shameless plug: I wrote a python script for Lambda to do this here

Upvotes: -3

Related Questions