Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to download AWS Lambda Layer

Using the AWS CLI is it possible to download a Lambda Layer?

I have seen this documented command. https://docs.aws.amazon.com/lambda/latest/dg/API_GetLayerVersion.html

But when I try to run it with something like below.

aws lambda get-layer-version --layer-name arn:aws:lambda:us-east-1:209497400698:layer:php-73 --version-number 7

I get this error.

An error occurred (InvalidParameterValueException) when calling the GetLayerVersion operation: Invalid Layer name: arn:aws:lambda:us-east-1:209497400698:layer:php-73

Is downloading a layer possible via the CLI?

As an extra note I am trying to download any of these layers https://runtimes.bref.sh/

like image 255
Somk Avatar asked Jun 15 '19 20:06

Somk


1 Answers

It should be possible to download a layer programmatically using the AWS CLI. For example

# https://docs.aws.amazon.com/cli/latest/reference/lambda/get-layer-version.html
URL=$(aws lambda get-layer-version --layer-name YOUR_LAYER_NAME_HERE --version-number YOUR_LAYERS_VERSION --query Content.Location --output text)
curl $URL -o layer.zip

For the arn's in that web page, I had to use the other api which uses an arn value. For example:

# https://docs.aws.amazon.com/cli/latest/reference/lambda/get-layer-version-by-arn.html
URL=$(aws lambda get-layer-version-by-arn --arn arn:aws:lambda:us-east-1:209497400698:layer:php-73:7 --query Content.Location --output text)
curl $URL -o php.zip

HTH

-James

like image 53
jmp Avatar answered Sep 20 '22 14:09

jmp