When I run sam cli locally my code changes are not picked up automatically and every time I have to run sam build after every code change.
From the projects main directory run:
sam build
Then execute:
sam local start-api
This will load below directory
~/image-resize-lambda/.aws-sam/build/
But since my main project directory is ~/image-resize-lambda any code changes here are not loaded into the docker container
Any code changes in the parent directory should be readily available in the docker container
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
SAM Template for image resize function
Globals:
Function:
Timeout: 3
Api:
BinaryMediaTypes:
- image~1gif
- image~1png
- image~1jpeg
Resources:
Imageresize:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./
Handler: index.handler
Runtime: nodejs8.10
Events:
Images:
Type: Api
Properties:
Path: /images
Method: get
@publitas-revolution Thank you for the issue. I have seen this a couple times now, so I created an explicit issue for how we are looking to solve this problem: https://github.com/awslabs/aws-sam-cli/issues/921
In that issue, I provided a 'workaround' which can allow you to do the following:
sam buildsam local start-apisam build whenever you have code changes.This will allow you to keep the api up and build when your code changes. This only works as long as the CodeUri doesn't change or new functions/routes are added. I know this workaround doesn't solve the issue but gives a slightly better experience.
I am going to close this in favor of the more specific one I created that we can use to track the implementation.
Just for everyone who ends up at this issue, here is one potential workaround: https://github.com/awslabs/aws-sam-cli/issues/1921#issuecomment-636274872
Most helpful comment
@publitas-revolution Thank you for the issue. I have seen this a couple times now, so I created an explicit issue for how we are looking to solve this problem: https://github.com/awslabs/aws-sam-cli/issues/921
In that issue, I provided a 'workaround' which can allow you to do the following:
sam buildsam local start-apisam buildwhenever you have code changes.This will allow you to keep the api up and build when your code changes. This only works as long as the CodeUri doesn't change or new functions/routes are added. I know this workaround doesn't solve the issue but gives a slightly better experience.
I am going to close this in favor of the more specific one I created that we can use to track the implementation.