Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dotnet lambda package-ci chokes on unquoted AWS::NoValue ref in !If block #209

Open
hauntingEcho opened this issue Apr 13, 2022 · 3 comments
Assignees
Labels
bug This issue is a bug. module/cli-ext p2 This is a standard priority issue queued

Comments

@hauntingEcho
Copy link

Describe the bug

if you use !Ref AWS::NoValue as a possible result of an !If, then dotnet lambda package-ci will fail.

Expected Behavior

template provided in the reproduction steps works with dotnet lambda package-ci

Current Behavior

while aws cloudformation validate-template accepts the file, dotnet lambda package-ci fails with the error:

Unknown error executing command: (Line: 22, Col: 52, Idx: 493) - (Line: 22, Col: 55, Idx: 496): While scanning a plain scalar, find unexpected ':'.
   at YamlDotNet.Core.Scanner.ScanPlainScalar()
   at YamlDotNet.Core.Scanner.FetchPlainScalar()
   at YamlDotNet.Core.Scanner.FetchNextToken()
   at YamlDotNet.Core.Scanner.FetchMoreTokens()
   at YamlDotNet.Core.Scanner.MoveNextWithoutConsuming()
   at YamlDotNet.Core.Parser.GetCurrentToken()
   at YamlDotNet.Core.Parser.ParseFlowSequenceEntry(Boolean isFirst)
   at YamlDotNet.Core.Parser.StateMachine()
   at YamlDotNet.Core.Parser.MoveNext()
   at YamlDotNet.Core.ParserExtensions.Allow[T](IParser parser)
   at YamlDotNet.Core.ParserExtensions.Expect[T](IParser parser)
   at YamlDotNet.RepresentationModel.YamlScalarNode.Load(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlScalarNode..ctor(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlNode.ParseNode(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlSequenceNode.Load(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlSequenceNode..ctor(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlNode.ParseNode(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlMappingNode.Load(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlMappingNode..ctor(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlNode.ParseNode(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlMappingNode.Load(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlMappingNode..ctor(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlNode.ParseNode(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlMappingNode.Load(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlMappingNode..ctor(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlNode.ParseNode(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlMappingNode.Load(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlMappingNode..ctor(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlNode.ParseNode(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlDocument..ctor(IParser parser)
   at YamlDotNet.RepresentationModel.YamlStream.Load(IParser parser)
   at YamlDotNet.RepresentationModel.YamlStream.Load(TextReader input)
   at Amazon.Lambda.Tools.TemplateProcessor.TemplateProcessorManager.CreateTemplateParser(String templateBody) in C:\codebuild\tmp\output\src933647099\src\src\Amazon.Lambda.Tools\TemplateProcessor\TemplateProce
ssorManager.cs:line 380
   at Amazon.Lambda.Tools.TemplateProcessor.TemplateProcessorManager.TransformTemplateAsync(String templateDirectory, String templateBody, String[] args) in C:\codebuild\tmp\output\src933647099\src\src\Amazon.L
ambda.Tools\TemplateProcessor\TemplateProcessorManager.cs:line 80
   at Amazon.Lambda.Tools.Commands.PackageCICommand.PerformActionAsync() in C:\codebuild\tmp\output\src933647099\src\src\Amazon.Lambda.Tools\Commands\PackageCICommand.cs:line 131
   at Amazon.Common.DotNetCli.Tools.Commands.BaseCommand`1.ExecuteAsync() in C:\codebuild\tmp\output\src933647099\src\src\Amazon.Common.DotNetCli.Tools\Commands\BaseCommand.cs:line 46

Reproduction Steps

Using serverless.yaml:

AWSTemplateFormatVersion: 2010-09-09
Parameters:
  LambdaExecutionRoleArn:
    Type: String

    
Conditions:
  trueCondition: !Equals
    - a
    - a

Resources:
  GetAuthz:
    Type: AWS::Lambda::Function
    Properties:
      Timeout: 30
      Runtime: dotnet6
      MemorySize: 2048
      TracingConfig:
        Mode: Active
      Handler: APIGatewayAuthorizerHandler::APIGatewayAuthorizerHandler.Authorizer::Execute
      Description: !If [trueCondition, aaaaa, !Ref AWS::NoValue]
      Role: !Ref LambdaExecutionRoleArn

and aws-lambda-tools-defaults.json:

{
  "Information": [
    "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.",
    "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.",
    "dotnet lambda help",
    "All the command line options for the Lambda command can be specified in this file.",
  ],
  "configuration": "Release",
  "framework": "net6.0",
  "output-template": "compiled.yml",
  "template": "serverless.yaml",
  "s3-prefix": "serverless/",
  "region": "us-east-1"
}

call dotnet lambda package-ci -sb ${bucket} (using a ${bucket} that you can write to)

Possible Solution

Temporary workaround: adding quotes around "AWS::NoValue" makes the utility accept it.

Additional Information/Context

No response

Targeted .NET platform

6

CLI extension version

5.1.4

Environment details (OS name and version, etc.)

Windows 10

@hauntingEcho hauntingEcho added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 13, 2022
@hauntingEcho
Copy link
Author

Also applies to AWS::StackName

@ashishdhingra
Copy link
Contributor

@hauntingEcho Although unsure, you might be affected by the issue #116. If yes, please close this a duplicate.

@ashishdhingra ashishdhingra removed the needs-triage This issue or PR still needs to be triaged. label Apr 14, 2022
@hauntingEcho
Copy link
Author

My understanding is that 116 only affects the --template-substitutions command-line parameter, which I am not using. This issue is when using CloudFormation's pseudo-parameters

@ashishdhingra ashishdhingra added queued p2 This is a standard priority issue and removed B labels Nov 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. module/cli-ext p2 This is a standard priority issue queued
Projects
None yet
Development

No branches or pull requests

3 participants