awslabs / aws-lambda-powershell-runtime

This new PowerShell custom runtime for AWS Lambda makes it even easier to run Lambda functions written in PowerShell to process events.
Apache License 2.0
59 stars 20 forks source link
aws aws-lambda lambda powershell serverless

PowerShell Runtime for AWS Lambda

This new PowerShell custom runtime for AWS Lambda makes it even easier to run Lambda functions written in PowerShell to process events.

Your code runs in an Amazon Linux environment that includes AWS credentials from an AWS Identity and Access Management (IAM) role that you manage.

Overview

Lambda has supported running PowerShell since 2018. However, the existing solution uses the .NET Core runtime implementation for PowerShell. It uses the additional AWSLambdaPSCore modules for deployment and publishing, which require compiling the PowerShell code into C# binaries to run on .NET. This adds additional steps to the development process.

This new runtime uses Lambda's custom runtime functionality based on the provided.al2023 runtime.

PowerShell custom runtime benefits

Building, deploying, and invoking PowerShell Lambda functions

You can build the custom runtime using a number of tools, including the the AWS Command Line Interface (AWS CLI), or with infrastructure as code tools such as AWS CloudFormation, AWS Serverless Application Model (AWS SAM), Serverless Framework, and AWS Cloud Development Kit (AWS CDK).

Deploy the example demo-runtime-layer-function to explore how the runtime and PowerShell function work.

PowerShell-runtime

Contains the PowerShell custom runtime based on provided.al2023 with a number of deployment methods.

PowerShell-modules

Contains a number of PowerShell modules you can build and add to your functions. Module Description
AWSToolsforPowerShell AWS Tools for PowerShell
VMwarePowerCLI VMware PowerCLI

Examples folder

Contains a number of demo applications to show the PowerShell runtime functionality.

Initial demo application demo-runtime-layer-function uses AWS SAM to deploy the following:

  1. PowerShell custom runtime based on provided.al2023 as a Lambda layer.
  2. Additional Lambda layer including the AWSTools for PowerShell with the following module.
  1. Lambda function with three different handler options.

All examples

Example Description
demo-runtime-layer-function All-in-one Powershell runtime layer, AWS Tools for PowerShell layer, Lambda function with all three handler options.
demo-s3-lambda-eventbridge Demo to show an event-drive application in PowerShell. Copy .CSV file to S3 which triggers PowerShell Lambda function which parses the file. Sends each file line as an event to EventBridge which writes it to CLoudWatch Logs.
demo-container-image-all-aws-sdk Demo application to deploy a PowerShell Lambda function using a container image. The container image can be up to 10Gb in size which allows you to build functions larger than the 256MB limit for .zip archive functions. This allows you to include the entire AWSTools for PowerShell SDK, for example.
demo-container-images-shared Demo application to deploy container image Lambda function using separate layers for the PowerShell runtime and entire AWSTools for PowerShell SDK. This allows you to use these shared layers to build multiple Lambda functions. The container image can be up to 10Gb in size which allows you to build functions larger than the 256MB limit for .zip archive functions.

Powershell runtime information

See the PowerShell-runtime page for more information on how the runtime works, including:

Acknowledgements

This custom runtime builds on the work of Norm Johanson, Kevin Marquette, Andrew Pearce, Afroz Mohammed, and Jonathan Nunn.

Security

See CONTRIBUTING for more information.

License

This project is licensed under the Apache-2.0 License.