0

Lambda 中的新nodejs运行时基于未预安装的 Amazon2 curl。因此curl: command not found在尝试使用它时给出一个。

我如何curl回到新的nodejs 10.x and 12.x运行时?

我找不到curllambda 层。

4

1 回答 1

4

推荐的方式是使用request客户端nodejs。但是,如果您在curl从 升级node 8.x到时投入过多node 12.x,您将需要自己包含curl二进制文件和所需的库。

我创建了一个 lambda 层arn:aws:lambda:us-east-1:310788757301:layer:curl:15。您可以自由使用它,但是我将其用于个人用途,因此我不建议在生产环境中使用它。相反,我将为您提供有关构建您自己的curllambda 层的指南。

我上传了curl 7.69.1 (x86_64-redhat-linux-gnu),并用来ldd /opt/bin/curl找出缺少哪些库。包含所有必需的库后,输出如下:

START RequestId: c9e7ed3f-f1b7-4e93-98fe-dea302385723 Version: $LATEST
2020-03-29T23:37:19.899Z    c9e7ed3f-f1b7-4e93-98fe-dea302385723    INFO        linux-vdso.so.1 (0x00007ffdf2f76000)
    libcurl.so.4 => /opt/lib/libcurl.so.4 (0x00007faa5f5c8000)
    libmetalink.so.3 => /opt/lib/libmetalink.so.3 (0x00007faa5f3b9000)
    libssl.so.10 => /lib64/libssl.so.10 (0x00007faa5f14a000)
    libcrypto.so.10 => /lib64/libcrypto.so.10 (0x00007faa5ecf6000)
    libz.so.1 => /lib64/libz.so.1 (0x00007faa5eae1000)
    librt.so.1 => /lib64/librt.so.1 (0x00007faa5e8d9000)
    libc.so.6 => /lib64/libc.so.6 (0x00007faa5e52e000)
    libcares.so.2 => /opt/lib/libcares.so.2 (0x00007faa5e31e000)
    libssh2.so.1 => /opt/lib/libssh2.so.1 (0x00007faa5e0f6000)
    libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007faa5deaa000)
    libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007faa5dbc6000)
    libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007faa5d995000)
    libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007faa5d791000)
    libldap-2.4.so.2 => /opt/lib/libldap-2.4.so.2 (0x00007faa5d540000)
    libexpat.so.1 => /opt/lib/libexpat.so.1 (0x00007faa5d318000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007faa5d114000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007faa5cef6000)
    /lib64/ld-linux-x86-64.so.2 (0x00007faa5f84d000)
    libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007faa5cce7000)
    libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007faa5cae3000)
    libresolv.so.2 => /lib64/libresolv.so.2 (0x00007faa5c8cd000)
    liblber-2.4.so.2 => /opt/lib/liblber-2.4.so.2 (0x00007faa5c6be000)
    libsasl2.so.2 => /opt/lib/libsasl2.so.2 (0x00007faa5c4a4000)
    libssl3.so => /opt/lib/libssl3.so (0x00007faa5c251000)
    libsmime3.so => /opt/lib/libsmime3.so (0x00007faa5c024000)
    libnss3.so => /opt/lib/libnss3.so (0x00007faa5bcdc000)
    libnssutil3.so => /lib64/libnssutil3.so (0x00007faa5baad000)
    libplds4.so => /lib64/libplds4.so (0x00007faa5b8a9000)
    libplc4.so => /lib64/libplc4.so (0x00007faa5b6a4000)
    libnspr4.so => /lib64/libnspr4.so (0x00007faa5b468000)
    libselinux.so.1 => /lib64/libselinux.so.1 (0x00007faa5b241000)
    libcrypt.so.1 => /opt/lib/libcrypt.so.1 (0x00007faa5b00a000)
    libpcre.so.1 => /lib64/libpcre.so.1 (0x00007faa5ada6000)
    libfreebl3.so => /lib64/libfreebl3.so (0x00007faa5aba3000)

END RequestId: c9e7ed3f-f1b7-4e93-98fe-dea302385723
REPORT RequestId: c9e7ed3f-f1b7-4e93-98fe-dea302385723  Duration: 515.09 ms Billed Duration: 600 ms Memory Size: 128 MB Max Memory Used: 70 MB  Init Duration: 115.35 ms    

我下载了 RedHat 6 和 Centos 6 库的混合,它似乎工作。这是您将需要的清单。

.
├── bin
│   └── curl
└── lib
    ├── libcares.so.2 -> libcares.so.2.1.0
    ├── libcares.so.2.1.0
    ├── libcrypt-2.12.so
    ├── libcrypt.so.1 -> libcrypt-2.12.so
    ├── libcurl.so.4 -> libcurl.so.4.6.0
    ├── libcurl.so.4.6.0
    ├── libexpat.so.1 -> libexpat.so.1.5.2
    ├── libexpat.so.1.5.2
    ├── liblber-2.4.so.2 -> liblber-2.4.so.2.10.3
    ├── liblber-2.4.so.2.10.3
    ├── libldap-2.4.so.2 -> libldap-2.4.so.2.10.3
    ├── libldap-2.4.so.2.10.3
    ├── libmetalink.so.3 -> libmetalink.so.3.1.0
    ├── libmetalink.so.3.1.0
    ├── libnss3.so
    ├── libnsspem.so
    ├── libsasl2.so.2 -> libsasl2.so.2.0.23
    ├── libsasl2.so.2.0.23
    ├── libsmime3.so
    ├── libssh2.so.1 -> libssh2.so.1.0.1
    ├── libssh2.so.1.0.1
    └── libssl3.so

您可以在此处查看和下载我的 lambda 层的副本:https ://github.com/andey/curl-lambda-layer

于 2020-03-29T23:50:00.653 回答