How To Pass Input Data To An Amazon Web Services (AWS) Lambda PowerShell Script

Now that AWS recently announced support for its Lambda functions, we can now automate and manage AWS resources with PowerShell scripts. When triggering a PowerShell Lambda function, you will probably need to pass some kind of input to your scripts.

In this Snip, Matt will show you how to create a PowerShell script, created from a template, that will accept some input through the $LambdaInput predefined variable. Then we will take this further and invoke the Lambda PowerShell function using Invoke-LMFunction passing in a payload in JSON format. When the script runs, it will output some text created from the payload input to the CloudWatch logs.

Prerequisites include: PowerShell 6.0 or higher AWSLambdaPSCore Module AWSPowerShell.NetCore Module .NET Core 2.1 SDK An AWS IAM role