Skip to content

Commit c1b76df

Browse files
authored
fix(lambda): drop template path from sam deploy command #5912
## Problem Explicitly specifying template path in sam deploy command to point to the build artifact folder makes SAM CLI create/update `samconfig.toml` in the build artifact folder rather than updating the `samconfig.toml` file in project root folder. ## Solution Remove the `--template-path` from deploy flag. SAM will determine the template in the project folder and write to correct samconfig file
1 parent 65d0e93 commit c1b76df

File tree

4 files changed

+4
-12
lines changed

4 files changed

+4
-12
lines changed

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,6 @@ export async function runDeploy(arg: any, wizardParams?: DeployParams): Promise<
377377
throw ToolkitError.chain(error, 'Failed to build SAM template', { details: { ...buildFlags } })
378378
}
379379

380-
// Pass built template to deployFlags
381-
const templatePath = vscode.Uri.joinPath(params.projectRoot, '.aws-sam', 'build', 'template.yaml').fsPath
382-
deployFlags.push('--template-file', `${templatePath}`)
383-
384380
// Create a child process to run the SAM deploy command
385381
const deployProcess = new ChildProcess(samCliPath, ['deploy', ...deployFlags], {
386382
spawnOptions: await addTelemetryEnvVar({

packages/core/src/test/shared/sam/deploy.test.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -709,8 +709,6 @@ describe('SAM Deploy', () => {
709709
'--parameter-overrides',
710710
`ParameterKey=SourceBucketName,ParameterValue=${mockDeployParams.SourceBucketName} ` +
711711
`ParameterKey=DestinationBucketName,ParameterValue=${mockDeployParams.DestinationBucketName}`,
712-
'--template-file',
713-
vscode.Uri.joinPath(projectRoot, '.aws-sam', 'build', 'template.yaml').fsPath,
714712
],
715713
{
716714
spawnOptions: {
@@ -787,8 +785,6 @@ describe('SAM Deploy', () => {
787785
'--parameter-overrides',
788786
`ParameterKey=SourceBucketName,ParameterValue=${mockDeployParams.SourceBucketName} ` +
789787
`ParameterKey=DestinationBucketName,ParameterValue=${mockDeployParams.DestinationBucketName}`,
790-
'--template-file',
791-
vscode.Uri.joinPath(projectRoot, '.aws-sam', 'build', 'template.yaml').fsPath,
792788
],
793789
{
794790
spawnOptions: {
@@ -867,8 +863,6 @@ describe('SAM Deploy', () => {
867863
'--parameter-overrides',
868864
`ParameterKey=SourceBucketName,ParameterValue=${mockDeployParams.SourceBucketName} ` +
869865
`ParameterKey=DestinationBucketName,ParameterValue=${mockDeployParams.DestinationBucketName}`,
870-
'--template-file',
871-
vscode.Uri.joinPath(projectRoot, '.aws-sam', 'build', 'template.yaml').fsPath,
872866
],
873867
{
874868
spawnOptions: {

packages/core/src/testInteg/sam.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -883,8 +883,6 @@ describe('SAM Integration Tests', async function () {
883883
'--capabilities',
884884
'CAPABILITY_IAM',
885885
'CAPABILITY_NAMED_IAM',
886-
'--template-file',
887-
vscode.Uri.joinPath(mockDeployParams.projectRoot, '.aws-sam', 'build', 'template.yaml').fsPath,
888886
])
889887

890888
// Check that runInTerminal is called with the correct arguments for deploy
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: Save SAM deploy parameters to correct samconfig.toml in project folder"
4+
}

0 commit comments

Comments
 (0)