You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If $Name is defined with a type in global scope then the invocation of _packageProject can fail.
For example, if a variable is instantiated with a type that does not support op_Addition an error will be raised:
# That this is set is none of this modules business.
[IPAddress]$Name='1.2.3.4'
Expected Behavior
That the lambda package would create successfully.
Current Behavior
The build fails because of an attempt to += based on the existing $Name variable from global scope.
16|PS> New-AWSPowerShellLambdaPackage @params
Staging deployment at c:\temp\stage\test
Configuring PowerShell to version 7.2.1
Generating C# project C:\temp\stage\test\test.csproj used to create Lambda function bundle.
Generating C:\temp\stage\test\Bootstrap.cs to load PowerShell script and required modules in Lambda environment.
Generating aws-lambda-tools-defaults.json config file with default values used when publishing project.
Copying PowerShell script to staging directory
Creating deployment package at c:\temp\test.zip
InvalidOperation: C:\Users\chris\Documents\PowerShell\Modules\AWSLambdaPSCore\3.0.1.0\Private\_DeploymentFunctions.ps1:254
Line |
254 | $arguments += " --configuration Release --framework $AwsPower …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Method invocation failed because [System.Net.IPAddress] does not contain a method named 'op_Addition'.
When deploying this package to AWS Lambda you will need to specify the function handler. The handler for this package is: test::test.Bootstrap::ExecuteFunction. To request Lambda to invoke a specific PowerShell function in your script specify the name of the PowerShell function in the environment variable AWS_POWERSHELL_FUNCTION_HANDLER when publishing the package.
Resolve-Path: C:\Users\chris\Documents\PowerShell\Modules\AWSLambdaPSCore\3.0.1.0\Public\New-AWSPowerShellLambdaPackage.ps1:198
Line |
198 | … PathToPackage = Resolve-Path -Path $OutputPackage
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Cannot find path 'C:\temp\test.zip' because it does not exist.
Reproduction Steps
# That this is set is none of this modules business.
[IPAddress]$Name='1.2.3.4'New-Item c:\temp\stage -ItemType Directory
Set-Content'c:\temp\test.ps1'-Value 'Write-Host "Hello world"'$params=@{
ScriptPath='c:\temp\test.ps1'StagingDirectory='c:\temp\stage'OutputPackage='c:\temp\test.zip'
}
New-AWSPowerShellLambdaPackage@params
Possible Solution
Use parameters to pass variables between scopes. Properly declare variables in parent scopes.
Additional Information/Context
No response
AWS .NET SDK and/or Package version used
AWSLambdaPSCore 3.0.1.0
Targeted .NET Platform
.NET Core 3.1
Operating System and version
Windows 11
The text was updated successfully, but these errors were encountered:
Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.
Describe the bug
The private function
_packageProject
attempts to concatenate with a variable from a parent scope which is not declared in any intermediate scope.https://github.com/aws/aws-lambda-dotnet/blob/master/PowerShell/Module/Private/_DeploymentFunctions.ps1#L253-L254
If
$Name
is defined with a type in global scope then the invocation of_packageProject
can fail.For example, if a variable is instantiated with a type that does not support op_Addition an error will be raised:
Expected Behavior
That the lambda package would create successfully.
Current Behavior
The build fails because of an attempt to
+=
based on the existing$Name
variable from global scope.Reproduction Steps
Possible Solution
Use parameters to pass variables between scopes. Properly declare variables in parent scopes.
Additional Information/Context
No response
AWS .NET SDK and/or Package version used
AWSLambdaPSCore 3.0.1.0
Targeted .NET Platform
.NET Core 3.1
Operating System and version
Windows 11
The text was updated successfully, but these errors were encountered: