The AWS Lambda Tools for Powershell allows PowerShell developers to publish PowerShell scripts with their dependent modules and have the scripts be invoked by Lambda.
Before we get started developing PowerShell based Lambda functions, let's set up our development environment.
First, we need to set up the correct version of PowerShell. AWS Lambda support for PowerShell is based on the cross-platform PowerShell Core 6.0 release. This means you can develop your Lambda functions for PowerShell on Windows, Linux, or Mac. If you don't have this version of PowerShell installed, you can find instructions here.
If you are using Visual Studio Code on Windows as your IDE, you need to ensure it's configured for PowerShell Core 6.0. To learn how to configure Visual Studio Code for PowerShell Core, see the following: https://docs.microsoft.com/en-us/powershell/scripting/core-powershell/vscode/using-vscode?view=powershell-6
Next, we need to install the .NET Core 2.1 SDK. Because PowerShell Core is built on top of .NET Core, the Lambda support for PowerShell uses the same .NET Core 2.1 Lambda runtime for both .NET Core and PowerShell based Lambda functions. The .NET Core 2.1 SDK is used by the new PowerShell publishing cmdlets for Lambda to create the Lambda deployment package. You can find the .NET Core 2.1 SDK here. Be sure to install the SDK, not the runtime installation.
The last component we need for the development environment is the new AWSLambdaPSCore module that you can install from the PowerShell Gallery. The following is an example of installing the module from a PowerShell Core shell.
Install-Module AWSLambdaPSCore -Scope CurrentUser
This new module has the following new cmdlets to help you author and publish PowerShell based Lambda functions.
Cmdlet name | Description |
---|---|
Get-AWSPowerShellLambdaTemplate | Returns a list of getting started templates. |
New-AWSPowerShellLambda | Used to create an initial PowerShell script that is based on a template. |
Publish-AWSPowerShellLambda | Publishes a given PowerShell script to Lambda. |
New-AWSPowerShellLambdaPackage | Creates the Lambda deployment package that can be used in a CI/CD system for deployment. |
- Programming Model for Authoring Lambda Functions in PowerShell
- Creating a Deployment Package (PowerShell)
- Announcing Lambda Support for PowerShell Core
- Deploying PowerShell-based Lambda with AWS CloudFormation
- Creating a PowerShell REST API
- AWS Lambda and PowerShell - By Alex Neihaus
- Intro post for responding to S3 Events with PowerShell.
- Creating a PowerShell Lambda-backed Custom Resource for AWS CloudFormation - By Nate Ferrell
- Writing PowerShell Core AWS Lambda Functions – Part I - By Tim Pringle
- A series creating an Amazon Lex bot connected to Facebook powered by PowerShell Lambda.
- Part 1 sets up the Facebook app.
- Writing PowerShell Core AWS Lambda Functions – Part II - By Tim Pringle
- Part 2 sets up the dev environment and explain each of the available PowerShell Lambda cmdlets from the AWSLambdaPSCore module.
- Writing PowerShell Core AWS Lambda Functions – Part III - By Tim Pringle
- Part 3 sets up the Lex 'bot, Messenger component, and introduces the event data that the PowerShell Lambda function will process.
- Writing PowerShell Core AWS Lambda Functions - Part IV - By Tim Pringle
- Part 4 walksthrough writing the entire PowerShell Lambda function and testing it locally.
- Writing PowerShell Core AWS Lambda Functions - Part V - By Tim Pringle
- Part 5 concludes the series with the packaging and publishing of the PowerShell Lambda function to AWS and shows it in operation from Facebook.
- AWS Lambda and PowerShell - By Graham Beer
- Building Environment to create PowerShell AWS lambda's. Example of shutting down instances via tagging.
- Automate the posts on Twitter using a AWS Lambda function and PowerShell - By Victor Silva
- A way to send automated blog post on Twitter without “human” interaction using PowerShell AWS Lambda´s.