bash 脚本可以写在 AWS Lambda 函数中吗 [英] Can bash script be written inside a AWS Lambda function

查看:31
本文介绍了bash 脚本可以写在 AWS Lambda 函数中吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在 Lambda 函数中编写 bash 脚本吗?我在 aws 文档中读到它可以执行用 Python、NodeJS 和 Java 8 编写的代码.

Can I write a bash script inside a Lambda function? I read in the aws docs that it can execute code written in Python, NodeJS and Java 8.

在一些文件中提到可能可以使用Bash,但没有具体的证据支持它或任何示例

It is mentioned in some documents that it might be possible to use Bash but there is no concrete evidence supporting it or any example

推荐答案

AWS 最近宣布了Lambda 运行时 API 和 Lambda 层",这两项新功能使开发人员能够构建自定义运行时.因此,现在甚至可以在 Lambda 中直接运行 bash 脚本而无需黑客攻击.

AWS recently announced the "Lambda Runtime API and Lambda Layers", two new features that enable developers to build custom runtimes. So, it's now possibile to directly run even bash scripts in Lambda without hacks.

由于这是一个非常新的功能(2018 年 11 月),目前还没有太多材料,还需要一些手动工作,但你可以看看 this Github repo 作为开始的示例(免责声明:我没有测试它).下面是 bash 中的示例处理程序:

As this is a very new feature (November 2018), there isn't much material yet around and some manual work still needs to be done, but you can have a look at this Github repo for an example to start with (disclaimer: I didn't test it). Below a sample handler in bash:

function handler () {
  EVENT_DATA=$1
  echo "$EVENT_DATA" 1>&2;
  RESPONSE="{"statusCode": 200, "body": "Hello World"}"
  echo $RESPONSE
}

这实际上开启了在 Lambda 中运行任何编程语言的可能性.这是一个关于发布自定义的 AWS 教程Lambda 运行时.

This actually opens up the possibility to run any programming language within a Lambda. Here it is an AWS tutorial about publishing custom Lambda runtimes.

这篇关于bash 脚本可以写在 AWS Lambda 函数中吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆