Skip to content

Commit 11d0f13

Browse files
committed
SAM debugconfig: rename "event" to "payload"
1 parent ff93f08 commit 11d0f13

File tree

7 files changed

+27
-26
lines changed

7 files changed

+27
-26
lines changed

designs/sam-debugging/local-sam-debugging.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ The required fields are: type, request, invokeTarget
180180
"invokeTarget": {
181181
"target": "template", // template | code, influences fields expected by toolkit
182182
"templatePath": "path to template yaml file",
183-
"samTemplateResource": "HelloWorldResource" // Name of Template resource to debug
183+
"logicalId": "HelloWorldResource" // Name of Template resource to debug
184184
},
185185
// Lambda Execution related arguments
186186
"lambda": {
@@ -190,7 +190,7 @@ The required fields are: type, request, invokeTarget
190190
"envvar2": "..."
191191
},
192192
// The event passed to the Lambda handler (defaults to an empty JSON object)
193-
"event": {
193+
"payload": {
194194
// path or json, not both
195195
"path": "somepath", // Path to event data
196196
"json": {
@@ -256,7 +256,7 @@ The required fields are: type, request, invokeTarget, lambda.runtime
256256
"envvar2": "..."
257257
},
258258
// The event passed to the Lambda handler (defaults to an empty JSON object)
259-
"event": {
259+
"payload": {
260260
// path or json, not both
261261
"path": "somepath", // Path to event data
262262
"json": {

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,11 @@
238238
},
239239
"type": "object"
240240
},
241-
"event": {
241+
"payload": {
242242
"description": "%AWS.configuration.description.awssam.debug.event%",
243243
"properties": {
244244
"json": {
245+
"description": "%AWS.configuration.description.awssam.debug.event.json%",
245246
"additionalProperties": {
246247
"type": [
247248
"string",
@@ -347,7 +348,7 @@
347348
},
348349
"lambda": {
349350
"runtime": "${2:Lambda Runtime}",
350-
"event": {
351+
"payload": {
351352
"json": {}
352353
}
353354
}
@@ -366,7 +367,7 @@
366367
"logicalId": "${2:Function Logical ID}"
367368
},
368369
"lambda": {
369-
"event": {
370+
"payload": {
370371
"json": {}
371372
}
372373
}

package.nls.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@
7070
"AWS.configuration.description.awssam.debug.aws": "AWS connection details",
7171
"AWS.configuration.description.awssam.debug.credentials": "The AWS credential type and ID to use during the invocation. Example: credential profile \"default\" would be entered as `profile:default`.",
7272
"AWS.configuration.description.awssam.debug.region": "AWS region to use during the invocation.",
73-
"AWS.configuration.description.awssam.debug.event": "The payload to pass to the lambda invocation.\n Must specify one of 'json' or 'path'.",
74-
"AWS.configuration.description.awssam.debug.event.json": "A JSON document to use as the event payload",
75-
"AWS.configuration.description.awssam.debug.event.path": "The path to a file to use as the event payload",
73+
"AWS.configuration.description.awssam.debug.event": "Event payload to pass to the Lambda invocation.\n Must specify one of 'json' or 'path'.",
74+
"AWS.configuration.description.awssam.debug.event.json": "JSON definition to use as the event payload",
75+
"AWS.configuration.description.awssam.debug.event.path": "Path to a file to use as the event payload",
7676
"AWS.configuration.description.awssam.debug.sam": "SAM CLI specific configurations",
7777
"AWS.configuration.description.awssam.debug.buildArguments": "Additional arguments to pass to the `sam build` command.",
7878
"AWS.configuration.description.awssam.debug.containerBuild": "Whether to build inside a container (default: false).",

src/shared/sam/debugger/awsSamDebugConfiguration.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export function createTemplateAwsSamDebugConfig(
123123
logicalId: resourceName,
124124
},
125125
lambda: {
126-
event: {},
126+
payload: {},
127127
environmentVariables: {},
128128
},
129129
}
@@ -134,11 +134,11 @@ export function createTemplateAwsSamDebugConfig(
134134
lambda:
135135
preloadedConfig.environmentVariables || preloadedConfig.eventJson
136136
? {
137-
event: preloadedConfig.eventJson ? { json: preloadedConfig.eventJson } : {},
137+
payload: preloadedConfig.eventJson ? { json: preloadedConfig.eventJson } : {},
138138
environmentVariables: preloadedConfig.environmentVariables,
139139
}
140140
: {
141-
event: {},
141+
payload: {},
142142
environmentVariables: {},
143143
},
144144
sam:
@@ -174,7 +174,7 @@ export function createCodeAwsSamDebugConfig(
174174
},
175175
lambda: {
176176
runtime,
177-
event: {},
177+
payload: {},
178178
environmentVariables: {},
179179
},
180180
}

src/shared/sam/debugger/awsSamDebugConfigurationValidator.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,15 @@ export class DefaultAwsSamDebugConfigurationValidator implements AwsSamDebugConf
207207
}
208208

209209
private validateLambda(config: AwsSamDebuggerConfiguration): ValidationResult {
210-
if (config.lambda?.event?.path) {
211-
const fullpath = tryGetAbsolutePath(this.workspaceFolder, config.lambda?.event?.path)
210+
if (config.lambda?.payload?.path) {
211+
const fullpath = tryGetAbsolutePath(this.workspaceFolder, config.lambda?.payload?.path)
212212
if (!fs.existsSync(fullpath)) {
213213
return {
214214
isValid: false,
215215
message: localize(
216216
'AWS.sam.debugger.missingRuntime',
217217
'Payload file not found: "{0}"',
218-
config.lambda?.event?.path
218+
config.lambda?.payload?.path
219219
),
220220
}
221221
}

src/shared/sam/localLambdaRunner.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,10 +440,10 @@ export async function makeConfig(config: SamLaunchRequestArgs): Promise<void> {
440440
await writeFile(config.envFile, env)
441441

442442
// event.json
443-
if (config.lambda?.event?.path) {
444-
const fullpath = tryGetAbsolutePath(config.workspaceFolder, config.lambda?.event?.path)
443+
if (config.lambda?.payload?.path) {
444+
const fullpath = tryGetAbsolutePath(config.workspaceFolder, config.lambda?.payload?.path)
445445
await copyFile(fullpath, config.eventPayloadFile)
446446
} else {
447-
await writeFile(config.eventPayloadFile, JSON.stringify(config.lambda?.event?.json || {}))
447+
await writeFile(config.eventPayloadFile, JSON.stringify(config.lambda?.payload?.json || {}))
448448
}
449449
}

src/test/shared/sam/debugger/samDebugConfigProvider.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ describe('SamDebugConfigurationProvider', async () => {
380380
},
381381
memoryMb: 1.2,
382382
timeoutSec: 9000,
383-
event: {
383+
payload: {
384384
json: {
385385
'test-payload-key-1': 'test payload value 1',
386386
'test-payload-key-2': 'test payload value 2',
@@ -496,7 +496,7 @@ describe('SamDebugConfigurationProvider', async () => {
496496
},
497497
memoryMb: 1.01,
498498
timeoutSec: 99,
499-
event: {
499+
payload: {
500500
json: {
501501
'test-js-template-key-1': 'test js target=template value 1',
502502
'test-js-template-key-2': 'test js target=template value 2',
@@ -737,7 +737,7 @@ describe('SamDebugConfigurationProvider', async () => {
737737
},
738738
memoryMb: 42,
739739
timeoutSec: 717,
740-
event: {
740+
payload: {
741741
json: {
742742
'test-payload-key-1': 'test payload value 1',
743743
},
@@ -876,7 +876,7 @@ Globals:
876876
},
877877
lambda: {
878878
runtime: 'python3.7',
879-
event: {
879+
payload: {
880880
path: `${appDir}/events/event.json`,
881881
},
882882
},
@@ -942,7 +942,7 @@ Globals:
942942
assertFileText(expected.envFile, '{"awsToolkitSamLocalResource":{}}')
943943
assert.strictEqual(
944944
readFileSync(actual.eventPayloadFile, 'utf-8'),
945-
readFileSync(input.lambda.event.path, 'utf-8')
945+
readFileSync(input.lambda.payload.path, 'utf-8')
946946
)
947947
assertFileText(
948948
expected.templatePath,
@@ -1439,7 +1439,7 @@ describe('createTemplateAwsSamDebugConfig', () => {
14391439
templatePath: templatePath,
14401440
},
14411441
lambda: {
1442-
event: {},
1442+
payload: {},
14431443
environmentVariables: {},
14441444
},
14451445
})
@@ -1456,7 +1456,7 @@ describe('createTemplateAwsSamDebugConfig', () => {
14561456
dockerNetwork: 'rockerFretwork',
14571457
}
14581458
const config = createTemplateAwsSamDebugConfig(undefined, undefined, name, templatePath, params)
1459-
assert.deepStrictEqual(config.lambda?.event?.json, params.eventJson)
1459+
assert.deepStrictEqual(config.lambda?.payload?.json, params.eventJson)
14601460
assert.deepStrictEqual(config.lambda?.environmentVariables, params.environmentVariables)
14611461
assert.strictEqual(config.sam?.dockerNetwork, params.dockerNetwork)
14621462
assert.strictEqual(config.sam?.containerBuild, undefined)

0 commit comments

Comments
 (0)