lambda 函数如何在无服务器中工作?

How does lambda functions works in serverless?

有没有handler.js是运行宁的环境?如果是的话,如果在 AWS lambda 中以某种方式 运行 sudo rm -rf ~/ 怎么办?

怎么想会发生什么?

您可以将 Lambda 函数视为托管(短期)docker 容器(尽管 Micro-VM 更正确,正如我们在 re:Invent 2018 年了解到的那样)。您定义 "container" 必须用于 运行 函数的计算和 RAM 资源。

documentation 所述,您将获得以下环境:

The underlying AWS Lambda execution environment includes the following software and libraries.

  • Operating system – Amazon Linux
  • AMI – amzn-ami-hvm-2017.03.1.20170812-x86_64-gp2
  • Linux kernel – 4.14.77-70.59.amzn1.x86_64
  • AWS SDK for JavaScript – 2.290.0
  • SDK for Python (Boto 3) – 3-1.7.74 botocore-1.10.74

此外,您在 /tmp/.

处获得了一些临时存储空间(目前为 500MB)

AWS 尝试重新运行 每个 Lambda 调用的处理程序函数(参见 here for more details), if there is already a "container" running, so I'd imagine you could break your own container - although it apparently doesn't have sudo privileges,因此您对 sudo rm -rf 的影响有限。