aws-lambda-dotnet
aws-lambda-dotnet copied to clipboard
Update `Publish-AWSPowerShellLambda` to set function runtime if it does not match the built csproj
Describe the feature
Publish-AWSPowerShellLambda
would be a better experience if it would automatically upgrade the function config to match the correct dotnet runtime prior to uploading function code. There is no parameter to specify this, so you need to trigger it via some other mechanism.
Use Case
When publishing a function via Publish-AWSPowerShellLambda
, if the current function config does not match what was built the deployment will fail.
Error updating code for Lambda function: The runtime parameter of dotnetcore2.1 is no longer supported for creating or updating AWS Lambda functions. We recommend you use the new runtime (dotnet6) while creating or updating functions.
Proposed Solution
The csproj target framework is specified in blueprints: https://github.com/aws/aws-lambda-dotnet/blob/master/PowerShell/Module/Templates/Blueprints/projectfile.csproj.txt#L3
This should be used to call dotnet lambda update-function-config
to set the runtime prior to updating function code.
Other Information
No response
Acknowledgements
- [X] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
AWS .NET SDK and/or Package version used
AWSLambdaPSCore 3.0.1.0
Targeted .NET Platform
.NET 6
Operating System and version
Windows 10
One of the caveat here is if the function runtime is actually supported by Lambda environment. For example, .NET Core 2.1 is no longer supported. Needs review with the team.
Fix should be similar for another related issue https://github.com/aws/aws-lambda-dotnet/issues/476.
This issue cannot be reproduced since it requires an existing Lambda function with a .NET runtime that is no longer supported by Lambda. The same problem was also reported to us for C# based Lambda functions - https://github.com/aws/aws-lambda-dotnet/issues/476.
As outlined by normj's comment, this issue was caused by the fact that Amazon.Lambda.Tools made 2 service calls -- the first call was to update the function code followed by a second call to update the function runtime.
We released a fix for this issue in Amazon.Lambda.Tools that flipped the order of these service calls - https://github.com/aws/aws-extensions-for-dotnet-cli/pull/265.
Since the Publish-AWSPowerShellLambda
cmdlet uses Amazon.Lambda.Tools under the covers, the above fix also applies to PowerShell based Lambda functions.
Closing this issue since it has been fixed via https://github.com/aws/aws-extensions-for-dotnet-cli/pull/265.
⚠️COMMENT VISIBILITY WARNING⚠️
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.