给定 ARN,是否可以从 AWS 下载 public Lambda 层的内容?

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

我想从这个 GitHub repository 下载 public arn 以获得更紧凑的 spacy 版本。

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

我怎样才能做到这一点?

您可以使用 CLI 中的 get-layer-version-by-arn function 从 Arn 获取它。

您可以运行以下命令获取您请求的 Lambda 层的源。

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

您将收到的回复示例如下

{
    "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"
}

一旦你 运行 你会得到一个返回的响应,其中包含一个 "Location" 的子键,它引用了下载层内容的 S3 路径。 "Content" =16=]

您可以从此路径下载,然后您需要在删除所有依赖项后再次configure将其作为 Lambda 层。