Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to download the contents of a public Lambda layer from AWS given the ARN?

I want to download the public arn for a more compact version of spacy from this GitHub repository.

"arn:aws:lambda:us-west-2:113088814899:layer:Klayers-python37-spacy:27"

How can I achieve this?

like image 262
coderboi Avatar asked Jan 01 '23 00:01

coderboi


1 Answers

You can get it from a Arn using the get-layer-version-by-arn function in the CLI.

You can run the below command to get the source of the Lambda layer you requested.

aws lambda get-layer-version-by-arn \
    --arn "arn:aws:lambda:us-west-2:113088814899:layer:Klayers-python37-spacy:27"

An example of the response you will receive is below

{
    "LayerVersionArn": "arn:aws:lambda:us-west-2:123456789012:layer:AWSLambda-Python37-SciPy1x:2",
    "Description": "AWS Lambda SciPy layer for Python 3.7 (scipy-1.1.0, numpy-1.15.4) https://github.com/scipy/scipy/releases/tag/v1.1.0 https://github.com/numpy/numpy/releases/tag/v1.15.4",
    "CreatedDate": "2018-11-12T10:09:38.398+0000",
    "LayerArn": "arn:aws:lambda:us-west-2:123456789012:layer:AWSLambda-Python37-SciPy1x",
    "Content": {
        "CodeSize": 41784542,
        "CodeSha256": "GGmv8ocUw4cly0T8HL0Vx/f5V4RmSCGNjDIslY4VskM=",
        "Location": "https://awslambda-us-west-2-layers.s3.us-west-2.amazonaws.com/snapshots/123456789012/..."
    },
    "Version": 2,
    "CompatibleRuntimes": [
        "python3.7"
    ],
    "LicenseInfo": "SciPy: https://github.com/scipy/scipy/blob/master/LICENSE.txt, NumPy: https://github.com/numpy/numpy/blob/master/LICENSE.txt"
}

Once you run this you will get a response returned with a key of "Content", containing a subkey of "Location" which references the S3 path to download the layer contents.

You can download from this path, you will then need to configure this as a Lambda layer again after removing any dependencies.

Please ensure in this process that you only remove unnecessary dependencies.

like image 167
Chris Williams Avatar answered Jan 02 '23 12:01

Chris Williams