aws / aws-extensions-for-dotnet-cli

Extensions to the dotnet CLI to simplify the process of building and publishing .NET Core applications to AWS services
Apache License 2.0
369 stars 86 forks source link

Error while deploying code using CICD #277

Closed HemishGarden closed 1 year ago

HemishGarden commented 1 year ago

Describe the bug

~/.dotnet/tools/dotnet-lambda deploy-serverless --template ./template.yaml

Error image

2023-04-19T09:23:46.9788260Z Unknown error executing command: The given key 'Properties' was not present in the dictionary. 2023-04-19T09:23:46.9967789Z at System.Collections.Generic.Dictionary2.get_Item(TKey key) 2023-04-19T09:23:46.9969437Z at Amazon.Lambda.Tools.TemplateProcessor.YamlTemplateParser.UpdatableResources()+MoveNext() in E:\JenkinsWorkspaces\aws-extensions-for-dotnet-cli\src\Amazon.Lambda.Tools\TemplateProcessor\YamlTemplateParser.cs:line 50 2023-04-19T09:23:46.9971311Z at Amazon.Lambda.Tools.TemplateProcessor.TemplateProcessorManager.TransformTemplateAsync(String templateDirectory, String templateBody) in E:\JenkinsWorkspaces\aws-extensions-for-dotnet-cli\src\Amazon.Lambda.Tools\TemplateProcessor\TemplateProcessorManager.cs:line 72 2023-04-19T09:23:46.9973814Z at Amazon.Lambda.Tools.Commands.DeployServerlessCommand.PerformActionAsync() in E:\JenkinsWorkspaces\aws-extensions-for-dotnet-cli\src\Amazon.Lambda.Tools\Commands\DeployServerlessCommand.cs:line 167 2023-04-19T09:23:46.9975321Z at Amazon.Common.DotNetCli.Tools.Commands.BaseCommand1.ExecuteAsync() in E:\JenkinsWorkspaces\aws-extensions-for-dotnet-cli\src\Amazon.Common.DotNetCli.Tools\Commands\BaseCommand.cs:line 44 2023-04-19T09:23:47.0089355Z ##[error]Error: The process '/bin/bash' failed with exit code 255

Expected Behavior

It was deploying without error when I deployed in Feb

Current Behavior

Throwing error

2023-04-19T09:23:46.9788260Z Unknown error executing command: The given key 'Properties' was not present in the dictionary. 2023-04-19T09:23:46.9967789Z at System.Collections.Generic.Dictionary2.get_Item(TKey key) 2023-04-19T09:23:46.9969437Z at Amazon.Lambda.Tools.TemplateProcessor.YamlTemplateParser.UpdatableResources()+MoveNext() in E:\JenkinsWorkspaces\aws-extensions-for-dotnet-cli\src\Amazon.Lambda.Tools\TemplateProcessor\YamlTemplateParser.cs:line 50 2023-04-19T09:23:46.9971311Z at Amazon.Lambda.Tools.TemplateProcessor.TemplateProcessorManager.TransformTemplateAsync(String templateDirectory, String templateBody) in E:\JenkinsWorkspaces\aws-extensions-for-dotnet-cli\src\Amazon.Lambda.Tools\TemplateProcessor\TemplateProcessorManager.cs:line 72 2023-04-19T09:23:46.9973814Z at Amazon.Lambda.Tools.Commands.DeployServerlessCommand.PerformActionAsync() in E:\JenkinsWorkspaces\aws-extensions-for-dotnet-cli\src\Amazon.Lambda.Tools\Commands\DeployServerlessCommand.cs:line 167 2023-04-19T09:23:46.9975321Z at Amazon.Common.DotNetCli.Tools.Commands.BaseCommand1.ExecuteAsync() in E:\JenkinsWorkspaces\aws-extensions-for-dotnet-cli\src\Amazon.Common.DotNetCli.Tools\Commands\BaseCommand.cs:line 44 2023-04-19T09:23:47.0089355Z ##[error]Error: The process '/bin/bash' failed with exit code 255

Reproduction Steps

deploy lambda using ~/.dotnet/tools/dotnet-lambda deploy-serverless --template ./template.yaml

Possible Solution

No response

Additional Information/Context

No response

Targeted .NET platform

.Net 3.1 and 6.0

CLI extension version

Amazon Lambda Tools for .NET Core applications (3.1.0)

Environment details (OS name and version, etc.)

windows-latest

ashishdhingra commented 1 year ago

Hi @HemishGarden,

Good morning.

Could you please share the sample code solution including the template.yaml to reproduce the issue? Also, I noticed that you are using very old version 3.1.0 Amazon Lambda Tools, the current version is 5.6.6. Any specific reason or bottleneck for not upgrading to later version?

Thanks, Ashish

HemishGarden commented 1 year ago

Hi @ashishdhingra , This is a medium size project so it's hard to send you the code. Regarding the Yaml file, it contains infrastructure details so, can't share the file aswell. I am trying to upgrade from 3.1.0 to 5.6.6. That's when I hit this error. I rolled back to 3.1.0 and I still see the same errors. Something has changed since early this year with this lib.

Please let me know if you need any specific details, I can provide that to you.

Thanks

HemishGarden commented 1 year ago

Hi @ashishdhingra ,

This is my pipeline yaml file.

trigger: batch: true branches: include:

pool: vmImage: 'windows-latest'

steps:

ashishdhingra commented 1 year ago

@HemishGarden Since you are using Amazon.Lambda.Tools version 3.1.0, it is most likely the commit source https://github.com/aws/aws-extensions-for-dotnet-cli/tree/1305565941f1409d9f8e445b023b741dab5fe417/src. Looking at the stack trace of the error, it is most likely thrown at this line where it is inspecting updatable resource properties. A serverless resource should define set of Properties in YAML template (refer AWS SAM resource and property reference). It is quite possible that one of your resources is missing Properties information which is throwing this error. Kindly note that a YAML template must be properly indented for YAML parser to process it properly.

Please use guidance above to investigate your YAML template.

Thanks, Ashish

github-actions[bot] commented 1 year ago

This issue has not received a response in 5 days. If you want to keep this issue open, please just leave a comment below and auto-close will be canceled.