Serverless run times with custom Bash AWS Lambda layers

A Code Bash

Get Set, Go

Navigate up to the top-right part of the function's page (Figure 5). Once there, click on Configure test events to create a test with variables to be sent to the function.

Figure 5: Creating a test event and running a test.

In my case, I'm going to leave an empty set of variables and not pass anything to the Lambda function; instead, I'll just send an empty run command to the Lambda function. I do, however, need to add the name EmptyTest to the test event under Event name . In this example, I'll just use the Hello World template. Click Save once you've added the event name and run the test by clicking the Test button. Figure 6 shows a successful invocation of the Lambda function.

Figure 6: All is well. Bash meets Lambda, just as hoped.

Look back at the payload's content in Figure 2. Note that it runs the jq JSON formatting command and outputs I am a Bash command! (Listing 1). Lo and behold, that's what is present in the CloudWatch logs. If you get stuck, CloudWatch is your friend. The AWS Management Console main page has more than one link to click to read the most recent logs for the Lambda function, so follow a link.

The End Is Nigh

I hope you agree that the sophisticated functionality illustrated in this article brings a welcome addition to Lambda functions for those not familiar with other languages. Imagine the number of legacy scripts that are too much work to refactor but would suit a serverless invocation.

With the ever-growing features available in AWS, the use of Lambda functions will only grow and, I suspect, continue at the exponential rate it has shown so far. I hope you will enjoy using Bash for serverless tasks in the future as much as I intend to. Now, let me think, where's that uptime dashboard script I wrote a few years ago?

The Author

Chris Binnie's latest book, Linux Server Security: Hack and Defend, shows how hackers launch sophisticated attacks to compromise servers, steal data, and crack complex passwords, so you can learn how to defend against such attacks. In the book, he also shows you how to make your servers invisible, perform penetration testing, and mitigate unwelcome attacks. You can find out more about DevOps, DevSecOps, Containers, and Linux security on his website:

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy ADMIN Magazine

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus
Subscribe to our ADMIN Newsletters
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs

Support Our Work

ADMIN content is made possible with support from readers like you. Please consider contributing when you've found an article to be beneficial.

Learn More”>


		<div class=