Skip to content

Commit 6e974a8

Browse files
authored
fix(sam): allow "AWS::Lambda::Function" when validating #4282
Problem: `validateTemplateConfig()` fails if the given resource is "AWS::Lambda::Function", but: 1. its error message implies that "AWS::Lambda::Function" is allowed 2. 7b5aae7 implies that "AWS::Lambda::Function" is allowed 3. `getResourcesForHandlerFromTemplateDatum()` allows "AWS::Lambda::Function": https://github.com/aws/aws-toolkit-vscode/blob/8704f2cedb065087d7a85c9a9c40fc63d296f8cf/src/shared/fs/templateRegistry.ts#L184 ref #4281 Solution: Update the condition to allow "AWS::Lambda::Function".
1 parent 8704f2c commit 6e974a8

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "SAM local debugging: Toolkit showed SamLaunchRequestError for `AWS::Lambda::Function` template resource"
4+
}

src/shared/sam/debugger/awsSamDebugConfigurationValidator.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@ export class DefaultAwsSamDebugConfigurationValidator implements AwsSamDebugConf
145145
}
146146
}
147147

148-
if (!resources || !Object.keys(resources).includes(templateTarget.logicalId)) {
148+
const resource = resources?.[templateTarget.logicalId]
149+
150+
if (!resource) {
149151
return {
150152
isValid: false,
151153
message: localize(
@@ -157,14 +159,12 @@ export class DefaultAwsSamDebugConfigurationValidator implements AwsSamDebugConf
157159
}
158160
}
159161

160-
const resource = resources[templateTarget.logicalId]
161-
162-
if (resource?.Type !== CloudFormation.SERVERLESS_FUNCTION_TYPE) {
162+
if (![CloudFormation.SERVERLESS_FUNCTION_TYPE, CloudFormation.LAMBDA_FUNCTION_TYPE].includes(resource.Type)) {
163163
return {
164164
isValid: false,
165165
message: localize(
166166
'AWS.sam.debugger.resourceNotAFunction',
167-
'Template Resource {0} in Template file {1} needs to be of type {2} or {3}',
167+
'Template Resource {0} in Template file {1} must be of type {2} or {3}',
168168
templateTarget.logicalId,
169169
templateTarget.templatePath,
170170
CloudFormation.SERVERLESS_FUNCTION_TYPE,

0 commit comments

Comments
 (0)