aws / aws/aws-sam-cli

Allow `sync --watch` to watch files outside the Lambda function CodeUri

Open
#3,819 1 comment 0 reactions 0 assignees View on GitHub
area/accelerate 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 Lambda function code resides outside the `CodeUri`, changes are not synced. For example, using the following directory structure for a go1.x Lambda function, where `cmd/main.go` is the Lambda entrypoint and `mypackage` has additional code, changes in `mypackage` do not trigger a sync event.

```
.
├── cmd
│   └── main.go
├── mypackage
│   └── mypackage.go
├── go.mod
├── go.sum
└── template.yml
```

```yml
# template.yml
...
Resources:
MyFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: cmd
Handler: main
Runtime: go1.x
...
```

In this example, `CodeUri` cannot be set to `./` because the CLI will raise the exception `aws_lambda_builders.workflows.go_modules.builder.BuilderError: Builder Failed: no Go files in `

### Proposal

Add an option accepting multiple values to specify arbitrary additional paths to watch.

```sh
sam sync --stack-name MyStack --watch --watch-paths mypackage,go.mod
or
sam sync --stack-name MyStack --watch --watch-path mypackage --watch-path go.mod
```

### Additional Details

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.