Amazon's SAM CLI does not pick up changes without rebuilding. The documentation SOUNDS like I should not have to start/rebuild/restart every time I make a change to a function. In fact, issuing the sam local start-api
command provides the following message...
You do not need to restart/reload SAM CLI while working on your
functions, changes will be reflected instantly/automatically.
You only need to restart SAM CLI if you update your AWS SAM template.
However, changes are not detected automatically. So, changing this...
const test = async (event, context) => {
const body = JSON.parse(event.body || {});
return toResponse(body);
};
... to this ...
const test = async (event, context) => {
const body = JSON.parse(event.body || {});
body.date = new Date();
return toResponse(body);
};
... should cause the body
variable to include a date
property. Unfortunately, the only way to force this is to stop (CTRL+C
), and then ...
sam build
sam local start-api
This is torture as the sam build
takes almost a minute on a 32GB i7 MacBook Pro.