I am trying to use AWS Update-LMFunctionCode to deploy my file with an existing lambda function in AWS.
Unlike the Publish-LMFunction function, where I can only provide the path to the zipFile (-FunctionZip), Update-LMFunction wants to have memystream for its -Zipfile argument.
is there an example of loading a local zip file from disk into a memory stream that works? My initial calls get errors that the file cannot be unzipped ...
$deployedFn = Get-LMFunction -FunctionName $functionname "Function Exists - trying to update" try{ [system.io.stream]$zipStream = [system.io.File]::OpenRead($zipFile) [byte[]]$filebytes = New-Object byte[] $zipStream.length [void] $zipStream.Read($filebytes, 0, $zipStream.Length) $zipStream.Close() "$($filebytes.length)" $zipString = [System.Convert]::ToBase64String($filebytes) $ms = new-Object IO.MemoryStream $sw = new-Object IO.StreamWriter $ms $sw.Write($zipString) Update-LMFunctionCode -FunctionName $functionname -ZipFile $ms } catch{ $ErrorMessage = $_.Exception.Message Write-Host $ErrorMessage break }
The docs for the Powershell function are here: http://docs.aws.amazon.com/powershell/latest/reference/items/Update-LMFunctionCode.html , although it wants to live in a frame ...
powershell amazon-web-services aws-lambda aws-powershell
Jeff martin
source share