aws / aws-toolkit-vscode

Amazon Q, CodeCatalyst, Local Lambda debug, SAM/CFN syntax, ECS Terminal, AWS resources
https://marketplace.visualstudio.com/items?itemName=AmazonWebServices.amazon-q-vscode
Apache License 2.0
1.5k stars 427 forks source link

Runtime for Template Resource undefined or unspecified for dotnet8 function #4628

Open boyersnet opened 6 months ago

boyersnet commented 6 months ago

Problem

Unable to launch vscode debugging configuration with dotnet8 lambda function. Function uses Lambda Annotations. Function executes properly when using sam local invoke.

Steps to reproduce the issue

Migrating from existing dotnet6 launch configuration with target: template immediately get the following error:

[ERROR]: SamLaunchRequestError: Invalid launch configuration: Runtime for Template Resource [ResourceId] in Template file [Template Path] is either undefined or unsupported. [BadLaunchConfig]

Launch Config:

{
      "type": "aws-sam",
      "request": "direct-invoke",
      "name": "[DebugProfileName]",
      "aws": {
        "region": "us-east-1",
        "credentials": "profile:[SSO Profile]"
      },
      "invokeTarget": {
        "target": "template",
        "templatePath": "${workspaceFolder}/[path]/template.yaml",
        "logicalId": "[ResourceId]"
      },
      "sam": {
        "skipNewImageCheck": false,
        "localArguments": [
          "--invoke-image",
          "[dotnet8 docker image path to internal repository]"
        ]
      },
      "lambda": {
        "runtime": "dotnet8",
        "pathMappings": [
          {
            "localRoot": "${workspaceFolder}[path]",
            "remoteRoot": "/var/task"
          }
        ],
        "payload": {
          "path": "[path]/events/event.json"
        },
        "environmentVariables": {
          [Various Environment Variables]
        }
      }
    }

Lambda Function

  ResourceId:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: ./src/[FunctionName]/
      Handler: [FunctionName]::[FunctionName].Function_FunctionHandler_Generated::FunctionHandler
      Runtime: dotnet8
      Architectures:
        - x86_64

Expected behavior

Lambda function initializes and the function begins execution, stops at selected breakpoint.

System details (run the AWS: About Toolkit command)

robsmithw commented 1 day ago

Is there any target date for when this will be supported? .NET 6 will be reaching end of support in under a month, November 12, 2024. I am running AWS Toolkit: 3.29.0 and I'm getting the same error.

Here is another launch.json configuration if it will help. I'm also more than happy to provide any additional information that would help.


    {
      "type": "aws-sam",
      "request": "direct-invoke",
      "name": "Rescind Document",
      "invokeTarget": {
        "target": "template",
        "templatePath": "${workspaceFolder}/src/.../template.yaml",
        "logicalId": "RescindDocument"
      },
      "lambda": {
        "payload": {
          "path": "${workspaceFolder}/src/.../DebugAssets/...Event.json"
        },
        "environmentVariables": {}
      }
    }
justinmk3 commented 1 day ago

We'll have updates here soon.