derek lawless
Posted on June 16, 2022
The packaged .zip for a Lambda layer can be downloaded using the AWS console (appropriate IAM permissions notwithstanding) - as long as you have access to the host AWS account of course.
If the Lambda layer originates in a different AWS account you don't have console access to, you will need to use the AWS CLI.
Why would you want or need to do this though?
- As with any third party dependency it makes sense to examine it rather than simply trusting it to be benign in nature
- You want to override the layer's behaviour in a specific way (i.e. by merging a later layer) and need to examine its implementation
Fortunately, the aws lambda
CLI provides two useful options - one for downloading a layer version by name, the other by its ARN.
Downloading a Lambda layer version by name
To download version 99 of a Lambda layer called acme-corp-lambda-layer
using its name, use the get-layer-version
option:
URL=$(aws lambda get-layer-version --layer-name ars:aws:lambda:$AWS_REGION:$AWS_ACME_CORP_ACCOUNT:layer:acme-corp-lambda-layer --version-number:99 --query Content.Location --output text)
curl $URL -o acme-corp-lambda-layer.zip
Downloading a Lambda layer version by ARN
If you want to download version 99 of of the layer using its ARN instead, use get-layer-version-by-arn
:
URL=$(aws lambda get-layer-version-by-arn --arn arn:aws:lambda:$AWS_REGION:$AWS_ACME_CORP_ACCOUNT:layer:my-lambda-layer:99 --query Content.Location --output text)
curl $URL -o acme-corp-lambda-layer.zip
Posted on June 16, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.