-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sam local start-api doesn't update on changes #1921
Comments
@fakekamrankhan Did you rebuild after changes? You need to run |
Hmmm, I was under the impression that I could work on an existing function without needing to rebuild:
|
Apologies, I have dug a little further on this github repository and realize this isn't possible for now. Kind of a bummer because it is quite annoying as a development experience to have to constantly build after every change. I believe this is the correct issue for tracking: #921 For now, anyone coming up here for the same confusion, this is what I'm doing to improve my experience in the interim:
I run this in the root folder of my sam application in one terminal and run Closing this issue. |
When looking at this issue, what is reported in the CLI tool Is there an intention to fix this bug? Or was this never intended to work like this in the first place? |
@rpstreef This isn't a bug. The log statement predates build so maybe there is an update to the message but everything is working as intended. |
okay but it's clear this message is causing a lot of confusion. It's updating something else automatically but not the code. That isn't immediately obvious. |
@rpstreef What's your recommendation? Are you interested in submitting a PR with an updated message? |
You need to either update your documentation that actually suggests hot reloading of code does work or you need to implement it: That GIF image clearly demonstrates the hot reloading of code changes. My recommendation is to implement that, or otherwise to just remove the message in the CLI all together. |
I will see if there is a better way to communicate that. We still allow 'hot reloading'. In the gif, there is no build stage happening. The key here is that the 'hot reloading' happens on whatever template is being used by the command. In build cases, this is the generate build template. This is why you can build, start the api, change code, build and invoke without having to tear down the start-api command. In the non build case, it happens just like the gif. Sounds like the confusion stems from using this with build not that we don't support it (because we do). |
This is confusing indeed, but there is a workaround. If the So, instead of bundling my dependencies in the main function, I took a much cleaner approach - bundle my dependencies within a lambda layer. Which should be the first choice in any case. While running the local api, I simply delete the
Also the sam template references the layer that corresponds to the package dependencies:
On a side note, @jfuss I'm new to sam but would like to take this up. I haven't used it enough to get hang of the access patterns, so can you help me with what would be the ideal way to fix this ? |
aws-sam-cli/samcli/commands/local/start_api/cli.py Lines 22 to 25 in 3edb55c
I believe the solution to this would be to not use |
oh wow this is really confusing. What's the correct development workflow for the following situation: I'm building a python lambda function, I start playing around with just the default lambda function adding in code and seeing my changes in real time. I then add another python package in which case I need to run Should I be using a task runner to |
how could i work with libraries in requirements.txt ? Because if i don't use sam build i could not work in this case |
I can confirm it hot reloads if you don't have the build folder there. |
If you are using |
@jfuss there's still a lot of explanation required for this feature, in my opinion this is simply due to unclear documentation. Fix the documentation, and the problem goes away. |
Is there a workaround for Python? |
Same here. Please share if anyone has sorted this. I wonder how |
approach with layers may work for python as well without platform specific wheels in the dependencies: template.yaml:
install dependencies:
update and invoke without running
|
for development purposes wouldn't it be possible to have an option to keep a local docker volume mount that points to a shared folder such as |
I noticed that this does not seem to work when using SAM with an image but does work when using a ZIP. |
Would love something like this |
|
Description
I am using the sample hello-world application on nodejs12.x using
sam init
but when I invokesam build
andsam local start-api
any subsequent changes I make to the lambda function don't update on the port.Steps to reproduce
Inside the
hello-world/app.js
response object I change the message property and save.Observed result
I refresh 127.0.0.1:3000/hello on the browser and nothing changes.
Expected result
I should see the message updated as per how
sam local start-api
is meant to work.Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
sam --version
SAM CLI, version 0.47.0
docker --version
Docker version 19.03.8, build afacb8b
aws --version
aws-cli/1.11.80 Python/2.7.10 Darwin/18.7.0 botocore/1.5.43
The text was updated successfully, but these errors were encountered: