Vague error message if zip command is missing in AWSLambdaPSCore
See original GitHub issueDescription
When setting up AWSLambdaPSCore on a fresh EC2 instance running Ubuntu Server 20.04 LTS, some dependencies for the AWSLambdaPSCore module are not pre-installed. If you attempt to publish a PowerShell-based AWS Lambda function, you receive a very bizarre error message.
zip
command is not installed by default
Expected Behavior
The Publish-AWSPowerShellLambda
command should run dependency checks early on, before running the dotnet restore
command, so that any missing utilities can be installed, and DOTNET_ROOT
is set correctly. Any missing dependencies should be listed out, along with remediation commands, to provide a pleasant user experience for this command.
I’ve also come across an issue where libhostfxr.so
could not be found. I think that’s somehow related to DOTNET_ROOT
, but I’m not entirely sure, as I can’t seem to intentionally reproduce it. I think it had something to do with having .NET Core 5.0 installed, but not 3.1.
Here’s a list of dependency checks that I’m currently aware of, which should be executed each time an invocation of Publish-AWSPowerShellLambda
is made:
- .NET Core SDK installed
DOTNET_ROOT
set correctly (if required)libhostfxr.so
can be locatedzip
command is installed
There may be other dependency checks that should be included as well, so please feel free to add them to this issue report.
Reproduction Steps
bash> sudo snap install powershell --classic
bash> pwsh
PS > Install-Module -Name AWSLambdaPSCore -Scope CurrentUser -Force
PS > Publish-AWSPowerShellLambda ..........
Zipping publish folder /tmp/generatetonsofdata.ps1/bin/Release/netcoreapp3.1/publish to /tmp/generatetonsofdata.ps1/bin/Release/netcoreapp3.1/generatetonsofdata.ps1.zip
Failed to find the "zip" utility program in path. This program is required to maintain Linux file permissions in the zip archive.
Exception: /home/ubuntu/.local/share/powershell/Modules/AWSLambdaPSCore/2.0.0.0/Private/_DeploymentFunctions.ps1:203
Line |
203 | throw $msg
| ~~~~~~~~~~
| Error publishing PowerShell Lambda Function: 255 CALLSTACK: Command Arguments ------- ---------
| _deployProject {ProfileName=, PowerShellFunctionHandler=, Region=, EnvironmentVariables=, Tags=, PublishNewVersion=, DisableInteractive=,
| FunctionRole=arn:aws:iam::665453315… Publish-AWSPowerShellLambda {Name=generatetonsofdata, ScriptPath=./generatetonsofdata.ps1/generatetonsofdata.ps1.ps1,
| IAMRoleArn=arn:aws:iam::665453315198:role/lambdaworkspacescleanup} <ScriptBlock> {}
Environment
Name Value
---- -----
PSVersion 7.1.2
PSEdition Core
GitCommitId 7.1.2
OS Linux 5.4.0-1038-aws #40-Ubuntu SMP Fri Feb 5 23:50:40 UTC 2021
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Resolution
- 👋 I can/would-like-to implement a fix for this problem myself
This is a 🐛 bug-report
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
@pcgeek86 Thanks for your response. I will convert this to
feature-request
and have developer look at it.We have noticed this issue has not received attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue.