@@ -38,6 +38,7 @@ import { asEnvironmentVariables } from '../../credentials/credentialsUtilities'
38
38
import { SamCliInfoInvocation } from './cli/samCliInfo'
39
39
import { parse } from 'semver'
40
40
import { isAutomation } from '../vscode/env'
41
+ import { getOverriddenParameters } from '../../lambda/config/parameterUtils'
41
42
42
43
export interface SyncParams {
43
44
readonly region : string
@@ -320,11 +321,32 @@ async function runSyncInTerminal(proc: ChildProcess) {
320
321
}
321
322
}
322
323
324
+ async function loadLegacyParameterOverrides ( template : TemplateItem ) {
325
+ try {
326
+ const params = await getOverriddenParameters ( template . uri )
327
+ if ( ! params ) {
328
+ return
329
+ }
330
+
331
+ return [ ...params . entries ( ) ] . map ( ( [ k , v ] ) => `${ k } =${ v } ` )
332
+ } catch ( err ) {
333
+ getLogger ( ) . warn ( `sam: unable to load legacy parameter overrides: %s` , err )
334
+ }
335
+ }
336
+
323
337
export async function runSamSync ( args : SyncParams ) {
324
338
telemetry . record ( { lambdaPackageType : args . ecrRepoUri !== undefined ? 'Image' : 'Zip' } )
325
339
326
340
const samCliPath = await getSamCliPath ( )
327
341
const { boundArgs } = await saveAndBindArgs ( args )
342
+ const overrides = await loadLegacyParameterOverrides ( args . template )
343
+ if ( overrides !== undefined ) {
344
+ // Leaving this out of the definitions file as this is _very_ niche and specific to the
345
+ // implementation. Plus we would have to redefine `sam_sync` to add it.
346
+ telemetry . record ( { isUsingTemplatesJson : true } as any )
347
+ boundArgs . push ( '--parameter-overrides' , ...overrides )
348
+ }
349
+
328
350
const sam = new ChildProcess ( samCliPath , [ 'sync' , ...boundArgs ] , {
329
351
spawnOptions : {
330
352
cwd : args . projectRoot . fsPath ,
0 commit comments