BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News AWS Introduces PowerShell Custom Runtime for Lambda

AWS Introduces PowerShell Custom Runtime for Lambda

This item in japanese

AWS recently announced a new PowerShell custom runtime for AWS Lambda to run Lambda functions written in PowerShell. With the new runtime developers can write native PowerShell code in Lambda without having to compile it, simplifying deployment and testing.

Julian Wood, serverless developer advocate at AWS, explains the benefits:

The new custom runtime for PowerShell uses native PowerShell, instead of compiling PowerShell and hosting it on the .NET runtime. Using native PowerShell means the function runtime environment matches a standard PowerShell session, which simplifies the development and testing process (...) This custom runtime returns everything placed on the pipeline as the function output, including the output of Write-Output. This gives you more control over the function output, error messages, and logging.

While Lambda has supported PowerShell since 2018, the previous solution required the .NET Core runtime implementation for PowerShell and a function returned only the last output from the PowerShell pipeline. Justin Grote, Microsoft MVP and Powershell evangelist, tweets:

AWS Lambda finally has a PowerShell runtime that isn't "Hey build a C# app that's a PowerShell host, that's how we support PowerShell". Great work!

Source: https://aws.amazon.com/blogs/compute/introducing-the-powershell-custom-runtime-for-aws-lambda/

Building Lambda functions with PowerShell currently supports .NET 6 and .NET Core 3.1. The runtime defines two main variables made available to the Lambda function: $LambdaInput, a PSObject that contains the input event data, and $LambdaContext, an object that provides methods and properties with information about the invocation and runtime environment.

Kevin Marquette, systems development engineer at Amazon and author of PowerShell Explained, writes:

This is really awesome. I wasn't happy with the original PowerShell Lambda dev experience, so I created a custom runtime to show what the user experience could be. They took my concept and put resources behind it to make it real. I'm glad this was finally released.

The new custom runtime allows editing PowerShell code directly within the Lambda console and supports additional functionality, including Add-Type, and different handler options. Wood explains how to build and package it:

The custom runtime is based on Lambda’s provided.al2 runtime, which runs in an Amazon Linux environment (...) You can build and package the runtime as a Lambda layer, or include it in a container image. When packaging as a layer, you can add it to multiple functions, which can simplify deployment. The runtime is based on the cross-platform PowerShell Core. This means that you can develop Lambda functions for PowerShell on Windows, Linux, or macOS.

A GitHub repository is available with the code for the custom runtime, along with installation options and different examples.

About the Author

Rate this Article

Adoption
Style

BT