SAM run/debug: eliminate temporary directory
Problem
Toolkit currently always builds and runs from a temporary /tmp/vstck-xx directory. This confuses tooling and may defeat SAM CLI "cache" functionality.
- #1988
- #2024
Reason for the temporary directory:
- we wanted to avoid building artifacts into the user's workspace (which then might be accidentally committed)
Related notes:
- A similar but not identical concept is that Toolkit copies the actual
template.yamlto a temporary counterpart.- #1159
- #990
Proposal
- what does aws-toolkit-jetbrains do?
- Switch to building in the user's workspace.
- auto-add to
.git/info/excludes?
- auto-add to
- in
.aws-sam/directory?- Bonus: works better with
saminvocations outside of the Toolkit
- Bonus: works better with
- Strategy: instead of "temp dir per execution", change the model to "temp dir per template"?
Alternative:
- Mostly keep the same logic, but always re-use the same
/tmp/vstck-xxdirectory for the sametemplate.yaml- risk: does this complicate the logic that maps the temporary template.yaml from the actual template.yaml ? #1159
Alternative:
- are we passing the temporary as
--build-dircorrectly? Maybe this will avoid needing to remap the paths in the temporary template.yaml #1159 #990 ?
This would be amazing. We wait over two minutes every time we invoke a function because the cache is wiped out. Super frustrating when trying to develop.
@justinmk3 Regarding JetBrains, we experience the same problem.
The next release (1.30.0) will include a way to set a directory via a buildDir field in the launch config (under "sam")
Example config:
"type": "aws-sam",
"request": "direct-invoke",
"name": "lambda-go1.x:HelloWorldFunction (go1.x)",
"invokeTarget": {
"target": "template",
"templatePath": "${workspaceFolder}/lambda-go1.x/template.yaml",
"logicalId": "HelloWorldFunction"
},
"lambda": {
"payload": {},
"environmentVariables": {},
"runtime": "go1.x"
},
"sam": {
"buildDir": "${workspaceFolder}/buildDir"
}
https://github.com/aws/aws-toolkit-vscode/pull/2755 mitigates some issues with the temporary directory by setting the process working directory.