Using the Lambda context object to retrieve PowerShell function information (original) (raw)

When Lambda runs your function, it passes context information by making a $LambdaContext variable available to the handler. This variable provides methods and properties with information about the invocation, function, and execution environment.

Context properties

The following PowerShell code snippet shows a simple handler function that prints some of the context information.

#Requires -Modules @{ModuleName='AWSPowerShell.NetCore';ModuleVersion='3.3.618.0'}
Write-Host 'Function name:' $LambdaContext.FunctionName
Write-Host 'Remaining milliseconds:' $LambdaContext.RemainingTime.TotalMilliseconds
Write-Host 'Log group name:' $LambdaContext.LogGroupName
Write-Host 'Log stream name:' $LambdaContext.LogStreamName