aws / aws-lambda-dotnet

Libraries, samples and tools to help .NET Core developers develop AWS Lambda functions.
Apache License 2.0
1.58k stars 477 forks source link

AWS Lambda Tools for PowerShell: PackageScript & PackageProject parameter sets aren't documented clearly #1821

Open sixfootdad opened 2 months ago

sixfootdad commented 2 months ago

Describe the issue

While the comment-based help mentions script & project workflows in both New-AWSPowerShellLambda & New-AWSPowerShellLambdaPackage, it isn't very clear how one would utilize those two options.

For example, when creating a new script using the basic template with New-AWSPowerShellLambda -Template Basic the output will create a new AWS Lambda PowerShell script Basic.ps1 from template Basic.ps1.txt at ./Basic. If New-AWSPowerShellLambdaPackage -ProjectDirectory ./Basic -OutputPackage ./Basic.zip is run, packaging will fail as ProjectDirectory belongs to the PackageProject parameter set (but the error messaging isn't super clear on why).

tl;dr - it's easy to mix up the parameter sets unknowingly, and the comment-based help doesn't make that clear.

Links

ashishdhingra commented 2 months ago

@sixfootdad Good afternoon. Thanks for opening the issue. Error is reproducible with your scenario giving below message:

Copying local module AWS.Tools.Common(4.1.491) from /Users/REDACTED/.local/share/powershell/Modules/AWS.Tools.Common/4.1.491
Resolved full output package path as /Users/REDACTED/dev/repros/PowerShellLambdaTest/Issue1821/./Basic.zip               
Creating deployment package at /Users/REDACTED/dev/repros/PowerShellLambdaTest/Issue1821/./Basic.zip
Restoring .NET Lambda deployment tool
Initiate packaging
Exception: /Users/REDACTED/.local/share/powershell/Modules/AWSLambdaPSCore/4.0.0.0/Private/_DeploymentFunctions.ps1:279
Line |
 279 |              throw $msg
     |              ~~~~~~~~~~
     | Error publishing PowerShell Lambda Function: 255 CALLSTACK: Command                        Arguments -------          
     | ---------                                                                                       _packageProject       
     | {OutputPackage=/Users/REDACTED/dev/repros/PowerShellLambdaTest/Issue1821/./Basic.zip, BuildDire…
     | New-AWSPowerShellLambdaPackage {ProjectDirectory=./Basic, OutputPackage=./Basic.zip}                                  
     | <ScriptBlock>                  {}

However, if you use the -Verbose parameter, it emits below in the output:

VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.Common.
VERBOSE: Found installed module AWS.Tools.Common (4.1.491) to save with package bundle.
Copying local module AWS.Tools.Common(4.1.491) from /Users/REDACTED/.local/share/powershell/Modules/AWS.Tools.Common/4.1.491
Resolved full output package path as /Users/REDACTED/dev/repros/PowerShellLambdaTest/Issue1821/./Basic.zip               
Creating deployment package at /Users/REDACTED/dev/repros/PowerShellLambdaTest/Issue1821/./Basic.zip
Restoring .NET Lambda deployment tool
VERBOSE: Updating .NET Global Tool Amazon.Lambda.Tools
VERBOSE: Looking for windows excutable for dotnet-lambda.exe
VERBOSE: Did not find windows executable, assuming on non windows platform and using dotnet-lambda
Initiate packaging
VERBOSE: ~/.dotnet/tools/dotnet-lambda package  --configuration Release --framework net8.0 --function-runtime dotnet8 --output-package "/Users/REDACTED/dev/repros/PowerShellLambdaTest/Issue1821/./Basic.zip"
VERBOSE: Amazon Lambda Tools for .NET Core applications (5.10.7)
VERBOSE: Project Home: https://github.com/aws/aws-extensions-for-dotnet-cli, https://github.com/aws/aws-lambda-dotnet
VERBOSE:    
VERBOSE: No .NET project found in directory /Users/REDACTED/dev/repros/PowerShellLambdaTest/Issue1821/Basic to build.
Exception: /Users/REDACTED/.local/share/powershell/Modules/AWSLambdaPSCore/4.0.0.0/Private/_DeploymentFunctions.ps1:279
Line |
 279 |              throw $msg
     |              ~~~~~~~~~~
     | Error publishing PowerShell Lambda Function: 255 CALLSTACK: Command                        Arguments -------          
     | ---------                                                                                       _packageProject       
     | {OutputPackage=/Users/REDACTED/dev/repros/PowerShellLambdaTest/Issue1821/./Basic.zip, BuildDire…
     | New-AWSPowerShellLambdaPackage {ProjectDirectory=./Basic, OutputPackage=./Basic.zip, Verbose=True}                    
     | <ScriptBlock>                  {}

The error is thrown by the underlying AWS .NET CLI Extensions tooling.

Please advise the content update you propose to document this scenario clearly.

Thanks, Ashish