Skip to content

Commit ecff24e

Browse files
Merge master into feature/console-session-profile
2 parents 52f40c2 + 08e23a1 commit ecff24e

File tree

3 files changed

+89
-25
lines changed

3 files changed

+89
-25
lines changed

packages/core/src/lambda/vue/remoteInvoke/invokeLambda.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,13 @@ export class RemoteInvokeWebview extends VueWebview {
272272
qualifier = RemoteDebugController.instance.qualifier
273273
}
274274

275+
const isLMI = (this.data.LambdaFunctionNode?.configuration as any)?.CapacityProviderConfig
276+
const isDurable = (this.data.LambdaFunctionNode?.configuration as any)?.DurableConfig
277+
if (isDurable && !qualifier) {
278+
// Make sure to invoke with qualifier for Durable Function, invoking unqualified will fail
279+
qualifier = isLMI ? '$LATEST.PUBLISHED' : '$LATEST'
280+
}
281+
275282
this.isInvoking = true
276283

277284
// If debugging is active, reset the timer during invoke
@@ -284,7 +291,7 @@ export class RemoteInvokeWebview extends VueWebview {
284291
await telemetry.lambda_invokeRemote.run(async (span) => {
285292
try {
286293
let funcResponse
287-
const isLMI = (this.data.LambdaFunctionNode?.configuration as any)?.CapacityProviderConfig
294+
288295
if (remoteDebugEnabled) {
289296
funcResponse = await this.clientDebug.invoke(this.data.FunctionArn, input, qualifier)
290297
} else if (isLMI) {
@@ -313,6 +320,7 @@ export class RemoteInvokeWebview extends VueWebview {
313320
this.channel.appendLine('')
314321
} finally {
315322
let action = remoteDebugEnabled ? 'debug' : 'invoke'
323+
action = `${action}${isDurable ? '-durable' : ''}${isLMI ? '-lmi' : ''}`
316324
if (!this.data.isLambdaRemote) {
317325
action = `${action}LocalStack`
318326
}

packages/core/src/test/lambda/vue/remoteInvoke/remoteInvoke.test.ts

Lines changed: 76 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,6 @@ describe('RemoteInvokeWebview', function () {
1818
const mockData = {
1919
FunctionArn: 'arn:aws:lambda:us-west-2:123456789012:function:my-function',
2020
} as any
21-
const mockDataLMI = {
22-
FunctionArn: 'arn:aws:lambda:us-west-2:123456789012:function:my-function',
23-
LambdaFunctionNode: {
24-
configuration: {
25-
CapacityProviderConfig: {
26-
blah: 'blah',
27-
},
28-
},
29-
},
30-
} as any
3121
const input = '{"key": "value"}'
3222
const mockResponse = {
3323
LogResult: Buffer.from('Test log').toString('base64'),
@@ -46,21 +36,83 @@ describe('RemoteInvokeWebview', function () {
4636
afterEach(() => {
4737
sinon.restore()
4838
})
49-
it('should invoke with a simple payload', async function () {
50-
const remoteInvokeWebview = new RemoteInvokeWebview(outputChannel, client, client, mockData)
51-
client.invoke.resolves(mockResponse)
52-
await remoteInvokeWebview.invokeLambda(input)
53-
sinon.assert.calledOnce(client.invoke)
54-
sinon.assert.calledWith(client.invoke, mockData.FunctionArn, input, undefined, 'Tail')
55-
})
39+
const invokeScenarios: {
40+
name: string
41+
data: any
42+
expectedQualifier: string | undefined
43+
expectedLogType: 'Tail' | 'None'
44+
}[] = [
45+
{
46+
name: 'should invoke with a simple payload',
47+
data: mockData,
48+
expectedQualifier: undefined,
49+
expectedLogType: 'Tail',
50+
},
51+
{
52+
name: 'should invoke with no tail in LMI',
53+
data: {
54+
FunctionArn: 'arn:aws:lambda:us-west-2:123456789012:function:my-function',
55+
LambdaFunctionNode: {
56+
configuration: {
57+
CapacityProviderConfig: {
58+
blah: 'blah',
59+
},
60+
},
61+
},
62+
},
63+
expectedQualifier: undefined,
64+
expectedLogType: 'None',
65+
},
66+
{
67+
name: 'should invoke $LATEST in Durable Function',
68+
data: {
69+
FunctionArn: 'arn:aws:lambda:us-west-2:123456789012:function:my-function',
70+
LambdaFunctionNode: {
71+
configuration: {
72+
DurableConfig: {
73+
blah: 'blah',
74+
},
75+
},
76+
},
77+
},
78+
expectedQualifier: '$LATEST',
79+
expectedLogType: 'Tail',
80+
},
81+
{
82+
name: 'should invoke $LATEST.PUBLISHED in LMI Durable Function',
83+
data: {
84+
FunctionArn: 'arn:aws:lambda:us-west-2:123456789012:function:my-function',
85+
LambdaFunctionNode: {
86+
configuration: {
87+
DurableConfig: {
88+
blah: 'blah',
89+
},
90+
CapacityProviderConfig: {
91+
blah: 'blah',
92+
},
93+
},
94+
},
95+
},
96+
expectedQualifier: '$LATEST.PUBLISHED',
97+
expectedLogType: 'None',
98+
},
99+
]
56100

57-
it('should invoke with no tail in LMI', async function () {
58-
const remoteInvokeWebview = new RemoteInvokeWebview(outputChannel, client, client, mockDataLMI)
59-
client.invoke.resolves(mockResponse)
60-
await remoteInvokeWebview.invokeLambda(input)
61-
sinon.assert.calledOnce(client.invoke)
62-
sinon.assert.calledWith(client.invoke, mockData.FunctionArn, input, undefined, 'None')
63-
})
101+
for (const scenario of invokeScenarios) {
102+
it(scenario.name, async function () {
103+
const remoteInvokeWebview = new RemoteInvokeWebview(outputChannel, client, client, scenario.data)
104+
client.invoke.resolves(mockResponse)
105+
await remoteInvokeWebview.invokeLambda(input)
106+
sinon.assert.calledOnce(client.invoke)
107+
sinon.assert.calledWith(
108+
client.invoke,
109+
scenario.data.FunctionArn,
110+
input,
111+
scenario.expectedQualifier,
112+
scenario.expectedLogType
113+
)
114+
})
115+
}
64116

65117
const mockEvent = {
66118
name: 'TestEvent',
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Feature",
3+
"description": "Lambda Remote Invoke panel now supports invoking Lambda durable functions"
4+
}

0 commit comments

Comments
 (0)