aws / aws/aws-sam-cli

watch Option for SAM Build command

Open
#921 47 comments 165 reactions 0 assignees View on GitHub
area/build area/local type/feature
Dominant language
Python
Stars
6.7k
Forks
1.2k
Avg merge
1d 10h
Merged PRs (30d)
52

Description

### Describe your idea/feature/enhancement

When using `sam build` to build functions that will later be invoked through `sam local [invoke|start-lambda|start-api]`, you need to run `sam build` before each invoke. The reason for this requirement is because the build command places artifacts (code + dependencies + updated template) into a build folder. The `sam local [invoke|start-lambda|start-api]` use these built templates (this has updated locations to the built function code) by default but there is no way to update the built code without running `sam build` again.

### Proposal

For the initial implementation of `sam build`, the `--watch` option [was out of scope](https://github.com/awslabs/aws-sam-cli/blob/develop/designs/sam_build_cmd.md#out-of-scope). The proposal is to add support for this option to all customers to enable building when source code changes.

An alternative could be to make the `sam local` suite of commands build the function during invoke. The main concern with this is the speed at which you can now invoke (other build enhancements might be a requirement for this, speed, incremental builds, etc).

### Workaround

All of the `sam local` command allow 'reloading' of the function code. This means for a given template, if you update the contents of a functions Code/CodeUri, SAM CLI will mount this updated content. So the current option for making interactions easier is to have two terminal windows open, one that builds and one that you local invoke with.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.