Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can bash script be written inside a AWS Lambda function

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.

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

like image 636
Hardik Kamdar Avatar asked Jan 06 '16 09:01

Hardik Kamdar


People also ask

Does AWS Lambda supported programming languages?

AWS Lambda natively supports Java, Go, PowerShell, Node. js, C#, Python, and Ruby code, and provides a Runtime API which allows you to use any additional programming languages to author your functions.

What is bash script in AWS?

What is Bash Script in AWS? Bash script is a simple text file that contains commands which are used in the command line. When an Amazon EC2 instance is launched, user data can be passed to the instance in different ways.


1 Answers

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.

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 } 

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.

like image 141
mturatti Avatar answered Sep 29 '22 18:09

mturatti