Skip to content

Commit 1c2a80a

Browse files
Merge master into feature/emr
2 parents 8416a91 + 57fa1d6 commit 1c2a80a

File tree

4 files changed

+116
-177
lines changed

4 files changed

+116
-177
lines changed

packages/core/src/shared/sam/cli/samCliLocalInvoke.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ import globals from '../../extensionGlobals'
1515
import { SamCliSettings } from './samCliSettings'
1616
import { addTelemetryEnvVar, collectSamErrors, SamCliError } from './samCliInvokerUtils'
1717
import { fs } from '../../fs/fs'
18+
import { Runtime } from 'aws-sdk/clients/lambda'
19+
import { getSamCliPathAndVersion } from '../utils'
20+
import { deprecatedRuntimes } from '../../../lambda/models/samLambdaRuntime'
1821

1922
const localize = nls.loadMessageBundle()
2023

@@ -217,6 +220,8 @@ export interface SamCliLocalInvokeInvocationArguments {
217220
name?: string
218221
/** AWS region */
219222
region?: string
223+
/** Overrides the template-specified runtime. */
224+
runtime?: Runtime
220225
}
221226

222227
/**
@@ -266,6 +271,17 @@ export class SamCliLocalInvokeInvocation {
266271
)
267272
invokeArgs.push(...(this.args.extraArgs ?? []))
268273

274+
// Get samcli version
275+
const { parsedVersion } = await getSamCliPathAndVersion()
276+
277+
// '--runtime' option for sam local invoke is only available in SAM CLI 1.135.0 and later
278+
if ((parsedVersion?.compare('1.135.0') ?? -1) >= 0) {
279+
// check if the runtime is valid (not deprecated)
280+
if (this.args.runtime && !deprecatedRuntimes.has(this.args.runtime)) {
281+
pushIf(invokeArgs, true, '--runtime', this.args.runtime)
282+
}
283+
}
284+
269285
return await this.args.invoker.invoke({
270286
options: {
271287
env: {

packages/core/src/shared/sam/localLambdaRunner.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ async function invokeLambdaHandler(
247247
parameterOverrides: config.parameterOverrides,
248248
name: config.name,
249249
region: config.region,
250+
runtime: config.lambda?.runtime,
250251
}
251252

252253
// sam local invoke ...

0 commit comments

Comments
 (0)