Aws-sam-cli: "sam local start-api" uses .aws-sam directory without warning

Created on 5 Jun 2019  路  3Comments  路  Source: aws/aws-sam-cli

"sam local start-api" worked correctly for starting and testing my api but when I did a "sam build", the "sam local start-api" uses that build without warning. I was changing my project and could not explain for a while why it didn't reflect in my api.

  • "sam init --runtime nodejs10.x"
  • "sam local start-api" -> api should be working
  • "sam build" -> .aws-sam directory created
  • "sam local start-api" uses .aws-sam directory forever instead starting with changes in the template.yaml
  1. OS: Windows
  2. sam --version: 0.17

Edit: it's cool if this is by design, but a warning after "You can now browse to the above endpoints to invoke your functions" would be really good.

Most helpful comment

Hey @jfuss, thanks for the response. Please consider my comment as a user feedback given that this is not considered a bug.

It might be working as designed, but it's a weird user experience. The --help described the functionality as Supports hot-reloading so you don't need to restart this service when you make changes to your function.

There is no mention anywhere that the steps you need to take with 3rd party dependencies are any different to the steps you need to take when you have no external dependencies. And why should be? For me as a user the term "hot reloading" means to see changes after code changes without running any additional actions. If any actions are needed, it makes hot reloading redundant as the same result can be achieved with inotify + sam build && sam local ..

Same goes to the original issue, it's not immediately obvious which code you are running when invoking sam local. I understand this is by design, but the experience is confusing. We are essentially running the same command and getting different experience depending on the structure of the current dir without any feedback from the tool.

Hope I managed to explain our troubles in a sufficient manner. And thanks for taking time to review the ticket.

All 3 comments

I've been caught by this behavior myself few times. It also breaks the hot-reload function of local when trying to develop and check results.

@GerbenRampaart This is by design. We intentionally pick up the build artifacts so you only every have to operate on the source code. Currently, you need to build every time but we have had conversations around introducing a watch option for build and allow building to happen from invoke.

@m1keil This does not break hot-reloading. Hot-reloading means that we mount the CodeUri (and therefore update any changes made to the code) based upon the template. When using sam build with say sam local start-api, you can run build in a different terminal and get the hot-reloading.

Closing as this is by design.

Hey @jfuss, thanks for the response. Please consider my comment as a user feedback given that this is not considered a bug.

It might be working as designed, but it's a weird user experience. The --help described the functionality as Supports hot-reloading so you don't need to restart this service when you make changes to your function.

There is no mention anywhere that the steps you need to take with 3rd party dependencies are any different to the steps you need to take when you have no external dependencies. And why should be? For me as a user the term "hot reloading" means to see changes after code changes without running any additional actions. If any actions are needed, it makes hot reloading redundant as the same result can be achieved with inotify + sam build && sam local ..

Same goes to the original issue, it's not immediately obvious which code you are running when invoking sam local. I understand this is by design, but the experience is confusing. We are essentially running the same command and getting different experience depending on the structure of the current dir without any feedback from the tool.

Hope I managed to explain our troubles in a sufficient manner. And thanks for taking time to review the ticket.

Was this page helpful?
0 / 5 - 0 ratings