When using the --template parameter together with --warm-containers using sam local start-api, the CLI gets stuck at this message and the container never starts:
Mounting /Users/viljamikuosmanen/sam-app as /var/task:ro,delegated inside runtime container
Initialise a fresh project using the nodejs12.x quick-start-web template:
$ sam init
...
-----------------------
Generating application:
-----------------------
Name: sam-app
Runtime: nodejs12.x
Dependency Manager: npm
Application Template: quick-start-web
Output Directory: .
Attempt to start the local api supplying the --template flag in order to mount the whole directory:
$ cd sam-app
$ sam build
$ sam local start-api --warm-containers EAGER --template template.yml --debug
Command output:
2020-12-30 14:39:12,050 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2020-12-30 14:39:12,137 | local start-api command is called
2020-12-30 14:39:12,151 | No Parameters detected in the template
2020-12-30 14:39:12,175 | 6 resources found in the template
2020-12-30 14:39:12,175 | Found Serverless function with name='getAllItemsFunction' and CodeUri='.'
2020-12-30 14:39:12,175 | Found Serverless function with name='getByIdFunction' and CodeUri='.'
2020-12-30 14:39:12,175 | Found Serverless function with name='putItemFunction' and CodeUri='.'
2020-12-30 14:39:12,180 | Initializing the lambda functions containers.
2020-12-30 14:39:12,180 | Async execution started
2020-12-30 14:39:12,180 | Invoking function functools.partial(<function InvokeContext._initialize_all_functions_containers.<locals>.initialize_function_container at 0x1072efa60>, Function(name='getAllItemsFunction', functionname='getAllItemsFunction', runtime='nodejs12.x', memory=128, timeout=100, handler='src/handlers/get-all-items.getAllItemsHandler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='.', environment={'Variables': {'SAMPLE_TABLE': 'SampleTable'}}, rolearn=None, layers=[], events={'Api': {'Type': 'HttpApi', 'Properties': {'ApiId': 'ServerlessHttpApi', 'Path': '$default', 'Method': 'x-amazon-apigateway-any-method'}}}, metadata=None, codesign_config_arn=None))
2020-12-30 14:39:12,181 | Invoking function functools.partial(<function InvokeContext._initialize_all_functions_containers.<locals>.initialize_function_container at 0x1072efa60>, Function(name='getByIdFunction', functionname='getByIdFunction', runtime='nodejs12.x', memory=128, timeout=100, handler='src/handlers/get-by-id.getByIdHandler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='.', environment={'Variables': {'SAMPLE_TABLE': 'SampleTable'}}, rolearn=None, layers=[], events={'Api': {'Type': 'Api', 'Properties': {'Path': '/{id}', 'Method': 'GET', 'RestApiId': 'ServerlessRestApi'}}}, metadata=None, codesign_config_arn=None))
2020-12-30 14:39:12,181 | Invoking function functools.partial(<function InvokeContext._initialize_all_functions_containers.<locals>.initialize_function_container at 0x1072efa60>, Function(name='putItemFunction', functionname='putItemFunction', runtime='nodejs12.x', memory=128, timeout=100, handler='src/handlers/put-item.putItemHandler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='.', environment={'Variables': {'SAMPLE_TABLE': 'SampleTable'}}, rolearn=None, layers=[], events={'Api': {'Type': 'Api', 'Properties': {'Path': '/', 'Method': 'POST', 'RestApiId': 'ServerlessRestApi'}}}, metadata=None, codesign_config_arn=None))
2020-12-30 14:39:12,182 | Environment variables overrides data is standard format
2020-12-30 14:39:12,182 | Waiting for async results
2020-12-30 14:39:12,182 | Loading AWS credentials from session with profile 'None'
2020-12-30 14:39:12,183 | Environment variables overrides data is standard format
2020-12-30 14:39:12,188 | Environment variables overrides data is standard format
2020-12-30 14:39:12,191 | Loading AWS credentials from session with profile 'None'
2020-12-30 14:39:12,191 | Loading AWS credentials from session with profile 'None'
2020-12-30 14:39:12,211 | Resolving code path. Cwd=/Users/viljamikuosmanen/sam-app, CodeUri=.
2020-12-30 14:39:12,212 | Resolving code path. Cwd=/Users/viljamikuosmanen/sam-app, CodeUri=.
2020-12-30 14:39:12,212 | Resolved absolute path to code is /Users/viljamikuosmanen/sam-app
2020-12-30 14:39:12,213 | Resolved absolute path to code is /Users/viljamikuosmanen/sam-app
2020-12-30 14:39:12,213 | Code /Users/viljamikuosmanen/sam-app is not a zip/jar file
2020-12-30 14:39:12,214 | Code /Users/viljamikuosmanen/sam-app is not a zip/jar file
2020-12-30 14:39:12,216 | Resolving code path. Cwd=/Users/viljamikuosmanen/sam-app, CodeUri=.
2020-12-30 14:39:12,216 | Resolved absolute path to code is /Users/viljamikuosmanen/sam-app
2020-12-30 14:39:12,217 | Code /Users/viljamikuosmanen/sam-app is not a zip/jar file
2020-12-30 14:39:12,244 | Skip pulling image and use local one: amazon/aws-sam-cli-emulation-image-nodejs12.x:rapid-1.15.0.
2020-12-30 14:39:12,244 | Mounting /Users/viljamikuosmanen/sam-app as /var/task:ro,delegated inside runtime container
2020-12-30 14:39:12,245 | Skip pulling image and use local one: amazon/aws-sam-cli-emulation-image-nodejs12.x:rapid-1.15.0.
2020-12-30 14:39:12,245 | Mounting /Users/viljamikuosmanen/sam-app as /var/task:ro,delegated inside runtime container
2020-12-30 14:39:12,246 | Skip pulling image and use local one: amazon/aws-sam-cli-emulation-image-nodejs12.x:rapid-1.15.0.
2020-12-30 14:39:12,246 | Mounting /Users/viljamikuosmanen/sam-app as /var/task:ro,delegated inside runtime container
SAM CLI gets stuck and the container gets created but never started.
Starting with --warm-containers LAZY starts the local API but runtime containers fail to start when requested.
Without the --template parameter, the local api works as expected.
I expected the runtime container to mount my local project directory and the local api to be exposed at port 3000.
Mac OS Catalina 10.15.7SAM CLI, version 1.15.0Docker version 20.10.0, build 7287ab3I was not able to reproduce this issue.
These are the steps I followed:
% sam init
Which template source would you like to use?
1 - AWS Quick Start Templates
2 - Custom Template Location
Choice: 1
What package type would you like to use?
1 - Zip (artifact is a zip uploaded to S3)
2 - Image (artifact is an image uploaded to an ECR image repository)
Package type: 1
Which runtime would you like to use?
1 - nodejs12.x
2 - python3.8
3 - ruby2.7
4 - go1.x
5 - java11
6 - dotnetcore3.1
7 - nodejs10.x
8 - python3.7
9 - python3.6
10 - python2.7
11 - ruby2.5
12 - java8.al2
13 - java8
14 - dotnetcore2.1
Runtime: 1
Project name [sam-app]: test
Cloning app templates from https://github.com/aws/aws-sam-cli-app-templates
AWS quick start application templates:
1 - Hello World Example
2 - Step Functions Sample App (Stock Trader)
3 - Quick Start: From Scratch
4 - Quick Start: Scheduled Events
5 - Quick Start: S3
6 - Quick Start: SNS
7 - Quick Start: SQS
8 - Quick Start: Web Backend
Template selection: 8
-----------------------
Generating application:
-----------------------
Name: test
Runtime: nodejs12.x
Dependency Manager: npm
Application Template: quick-start-web
Output Directory: .
Next steps can be found in the README file at ./test/README.md
% aws configure
AWS Access Key ID [********************]:
AWS Secret Access Key [********************]:
Default region name [us-west-2]:
Default output format [None]:
% cd test
% sam build
Building codeuri: . runtime: nodejs12.x metadata: {} functions: ['getAllItemsFunction', 'getByIdFunction', 'putItemFunction']
Running NodejsNpmBuilder:NpmPack
Running NodejsNpmBuilder:CopyNpmrc
Running NodejsNpmBuilder:CopySource
Running NodejsNpmBuilder:NpmInstall
Running NodejsNpmBuilder:CleanUpNpmrc
Build Succeeded
Built Artifacts : .aws-sam/build
Built Template : .aws-sam/build/template.yaml
Commands you can use next
=========================
[*] Invoke Function: sam local invoke
[*] Deploy: sam deploy --guided
% sam deploy --guided
Configuring SAM deploy
======================
Looking for config file [samconfig.toml] : Not found
Setting default arguments for 'sam deploy'
=========================================
Stack Name [sam-app]: test
AWS Region [us-east-1]: us-west-2
#Shows you resources changes to be deployed and require a 'Y' to initiate deploy
Confirm changes before deploy [y/N]: y
#SAM needs permission to be able to create roles to connect to the resources in your template
Allow SAM CLI IAM role creation [Y/n]: y
getAllItemsFunction may not have authorization defined, Is this okay? [y/N]: y
getByIdFunction may not have authorization defined, Is this okay? [y/N]: y
putItemFunction may not have authorization defined, Is this okay? [y/N]: y
Save arguments to configuration file [Y/n]: y
SAM configuration file [samconfig.toml]:
SAM configuration environment [default]:
Looking for resources needed for deployment: Found!
Managed S3 bucket: aws-sam-cli-managed-default-samclisourcebucket-iucm54o5o7dc
A different default S3 bucket can be set in samconfig.toml
Saved arguments to config file
Running 'sam deploy' for future deployments will use the parameters saved above.
The above parameters can be changed by modifying samconfig.toml
Learn more about samconfig.toml syntax at
https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-config.html
Uploading to test/b2d96e563b62361916ac8e8a1c8cd2c8 11671 / 11671.0 (100.00%)
Deploying with following values
===============================
Stack name : test
Region : us-west-2
Confirm changeset : True
Deployment s3 bucket : aws-sam-cli-managed-default-samclisourcebucket-iucm54o5o7dc
Capabilities : ["CAPABILITY_IAM"]
Parameter overrides : {}
Signing Profiles : {}
Initiating deployment
=====================
getAllItemsFunction may not have authorization defined.
getByIdFunction may not have authorization defined.
putItemFunction may not have authorization defined.
Uploading to test/b2f6f03b9584e96198c468da665480ad.template 2676 / 2676.0 (100.00%)
Waiting for changeset to be created..
CloudFormation stack changeset
-----------------------------------------------------------------------------------------------------
Operation LogicalResourceId ResourceType Replacement
-----------------------------------------------------------------------------------------------------
+ Add SampleTable AWS::DynamoDB::Table N/A
+ Add ServerlessRestApiDeploy AWS::ApiGateway::Deploy N/A
menta4d359a69a ment
+ Add ServerlessRestApiProdSt AWS::ApiGateway::Stage N/A
age
+ Add ServerlessRestApi AWS::ApiGateway::RestAp N/A
i
+ Add getAllItemsFunctionApiP AWS::Lambda::Permission N/A
ermissionProd
+ Add getAllItemsFunctionRole AWS::IAM::Role N/A
+ Add getAllItemsFunction AWS::Lambda::Function N/A
+ Add getByIdFunctionApiPermi AWS::Lambda::Permission N/A
ssionProd
+ Add getByIdFunctionRole AWS::IAM::Role N/A
+ Add getByIdFunction AWS::Lambda::Function N/A
+ Add putItemFunctionApiPermi AWS::Lambda::Permission N/A
ssionProd
+ Add putItemFunctionRole AWS::IAM::Role N/A
+ Add putItemFunction AWS::Lambda::Function N/A
-----------------------------------------------------------------------------------------------------
Changeset created successfully. arn:aws:cloudformation:us-west-2:772514331817:changeSet/samcli-deploy1609369552/7adccca6-500c-4b5a-b178-cd6fe26ca05c
Previewing CloudFormation changeset before deployment
======================================================
Deploy this changeset? [y/N]: y
2020-12-30 15:06:00 - Waiting for stack create/update to complete
CloudFormation events from changeset
-----------------------------------------------------------------------------------------------------
ResourceStatus ResourceType LogicalResourceId ResourceStatusReason
-----------------------------------------------------------------------------------------------------
CREATE_IN_PROGRESS AWS::DynamoDB::Table SampleTable Resource creation
Initiated
CREATE_IN_PROGRESS AWS::DynamoDB::Table SampleTable -
CREATE_COMPLETE AWS::DynamoDB::Table SampleTable -
CREATE_IN_PROGRESS AWS::IAM::Role getByIdFunctionRole Resource creation
Initiated
CREATE_IN_PROGRESS AWS::IAM::Role putItemFunctionRole Resource creation
Initiated
CREATE_IN_PROGRESS AWS::IAM::Role getAllItemsFunctionRole Resource creation
Initiated
CREATE_IN_PROGRESS AWS::IAM::Role getByIdFunctionRole -
CREATE_IN_PROGRESS AWS::IAM::Role putItemFunctionRole -
CREATE_IN_PROGRESS AWS::IAM::Role getAllItemsFunctionRole -
CREATE_COMPLETE AWS::IAM::Role getAllItemsFunctionRole -
CREATE_COMPLETE AWS::IAM::Role putItemFunctionRole -
CREATE_COMPLETE AWS::IAM::Role getByIdFunctionRole -
CREATE_IN_PROGRESS AWS::Lambda::Function putItemFunction Resource creation
Initiated
CREATE_IN_PROGRESS AWS::Lambda::Function getByIdFunction -
CREATE_IN_PROGRESS AWS::Lambda::Function getAllItemsFunction -
CREATE_IN_PROGRESS AWS::Lambda::Function putItemFunction -
CREATE_COMPLETE AWS::Lambda::Function getAllItemsFunction -
CREATE_COMPLETE AWS::Lambda::Function putItemFunction -
CREATE_IN_PROGRESS AWS::Lambda::Function getByIdFunction Resource creation
Initiated
CREATE_IN_PROGRESS AWS::Lambda::Function getAllItemsFunction Resource creation
Initiated
CREATE_COMPLETE AWS::Lambda::Function getByIdFunction -
CREATE_IN_PROGRESS AWS::ApiGateway::RestAp ServerlessRestApi Resource creation
i Initiated
CREATE_IN_PROGRESS AWS::ApiGateway::RestAp ServerlessRestApi -
i
CREATE_COMPLETE AWS::ApiGateway::RestAp ServerlessRestApi -
i
CREATE_IN_PROGRESS AWS::Lambda::Permission getAllItemsFunctionApiP -
ermissionProd
CREATE_IN_PROGRESS AWS::Lambda::Permission getByIdFunctionApiPermi -
ssionProd
CREATE_IN_PROGRESS AWS::ApiGateway::Deploy ServerlessRestApiDeploy -
ment menta4d359a69a
CREATE_IN_PROGRESS AWS::Lambda::Permission getByIdFunctionApiPermi Resource creation
ssionProd Initiated
CREATE_IN_PROGRESS AWS::ApiGateway::Deploy ServerlessRestApiDeploy Resource creation
ment menta4d359a69a Initiated
CREATE_IN_PROGRESS AWS::Lambda::Permission getAllItemsFunctionApiP Resource creation
ermissionProd Initiated
CREATE_IN_PROGRESS AWS::Lambda::Permission putItemFunctionApiPermi Resource creation
ssionProd Initiated
CREATE_IN_PROGRESS AWS::Lambda::Permission putItemFunctionApiPermi -
ssionProd
CREATE_COMPLETE AWS::ApiGateway::Deploy ServerlessRestApiDeploy -
ment menta4d359a69a
CREATE_IN_PROGRESS AWS::ApiGateway::Stage ServerlessRestApiProdSt -
age
CREATE_COMPLETE AWS::ApiGateway::Stage ServerlessRestApiProdSt -
age
CREATE_IN_PROGRESS AWS::ApiGateway::Stage ServerlessRestApiProdSt Resource creation
age Initiated
CREATE_COMPLETE AWS::Lambda::Permission putItemFunctionApiPermi -
ssionProd
CREATE_COMPLETE AWS::Lambda::Permission getByIdFunctionApiPermi -
ssionProd
CREATE_COMPLETE AWS::Lambda::Permission getAllItemsFunctionApiP -
ermissionProd
CREATE_COMPLETE AWS::CloudFormation::St test -
ack
-----------------------------------------------------------------------------------------------------
CloudFormation outputs from deployed stack
-------------------------------------------------------------------------------------------------------
Outputs
-------------------------------------------------------------------------------------------------------
Key WebEndpoint
Description API Gateway endpoint URL for Prod stage
Value https://5z8a1v4mne.execute-api.us-west-2.amazonaws.com/Prod/
-------------------------------------------------------------------------------------------------------
Successfully created/updated stack - test in us-west-2
% aws dynamodb list-tables
{
"TableNames": [
"test-SampleTable-1QMILHHZIHJOU"
]
}
{
"getAllItemsFunction": {
"SAMPLE_TABLE": "test-SampleTable-1QMILHHZIHJOU"
},
"getByIdFunction": {
"SAMPLE_TABLE": "test-SampleTable-1QMILHHZIHJOU"
},
"putItemFunction": {
"SAMPLE_TABLE": "test-SampleTable-1QMILHHZIHJOU"
}
}
% sam local start-api -n env.json --warm-containers eager --template template.yml --debug
2020-12-30 15:14:37,728 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2020-12-30 15:14:38,001 | local start-api command is called
2020-12-30 15:14:38,015 | No Parameters detected in the template
2020-12-30 15:14:38,056 | 5 resources found in the template
2020-12-30 15:14:38,057 | Found Serverless function with name='getAllItemsFunction' and CodeUri='.'
2020-12-30 15:14:38,057 | Found Serverless function with name='getByIdFunction' and CodeUri='.'
2020-12-30 15:14:38,057 | Found Serverless function with name='putItemFunction' and CodeUri='.'
2020-12-30 15:14:38,080 | Initializing the lambda functions containers.
2020-12-30 15:14:38,080 | Async execution started
2020-12-30 15:14:38,080 | Invoking function functools.partial(<function InvokeContext._initialize_all_functions_containers.<locals>.initialize_function_container at 0x10ffbe7a0>, Function(name='getAllItemsFunction', functionname='getAllItemsFunction', runtime='nodejs12.x', memory=128, timeout=100, handler='src/handlers/get-all-items.getAllItemsHandler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='.', environment={'Variables': {'SAMPLE_TABLE': 'SampleTable'}}, rolearn=None, layers=[], events={'Api': {'Type': 'Api', 'Properties': {'Path': '/', 'Method': 'GET', 'RestApiId': 'ServerlessRestApi'}}}, metadata=None, codesign_config_arn=None))
2020-12-30 15:14:38,081 | Invoking function functools.partial(<function InvokeContext._initialize_all_functions_containers.<locals>.initialize_function_container at 0x10ffbe7a0>, Function(name='getByIdFunction', functionname='getByIdFunction', runtime='nodejs12.x', memory=128, timeout=100, handler='src/handlers/get-by-id.getByIdHandler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='.', environment={'Variables': {'SAMPLE_TABLE': 'SampleTable'}}, rolearn=None, layers=[], events={'Api': {'Type': 'Api', 'Properties': {'Path': '/{id}', 'Method': 'GET', 'RestApiId': 'ServerlessRestApi'}}}, metadata=None, codesign_config_arn=None))
2020-12-30 15:14:38,082 | Invoking function functools.partial(<function InvokeContext._initialize_all_functions_containers.<locals>.initialize_function_container at 0x10ffbe7a0>, Function(name='putItemFunction', functionname='putItemFunction', runtime='nodejs12.x', memory=128, timeout=100, handler='src/handlers/put-item.putItemHandler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='.', environment={'Variables': {'SAMPLE_TABLE': 'SampleTable'}}, rolearn=None, layers=[], events={'Api': {'Type': 'Api', 'Properties': {'Path': '/', 'Method': 'POST', 'RestApiId': 'ServerlessRestApi'}}}, metadata=None, codesign_config_arn=None))
2020-12-30 15:14:38,082 | Waiting for async results
2020-12-30 15:14:38,083 | Environment variables overrides data is standard format
2020-12-30 15:14:38,083 | Loading AWS credentials from session with profile 'None'
2020-12-30 15:14:38,083 | Environment variables overrides data is standard format
2020-12-30 15:14:38,089 | Environment variables overrides data is standard format
2020-12-30 15:14:38,093 | Loading AWS credentials from session with profile 'None'
2020-12-30 15:14:38,093 | Loading AWS credentials from session with profile 'None'
2020-12-30 15:14:38,123 | Resolving code path. Cwd=/Volumes/Unix/workplace/github-issues/test, CodeUri=.
2020-12-30 15:14:38,124 | Resolved absolute path to code is /Volumes/Unix/workplace/github-issues/test
2020-12-30 15:14:38,124 | Code /Volumes/Unix/workplace/github-issues/test is not a zip/jar file
2020-12-30 15:14:38,126 | Resolving code path. Cwd=/Volumes/Unix/workplace/github-issues/test, CodeUri=.
2020-12-30 15:14:38,126 | Resolved absolute path to code is /Volumes/Unix/workplace/github-issues/test
2020-12-30 15:14:38,127 | Resolving code path. Cwd=/Volumes/Unix/workplace/github-issues/test, CodeUri=.
2020-12-30 15:14:38,127 | Resolved absolute path to code is /Volumes/Unix/workplace/github-issues/test
2020-12-30 15:14:38,127 | Code /Volumes/Unix/workplace/github-issues/test is not a zip/jar file
2020-12-30 15:14:38,128 | Code /Volumes/Unix/workplace/github-issues/test is not a zip/jar file
2020-12-30 15:14:38,177 | Skip pulling image and use local one: amazon/aws-sam-cli-emulation-image-nodejs12.x:rapid-1.15.0.
2020-12-30 15:14:38,177 | Mounting /Volumes/Unix/workplace/github-issues/test as /var/task:ro,delegated inside runtime container
2020-12-30 15:14:38,179 | Skip pulling image and use local one: amazon/aws-sam-cli-emulation-image-nodejs12.x:rapid-1.15.0.
2020-12-30 15:14:38,180 | Skip pulling image and use local one: amazon/aws-sam-cli-emulation-image-nodejs12.x:rapid-1.15.0.
2020-12-30 15:14:38,180 | Mounting /Volumes/Unix/workplace/github-issues/test as /var/task:ro,delegated inside runtime container
2020-12-30 15:14:38,180 | Mounting /Volumes/Unix/workplace/github-issues/test as /var/task:ro,delegated inside runtime container
2020-12-30 15:14:39,146 | Async execution completed
2020-12-30 15:14:39,147 | Containers Initialization is done.
2020-12-30 15:14:39,147 | No Parameters detected in the template
2020-12-30 15:14:39,175 | 5 resources found in the template
2020-12-30 15:14:39,175 | Found '1' API Events in Serverless function with name 'getAllItemsFunction'
2020-12-30 15:14:39,175 | Found '1' API Events in Serverless function with name 'getByIdFunction'
2020-12-30 15:14:39,175 | Found '1' API Events in Serverless function with name 'putItemFunction'
2020-12-30 15:14:39,175 | Detected Inline Swagger definition
2020-12-30 15:14:39,175 | Lambda function integration not found in Swagger document at path='/' method='get'
2020-12-30 15:14:39,175 | Lambda function integration not found in Swagger document at path='/' method='post'
2020-12-30 15:14:39,175 | Lambda function integration not found in Swagger document at path='/{id}' method='get'
2020-12-30 15:14:39,175 | Found '0' APIs in resource 'ServerlessRestApi'
2020-12-30 15:14:39,175 | Removed duplicates from '0' Explicit APIs and '3' Implicit APIs to produce '3' APIs
2020-12-30 15:14:39,175 | 3 APIs found in the template
2020-12-30 15:14:39,179 | Mounting getByIdFunction at http://127.0.0.1:3000/{id} [GET]
2020-12-30 15:14:39,179 | Mounting putItemFunction at http://127.0.0.1:3000/ [POST]
2020-12-30 15:14:39,179 | Mounting getAllItemsFunction at http://127.0.0.1:3000/ [GET]
2020-12-30 15:14:39,179 | You can now browse to the above endpoints to invoke your functions. You do not need to restart/reload SAM CLI while working on your functions, changes will be reflected instantly/automatically. You only need to restart SAM CLI if you update your AWS SAM template
2020-12-30 15:14:39,179 | Localhost server is starting up. Multi-threading = True
2020-12-30 15:14:39 * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)
% curl http://127.0.0.1:3000/
[]%
% curl -d '{"id": "1"}' -X POST http://127.0.0.1:3000/
{"id":"1"}%
% curl http://127.0.0.1:3000/1
{"id":"1"}%
% curl http://127.0.0.1:3000/
[{"id":"1"}]%
% curl -d '{"id": "2"}' -X POST http://127.0.0.1:3000/
{"id":"2"}%
% curl http://127.0.0.1:3000/
[{"id":"2"},{"id":"1"}]%
Could you please let me know if these steps are helpful or not.
Hi @moelasmar! Thanks for the quick response.
I've replicated the exact steps as you described. See the complete log below
viljami@work:~$ sam init
Which template source would you like to use?
1 - AWS Quick Start Templates
2 - Custom Template Location
Choice: 1
What package type would you like to use?
1 - Zip (artifact is a zip uploaded to S3)
2 - Image (artifact is an image uploaded to an ECR image repository)
Package type: 1
Which runtime would you like to use?
1 - nodejs12.x
2 - python3.8
3 - ruby2.7
4 - go1.x
5 - java11
6 - dotnetcore3.1
7 - nodejs10.x
8 - python3.7
9 - python3.6
10 - python2.7
11 - ruby2.5
12 - java8.al2
13 - java8
14 - dotnetcore2.1
Runtime: 1
Project name [sam-app]:
Cloning app templates from https://github.com/aws/aws-sam-cli-app-templates
AWS quick start application templates:
1 - Hello World Example
2 - Step Functions Sample App (Stock Trader)
3 - Quick Start: From Scratch
4 - Quick Start: Scheduled Events
5 - Quick Start: S3
6 - Quick Start: SNS
7 - Quick Start: SQS
8 - Quick Start: Web Backend
Template selection: 8
-----------------------
Generating application:
-----------------------
Name: sam-app
Runtime: nodejs12.x
Dependency Manager: npm
Application Template: quick-start-web
Output Directory: .
Next steps can be found in the README file at ./sam-app/README.md
viljami@work:~$ aws sts get-caller-identity
{
"UserId": "AIDA5NIA2MHAQVURD4DJO",
"Account": "921809084865",
"Arn": "arn:aws:iam::921809084865:user/viljami-aws"
}
viljami@work:~$ cd sam-app/
viljami@work:~/sam-app$ sam build
Building codeuri: . runtime: nodejs12.x metadata: {} functions: ['getAllItemsFunction', 'getByIdFunction', 'putItemFunction']
Running NodejsNpmBuilder:NpmPack
Running NodejsNpmBuilder:CopyNpmrc
Running NodejsNpmBuilder:CopySource
Running NodejsNpmBuilder:NpmInstall
Running NodejsNpmBuilder:CleanUpNpmrc
Build Succeeded
Built Artifacts : .aws-sam/build
Built Template : .aws-sam/build/template.yaml
Commands you can use next
=========================
[*] Invoke Function: sam local invoke
[*] Deploy: sam deploy --guided
viljami@work:~/sam-app$ sam deploy --guided
Configuring SAM deploy
======================
Looking for config file [samconfig.toml] : Not found
Setting default arguments for 'sam deploy'
=========================================
Stack Name [sam-app]: test
AWS Region [us-east-1]: us-west-2
#Shows you resources changes to be deployed and require a 'Y' to initiate deploy
Confirm changes before deploy [y/N]: y
#SAM needs permission to be able to create roles to connect to the resources in your template
Allow SAM CLI IAM role creation [Y/n]: y
getAllItemsFunction may not have authorization defined, Is this okay? [y/N]: y
getByIdFunction may not have authorization defined, Is this okay? [y/N]: y
putItemFunction may not have authorization defined, Is this okay? [y/N]: y
Save arguments to configuration file [Y/n]: y
SAM configuration file [samconfig.toml]:
SAM configuration environment [default]:
Looking for resources needed for deployment: Not found.
Creating the required resources...
Successfully created!
Managed S3 bucket: aws-sam-cli-managed-default-samclisourcebucket-m6hisknwp7bm
A different default S3 bucket can be set in samconfig.toml
Saved arguments to config file
Running 'sam deploy' for future deployments will use the parameters saved above.
The above parameters can be changed by modifying samconfig.toml
Learn more about samconfig.toml syntax at
https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-config.html
Uploading to test/19444c434543de3fb6dd831f6fdd8d7c 8091341 / 8091341.0 (100.00%)
Deploying with following values
===============================
Stack name : test
Region : us-west-2
Confirm changeset : True
Deployment s3 bucket : aws-sam-cli-managed-default-samclisourcebucket-m6hisknwp7bm
Capabilities : ["CAPABILITY_IAM"]
Parameter overrides : {}
Signing Profiles : {}
Initiating deployment
=====================
getAllItemsFunction may not have authorization defined.
getByIdFunction may not have authorization defined.
putItemFunction may not have authorization defined.
Uploading to test/0ff974a9e126feefc537dd2f6038c8c6.template 2679 / 2679.0 (100.00%)
Waiting for changeset to be created..
CloudFormation stack changeset
-------------------------------------------------------------------------------------------------
Operation LogicalResourceId ResourceType Replacement
-------------------------------------------------------------------------------------------------
+ Add SampleTable AWS::DynamoDB::Table N/A
+ Add ServerlessRestApiDeplo AWS::ApiGateway::Deplo N/A
ymenta4d359a69a yment
+ Add ServerlessRestApiProdS AWS::ApiGateway::Stage N/A
tage
+ Add ServerlessRestApi AWS::ApiGateway::RestA N/A
pi
+ Add getAllItemsFunctionApi AWS::Lambda::Permissio N/A
PermissionProd n
+ Add getAllItemsFunctionRol AWS::IAM::Role N/A
e
+ Add getAllItemsFunction AWS::Lambda::Function N/A
+ Add getByIdFunctionApiPerm AWS::Lambda::Permissio N/A
issionProd n
+ Add getByIdFunctionRole AWS::IAM::Role N/A
+ Add getByIdFunction AWS::Lambda::Function N/A
+ Add putItemFunctionApiPerm AWS::Lambda::Permissio N/A
issionProd n
+ Add putItemFunctionRole AWS::IAM::Role N/A
+ Add putItemFunction AWS::Lambda::Function N/A
-------------------------------------------------------------------------------------------------
Changeset created successfully. arn:aws:cloudformation:us-west-2:921809084865:changeSet/samcli-deploy1609409159/98441066-d0ee-4104-87b1-fff43b44da73
Previewing CloudFormation changeset before deployment
======================================================
Deploy this changeset? [y/N]: y
2020-12-31 11:06:11 - Waiting for stack create/update to complete
CloudFormation events from changeset
-------------------------------------------------------------------------------------------------
ResourceStatus ResourceType LogicalResourceId ResourceStatusReason
-------------------------------------------------------------------------------------------------
CREATE_IN_PROGRESS AWS::DynamoDB::Table SampleTable -
CREATE_IN_PROGRESS AWS::DynamoDB::Table SampleTable Resource creation
Initiated
CREATE_COMPLETE AWS::DynamoDB::Table SampleTable -
CREATE_IN_PROGRESS AWS::IAM::Role putItemFunctionRole Resource creation
Initiated
CREATE_IN_PROGRESS AWS::IAM::Role getAllItemsFunctionRol Resource creation
e Initiated
CREATE_IN_PROGRESS AWS::IAM::Role getByIdFunctionRole Resource creation
Initiated
CREATE_IN_PROGRESS AWS::IAM::Role getAllItemsFunctionRol -
e
CREATE_IN_PROGRESS AWS::IAM::Role getByIdFunctionRole -
CREATE_IN_PROGRESS AWS::IAM::Role putItemFunctionRole -
CREATE_COMPLETE AWS::IAM::Role getAllItemsFunctionRol -
e
CREATE_COMPLETE AWS::IAM::Role getByIdFunctionRole -
CREATE_COMPLETE AWS::IAM::Role putItemFunctionRole -
CREATE_IN_PROGRESS AWS::Lambda::Function putItemFunction -
CREATE_IN_PROGRESS AWS::Lambda::Function getAllItemsFunction -
CREATE_IN_PROGRESS AWS::Lambda::Function getByIdFunction -
CREATE_IN_PROGRESS AWS::Lambda::Function putItemFunction Resource creation
Initiated
CREATE_COMPLETE AWS::Lambda::Function getAllItemsFunction -
CREATE_COMPLETE AWS::Lambda::Function getByIdFunction -
CREATE_IN_PROGRESS AWS::Lambda::Function getAllItemsFunction Resource creation
Initiated
CREATE_IN_PROGRESS AWS::Lambda::Function getByIdFunction Resource creation
Initiated
CREATE_COMPLETE AWS::Lambda::Function putItemFunction -
CREATE_COMPLETE AWS::ApiGateway::RestA ServerlessRestApi -
pi
CREATE_IN_PROGRESS AWS::ApiGateway::RestA ServerlessRestApi Resource creation
pi Initiated
CREATE_IN_PROGRESS AWS::ApiGateway::RestA ServerlessRestApi -
pi
CREATE_IN_PROGRESS AWS::Lambda::Permissio getByIdFunctionApiPerm Resource creation
n issionProd Initiated
CREATE_IN_PROGRESS AWS::Lambda::Permissio putItemFunctionApiPerm Resource creation
n issionProd Initiated
CREATE_IN_PROGRESS AWS::Lambda::Permissio getByIdFunctionApiPerm -
n issionProd
CREATE_IN_PROGRESS AWS::Lambda::Permissio getAllItemsFunctionApi Resource creation
n PermissionProd Initiated
CREATE_IN_PROGRESS AWS::Lambda::Permissio putItemFunctionApiPerm -
n issionProd
CREATE_IN_PROGRESS AWS::Lambda::Permissio getAllItemsFunctionApi -
n PermissionProd
CREATE_IN_PROGRESS AWS::ApiGateway::Deplo ServerlessRestApiDeplo -
yment ymenta4d359a69a
CREATE_COMPLETE AWS::ApiGateway::Deplo ServerlessRestApiDeplo -
yment ymenta4d359a69a
CREATE_IN_PROGRESS AWS::ApiGateway::Deplo ServerlessRestApiDeplo Resource creation
yment ymenta4d359a69a Initiated
CREATE_IN_PROGRESS AWS::ApiGateway::Stage ServerlessRestApiProdS -
tage
CREATE_IN_PROGRESS AWS::ApiGateway::Stage ServerlessRestApiProdS Resource creation
tage Initiated
CREATE_COMPLETE AWS::ApiGateway::Stage ServerlessRestApiProdS -
tage
CREATE_COMPLETE AWS::Lambda::Permissio getByIdFunctionApiPerm -
n issionProd
CREATE_COMPLETE AWS::Lambda::Permissio putItemFunctionApiPerm -
n issionProd
CREATE_COMPLETE AWS::Lambda::Permissio getAllItemsFunctionApi -
n PermissionProd
CREATE_COMPLETE AWS::CloudFormation::S test -
tack
-------------------------------------------------------------------------------------------------
CloudFormation outputs from deployed stack
-------------------------------------------------------------------------------------------------
Outputs
-------------------------------------------------------------------------------------------------
Key WebEndpoint
Description API Gateway endpoint URL for Prod stage
Value https://nrf9yjwuk0.execute-api.us-west-2.amazonaws.com/Prod/
-------------------------------------------------------------------------------------------------
Successfully created/updated stack - test in us-west-2
viljami@work:~/sam-app$ aws dynamodb list-tables --region us-west-2
{
"TableNames": [
"test-SampleTable-6V3SXXE7EE1R"
]
}
viljami@work:~/sam-app$ vim env.json
viljami@work:~/sam-app$ cat env.json
{
"getAllItemsFunction": {
"SAMPLE_TABLE": "test-SampleTable-6V3SXXE7EE1R"
},
"getByIdFunction": {
"SAMPLE_TABLE": "test-SampleTable-6V3SXXE7EE1R"
},
"putItemFunction": {
"SAMPLE_TABLE": "test-SampleTable-6V3SXXE7EE1R"
}
}
viljami@work:~/sam-app$ sam local start-api -n env.json --warm-containers eager --template template.yml --debug
2020-12-31 11:09:01,083 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2020-12-31 11:09:01,215 | local start-api command is called
2020-12-31 11:09:01,231 | No Parameters detected in the template
2020-12-31 11:09:01,260 | 5 resources found in the template
2020-12-31 11:09:01,260 | Found Serverless function with name='getAllItemsFunction' and CodeUri='.'
2020-12-31 11:09:01,260 | Found Serverless function with name='getByIdFunction' and CodeUri='.'
2020-12-31 11:09:01,260 | Found Serverless function with name='putItemFunction' and CodeUri='.'
2020-12-31 11:09:01,265 | Initializing the lambda functions containers.
2020-12-31 11:09:01,266 | Async execution started
2020-12-31 11:09:01,266 | Invoking function functools.partial(<function InvokeContext._initialize_all_functions_containers.<locals>.initialize_function_container at 0x11042ca60>, Function(name='getAllItemsFunction', functionname='getAllItemsFunction', runtime='nodejs12.x', memory=128, timeout=100, handler='src/handlers/get-all-items.getAllItemsHandler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='.', environment={'Variables': {'SAMPLE_TABLE': 'SampleTable'}}, rolearn=None, layers=[], events={'Api': {'Type': 'Api', 'Properties': {'Path': '/', 'Method': 'GET', 'RestApiId': 'ServerlessRestApi'}}}, metadata=None, codesign_config_arn=None))
2020-12-31 11:09:01,266 | Invoking function functools.partial(<function InvokeContext._initialize_all_functions_containers.<locals>.initialize_function_container at 0x11042ca60>, Function(name='getByIdFunction', functionname='getByIdFunction', runtime='nodejs12.x', memory=128, timeout=100, handler='src/handlers/get-by-id.getByIdHandler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='.', environment={'Variables': {'SAMPLE_TABLE': 'SampleTable'}}, rolearn=None, layers=[], events={'Api': {'Type': 'Api', 'Properties': {'Path': '/{id}', 'Method': 'GET', 'RestApiId': 'ServerlessRestApi'}}}, metadata=None, codesign_config_arn=None))
2020-12-31 11:09:01,266 | Invoking function functools.partial(<function InvokeContext._initialize_all_functions_containers.<locals>.initialize_function_container at 0x11042ca60>, Function(name='putItemFunction', functionname='putItemFunction', runtime='nodejs12.x', memory=128, timeout=100, handler='src/handlers/put-item.putItemHandler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='.', environment={'Variables': {'SAMPLE_TABLE': 'SampleTable'}}, rolearn=None, layers=[], events={'Api': {'Type': 'Api', 'Properties': {'Path': '/', 'Method': 'POST', 'RestApiId': 'ServerlessRestApi'}}}, metadata=None, codesign_config_arn=None))
2020-12-31 11:09:01,268 | Waiting for async results
2020-12-31 11:09:01,268 | Environment variables overrides data is standard format
2020-12-31 11:09:01,268 | Environment variables overrides data is standard format
2020-12-31 11:09:01,268 | Loading AWS credentials from session with profile 'None'
2020-12-31 11:09:01,269 | Environment variables overrides data is standard format
2020-12-31 11:09:01,269 | Loading AWS credentials from session with profile 'None'
2020-12-31 11:09:01,277 | Loading AWS credentials from session with profile 'None'
2020-12-31 11:09:01,298 | Resolving code path. Cwd=/Users/viljamikuosmanen/sam-app, CodeUri=.
2020-12-31 11:09:01,298 | Resolved absolute path to code is /Users/viljamikuosmanen/sam-app
2020-12-31 11:09:01,298 | Code /Users/viljamikuosmanen/sam-app is not a zip/jar file
2020-12-31 11:09:01,299 | Resolving code path. Cwd=/Users/viljamikuosmanen/sam-app, CodeUri=.
2020-12-31 11:09:01,299 | Resolved absolute path to code is /Users/viljamikuosmanen/sam-app
2020-12-31 11:09:01,299 | Code /Users/viljamikuosmanen/sam-app is not a zip/jar file
2020-12-31 11:09:01,300 | Resolving code path. Cwd=/Users/viljamikuosmanen/sam-app, CodeUri=.
2020-12-31 11:09:01,301 | Resolved absolute path to code is /Users/viljamikuosmanen/sam-app
2020-12-31 11:09:01,301 | Code /Users/viljamikuosmanen/sam-app is not a zip/jar file
2020-12-31 11:09:01,323 | Skip pulling image and use local one: amazon/aws-sam-cli-emulation-image-nodejs12.x:rapid-1.15.0.
2020-12-31 11:09:01,323 | Mounting /Users/viljamikuosmanen/sam-app as /var/task:ro,delegated inside runtime container
2020-12-31 11:09:01,324 | Skip pulling image and use local one: amazon/aws-sam-cli-emulation-image-nodejs12.x:rapid-1.15.0.
2020-12-31 11:09:01,325 | Mounting /Users/viljamikuosmanen/sam-app as /var/task:ro,delegated inside runtime container
2020-12-31 11:09:01,325 | Skip pulling image and use local one: amazon/aws-sam-cli-emulation-image-nodejs12.x:rapid-1.15.0.
2020-12-31 11:09:01,325 | Mounting /Users/viljamikuosmanen/sam-app as /var/task:ro,delegated inside runtime container
At this stage a Python process gets permanently stuck, taking 100% CPU and spinning up the fans on my machine:
PID COMMAND %CPU TIME #TH #WQ #PORT MEM PURG CMPRS PGRP PPID STATE
30995 Python 101.3 02:43.17 6/1 1 38 5921M+ 0B 3545M+ 30995 2635 running
Trying to request port 3000 obviously fails since the local api doesn't start up:
viljami@work:~$ curl http://127.0.0.1:3000/
curl: (7) Failed to connect to 127.0.0.1 port 3000: Connection refused
Please let me know if I can provide any more information.
Can you attach the template file?
Here you go!
# This is the SAM template that represents the architecture of your serverless application
# https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-template-basics.html
# The AWSTemplateFormatVersion identifies the capabilities of the template
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/format-version-structure.html
AWSTemplateFormatVersion: 2010-09-09
Description: >-
sam-app
# Transform section specifies one or more macros that AWS CloudFormation uses to process your template
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/transform-section-structure.html
Transform:
- AWS::Serverless-2016-10-31
# Resources declares the AWS resources that you want to include in the stack
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resources-section-structure.html
Resources:
# Each Lambda function is defined by properties:
# https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
# This is a Lambda function config associated with the source code: get-all-items.js
getAllItemsFunction:
Type: AWS::Serverless::Function
Properties:
Handler: src/handlers/get-all-items.getAllItemsHandler
Runtime: nodejs12.x
MemorySize: 128
Timeout: 100
Description: A simple example includes a HTTP get method to get all items from a DynamoDB table.
Policies:
# Give Create/Read/Update/Delete Permissions to the SampleTable
- DynamoDBCrudPolicy:
TableName: !Ref SampleTable
Environment:
Variables:
# Make table name accessible as environment variable from function code during execution
SAMPLE_TABLE: !Ref SampleTable
Events:
Api:
Type: Api
Properties:
Path: /
Method: GET
# Each Lambda function is defined by properties:
# https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
# This is a Lambda function config associated with the source code: get-by-id.js
getByIdFunction:
Type: AWS::Serverless::Function
Properties:
Handler: src/handlers/get-by-id.getByIdHandler
Runtime: nodejs12.x
MemorySize: 128
Timeout: 100
Description: A simple example includes a HTTP get method to get one item by id from a DynamoDB table.
Policies:
# Give Create/Read/Update/Delete Permissions to the SampleTable
- DynamoDBCrudPolicy:
TableName: !Ref SampleTable
Environment:
Variables:
# Make table name accessible as environment variable from function code during execution
SAMPLE_TABLE: !Ref SampleTable
Events:
Api:
Type: Api
Properties:
Path: /{id}
Method: GET
# Each Lambda function is defined by properties:
# https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
# This is a Lambda function config associated with the source code: put-item.js
putItemFunction:
Type: AWS::Serverless::Function
Properties:
Handler: src/handlers/put-item.putItemHandler
Runtime: nodejs12.x
MemorySize: 128
Timeout: 100
Description: A simple example includes a HTTP post method to add one item to a DynamoDB table.
Policies:
# Give Create/Read/Update/Delete Permissions to the SampleTable
- DynamoDBCrudPolicy:
TableName: !Ref SampleTable
Environment:
Variables:
# Make table name accessible as environment variable from function code during execution
SAMPLE_TABLE: !Ref SampleTable
Events:
Api:
Type: Api
Properties:
Path: /
Method: POST
# Simple syntax to create a DynamoDB table with a single attribute primary key, more in
# https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlesssimpletable
# DynamoDB table to store item: {id: <ID>, name: <NAME>}
SampleTable:
Type: AWS::Serverless::SimpleTable
Properties:
PrimaryKey:
Name: id
Type: String
ProvisionedThroughput:
ReadCapacityUnits: 2
WriteCapacityUnits: 2
Outputs:
WebEndpoint:
Description: "API Gateway endpoint URL for Prod stage"
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/"
Thanks @anttiviljami .. I think I got the issue, just one more try to confirm it.
Could you please create a new dir, and move the project sam-app to it, and try to run the sam localcommand again
Is this what you mean? No change:
viljami@work:~$ mkdir test
viljami@work:~$ mv sam-app/* sam-app/.* test/
viljami@work:~$ cd test/
viljami@work:~/test$ ls
README.md __tests__ buildspec.yml env.json events package.json samconfig.toml src template.yml
viljami@work:~/test$ sam local start-api -n env.json --warm-containers eager --template template.yml --debug
2020-12-31 11:45:33,161 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2020-12-31 11:45:33,279 | local start-api command is called
2020-12-31 11:45:33,295 | No Parameters detected in the template
2020-12-31 11:45:33,323 | 5 resources found in the template
2020-12-31 11:45:33,323 | Found Serverless function with name='getAllItemsFunction' and CodeUri='.'
2020-12-31 11:45:33,323 | Found Serverless function with name='getByIdFunction' and CodeUri='.'
2020-12-31 11:45:33,323 | Found Serverless function with name='putItemFunction' and CodeUri='.'
2020-12-31 11:45:33,328 | Initializing the lambda functions containers.
2020-12-31 11:45:33,328 | Async execution started
2020-12-31 11:45:33,328 | Invoking function functools.partial(<function InvokeContext._initialize_all_functions_containers.<locals>.initialize_function_container at 0x10d4c0a60>, Function(name='getAllItemsFunction', functionname='getAllItemsFunction', runtime='nodejs12.x', memory=128, timeout=100, handler='src/handlers/get-all-items.getAllItemsHandler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='.', environment={'Variables': {'SAMPLE_TABLE': 'SampleTable'}}, rolearn=None, layers=[], events={'Api': {'Type': 'Api', 'Properties': {'Path': '/', 'Method': 'GET', 'RestApiId': 'ServerlessRestApi'}}}, metadata=None, codesign_config_arn=None))
2020-12-31 11:45:33,329 | Invoking function functools.partial(<function InvokeContext._initialize_all_functions_containers.<locals>.initialize_function_container at 0x10d4c0a60>, Function(name='getByIdFunction', functionname='getByIdFunction', runtime='nodejs12.x', memory=128, timeout=100, handler='src/handlers/get-by-id.getByIdHandler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='.', environment={'Variables': {'SAMPLE_TABLE': 'SampleTable'}}, rolearn=None, layers=[], events={'Api': {'Type': 'Api', 'Properties': {'Path': '/{id}', 'Method': 'GET', 'RestApiId': 'ServerlessRestApi'}}}, metadata=None, codesign_config_arn=None))
2020-12-31 11:45:33,329 | Invoking function functools.partial(<function InvokeContext._initialize_all_functions_containers.<locals>.initialize_function_container at 0x10d4c0a60>, Function(name='putItemFunction', functionname='putItemFunction', runtime='nodejs12.x', memory=128, timeout=100, handler='src/handlers/put-item.putItemHandler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='.', environment={'Variables': {'SAMPLE_TABLE': 'SampleTable'}}, rolearn=None, layers=[], events={'Api': {'Type': 'Api', 'Properties': {'Path': '/', 'Method': 'POST', 'RestApiId': 'ServerlessRestApi'}}}, metadata=None, codesign_config_arn=None))
2020-12-31 11:45:33,331 | Waiting for async results
2020-12-31 11:45:33,331 | Environment variables overrides data is standard format
2020-12-31 11:45:33,331 | Loading AWS credentials from session with profile 'None'
2020-12-31 11:45:33,340 | Environment variables overrides data is standard format
2020-12-31 11:45:33,340 | Environment variables overrides data is standard format
2020-12-31 11:45:33,340 | Loading AWS credentials from session with profile 'None'
2020-12-31 11:45:33,340 | Loading AWS credentials from session with profile 'None'
2020-12-31 11:45:33,364 | Resolving code path. Cwd=/Users/viljamikuosmanen/test, CodeUri=.
2020-12-31 11:45:33,364 | Resolved absolute path to code is /Users/viljamikuosmanen/test
2020-12-31 11:45:33,365 | Code /Users/viljamikuosmanen/test is not a zip/jar file
2020-12-31 11:45:33,366 | Resolving code path. Cwd=/Users/viljamikuosmanen/test, CodeUri=.
2020-12-31 11:45:33,366 | Resolving code path. Cwd=/Users/viljamikuosmanen/test, CodeUri=.
2020-12-31 11:45:33,367 | Resolved absolute path to code is /Users/viljamikuosmanen/test
2020-12-31 11:45:33,367 | Resolved absolute path to code is /Users/viljamikuosmanen/test
2020-12-31 11:45:33,367 | Code /Users/viljamikuosmanen/test is not a zip/jar file
2020-12-31 11:45:33,367 | Code /Users/viljamikuosmanen/test is not a zip/jar file
2020-12-31 11:45:33,385 | Skip pulling image and use local one: amazon/aws-sam-cli-emulation-image-nodejs12.x:rapid-1.15.0.
2020-12-31 11:45:33,385 | Mounting /Users/viljamikuosmanen/test as /var/task:ro,delegated inside runtime container
2020-12-31 11:45:33,403 | Skip pulling image and use local one: amazon/aws-sam-cli-emulation-image-nodejs12.x:rapid-1.15.0.
2020-12-31 11:45:33,403 | Mounting /Users/viljamikuosmanen/test as /var/task:ro,delegated inside runtime container
2020-12-31 11:45:33,404 | Skip pulling image and use local one: amazon/aws-sam-cli-emulation-image-nodejs12.x:rapid-1.15.0.
2020-12-31 11:45:33,404 | Mounting /Users/viljamikuosmanen/test as /var/task:ro,delegated inside runtime container
Curiously, moving the template file only fixes the issue:
viljami@work:~/test$ mkdir template-only
viljami@work:~/test$ mv template.yml template-only/
template.yml -> template-only/template.yml
viljami@work:~/test$ sam local start-api -n env.json --warm-containers eager --template template-only/template.yml --debug
2020-12-31 11:47:57,686 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2020-12-31 11:47:57,805 | local start-api command is called
2020-12-31 11:47:57,820 | No Parameters detected in the template
2020-12-31 11:47:57,846 | 5 resources found in the template
2020-12-31 11:47:57,846 | Found Serverless function with name='getAllItemsFunction' and CodeUri='.'
2020-12-31 11:47:57,846 | Found Serverless function with name='getByIdFunction' and CodeUri='.'
2020-12-31 11:47:57,846 | Found Serverless function with name='putItemFunction' and CodeUri='.'
2020-12-31 11:47:57,851 | Initializing the lambda functions containers.
2020-12-31 11:47:57,852 | Async execution started
2020-12-31 11:47:57,852 | Invoking function functools.partial(<function InvokeContext._initialize_all_functions_containers.<locals>.initialize_function_container at 0x105b73a60>, Function(name='getAllItemsFunction', functionname='getAllItemsFunction', runtime='nodejs12.x', memory=128, timeout=100, handler='src/handlers/get-all-items.getAllItemsHandler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='.', environment={'Variables': {'SAMPLE_TABLE': 'SampleTable'}}, rolearn=None, layers=[], events={'Api': {'Type': 'Api', 'Properties': {'Path': '/', 'Method': 'GET', 'RestApiId': 'ServerlessRestApi'}}}, metadata=None, codesign_config_arn=None))
2020-12-31 11:47:57,853 | Invoking function functools.partial(<function InvokeContext._initialize_all_functions_containers.<locals>.initialize_function_container at 0x105b73a60>, Function(name='getByIdFunction', functionname='getByIdFunction', runtime='nodejs12.x', memory=128, timeout=100, handler='src/handlers/get-by-id.getByIdHandler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='.', environment={'Variables': {'SAMPLE_TABLE': 'SampleTable'}}, rolearn=None, layers=[], events={'Api': {'Type': 'Api', 'Properties': {'Path': '/{id}', 'Method': 'GET', 'RestApiId': 'ServerlessRestApi'}}}, metadata=None, codesign_config_arn=None))
2020-12-31 11:47:57,853 | Invoking function functools.partial(<function InvokeContext._initialize_all_functions_containers.<locals>.initialize_function_container at 0x105b73a60>, Function(name='putItemFunction', functionname='putItemFunction', runtime='nodejs12.x', memory=128, timeout=100, handler='src/handlers/put-item.putItemHandler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='.', environment={'Variables': {'SAMPLE_TABLE': 'SampleTable'}}, rolearn=None, layers=[], events={'Api': {'Type': 'Api', 'Properties': {'Path': '/', 'Method': 'POST', 'RestApiId': 'ServerlessRestApi'}}}, metadata=None, codesign_config_arn=None))
2020-12-31 11:47:57,854 | Waiting for async results
2020-12-31 11:47:57,855 | Environment variables overrides data is standard format
2020-12-31 11:47:57,855 | Loading AWS credentials from session with profile 'None'
2020-12-31 11:47:57,855 | Environment variables overrides data is standard format
2020-12-31 11:47:57,861 | Environment variables overrides data is standard format
2020-12-31 11:47:57,862 | Loading AWS credentials from session with profile 'None'
2020-12-31 11:47:57,863 | Loading AWS credentials from session with profile 'None'
2020-12-31 11:47:57,884 | Resolving code path. Cwd=/Users/viljamikuosmanen/test/template-only, CodeUri=.
2020-12-31 11:47:57,884 | Resolved absolute path to code is /Users/viljamikuosmanen/test/template-only
2020-12-31 11:47:57,884 | Resolving code path. Cwd=/Users/viljamikuosmanen/test/template-only, CodeUri=.
2020-12-31 11:47:57,884 | Code /Users/viljamikuosmanen/test/template-only is not a zip/jar file
2020-12-31 11:47:57,884 | Resolved absolute path to code is /Users/viljamikuosmanen/test/template-only
2020-12-31 11:47:57,885 | Code /Users/viljamikuosmanen/test/template-only is not a zip/jar file
2020-12-31 11:47:57,886 | Resolving code path. Cwd=/Users/viljamikuosmanen/test/template-only, CodeUri=.
2020-12-31 11:47:57,886 | Resolved absolute path to code is /Users/viljamikuosmanen/test/template-only
2020-12-31 11:47:57,886 | Code /Users/viljamikuosmanen/test/template-only is not a zip/jar file
2020-12-31 11:47:57,911 | Skip pulling image and use local one: amazon/aws-sam-cli-emulation-image-nodejs12.x:rapid-1.15.0.
2020-12-31 11:47:57,911 | Mounting /Users/viljamikuosmanen/test/template-only as /var/task:ro,delegated inside runtime container
2020-12-31 11:47:57,912 | Skip pulling image and use local one: amazon/aws-sam-cli-emulation-image-nodejs12.x:rapid-1.15.0.
2020-12-31 11:47:57,912 | Mounting /Users/viljamikuosmanen/test/template-only as /var/task:ro,delegated inside runtime container
2020-12-31 11:47:57,913 | Skip pulling image and use local one: amazon/aws-sam-cli-emulation-image-nodejs12.x:rapid-1.15.0.
2020-12-31 11:47:57,913 | Mounting /Users/viljamikuosmanen/test/template-only as /var/task:ro,delegated inside runtime container
2020-12-31 11:47:58,532 | Async execution completed
2020-12-31 11:47:58,533 | Containers Initialization is done.
2020-12-31 11:47:58,533 | No Parameters detected in the template
2020-12-31 11:47:58,554 | 5 resources found in the template
2020-12-31 11:47:58,554 | Found '1' API Events in Serverless function with name 'getAllItemsFunction'
2020-12-31 11:47:58,554 | Found '1' API Events in Serverless function with name 'getByIdFunction'
2020-12-31 11:47:58,554 | Found '1' API Events in Serverless function with name 'putItemFunction'
2020-12-31 11:47:58,554 | Detected Inline Swagger definition
2020-12-31 11:47:58,554 | Lambda function integration not found in Swagger document at path='/' method='get'
2020-12-31 11:47:58,554 | Lambda function integration not found in Swagger document at path='/' method='post'
2020-12-31 11:47:58,554 | Lambda function integration not found in Swagger document at path='/{id}' method='get'
2020-12-31 11:47:58,555 | Found '0' APIs in resource 'ServerlessRestApi'
2020-12-31 11:47:58,555 | Removed duplicates from '0' Explicit APIs and '3' Implicit APIs to produce '3' APIs
2020-12-31 11:47:58,555 | 3 APIs found in the template
2020-12-31 11:47:58,556 | Mounting getAllItemsFunction at http://127.0.0.1:3000/ [GET]
2020-12-31 11:47:58,556 | Mounting getByIdFunction at http://127.0.0.1:3000/{id} [GET]
2020-12-31 11:47:58,556 | Mounting putItemFunction at http://127.0.0.1:3000/ [POST]
2020-12-31 11:47:58,557 | You can now browse to the above endpoints to invoke your functions. You do not need to restart/reload SAM CLI while working on your functions, changes will be reflected instantly/automatically. You only need to restart SAM CLI if you update your AWS SAM template
2020-12-31 11:47:58,557 | Localhost server is starting up. Multi-threading = True
2020-12-31 11:47:58 * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)
no I mean something like this:
mkdir test
mv sam-app test
cd test/sam-app
sam local start-api -n env.json --warm-containers eager --template template.yml --debug
I think this will also solve the issue
Looks like you're correct!
After moving the template file baqck under test/:
viljami@work:~/test$ sam local start-api -n env.json --warm-containers eager --template template.yml --debug
2020-12-31 11:55:33,211 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2020-12-31 11:55:33,304 | local start-api command is called
2020-12-31 11:55:33,318 | No Parameters detected in the template
2020-12-31 11:55:33,346 | 5 resources found in the template
2020-12-31 11:55:33,346 | Found Serverless function with name='getAllItemsFunction' and CodeUri='.'
2020-12-31 11:55:33,346 | Found Serverless function with name='getByIdFunction' and CodeUri='.'
2020-12-31 11:55:33,346 | Found Serverless function with name='putItemFunction' and CodeUri='.'
2020-12-31 11:55:33,351 | Initializing the lambda functions containers.
2020-12-31 11:55:33,351 | Async execution started
2020-12-31 11:55:33,351 | Invoking function functools.partial(<function InvokeContext._initialize_all_functions_containers.<locals>.initialize_function_container at 0x10de81a60>, Function(name='getAllItemsFunction', functionname='getAllItemsFunction', runtime='nodejs12.x', memory=128, timeout=100, handler='src/handlers/get-all-items.getAllItemsHandler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='.', environment={'Variables': {'SAMPLE_TABLE': 'SampleTable'}}, rolearn=None, layers=[], events={'Api': {'Type': 'Api', 'Properties': {'Path': '/', 'Method': 'GET', 'RestApiId': 'ServerlessRestApi'}}}, metadata=None, codesign_config_arn=None))
2020-12-31 11:55:33,352 | Invoking function functools.partial(<function InvokeContext._initialize_all_functions_containers.<locals>.initialize_function_container at 0x10de81a60>, Function(name='getByIdFunction', functionname='getByIdFunction', runtime='nodejs12.x', memory=128, timeout=100, handler='src/handlers/get-by-id.getByIdHandler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='.', environment={'Variables': {'SAMPLE_TABLE': 'SampleTable'}}, rolearn=None, layers=[], events={'Api': {'Type': 'Api', 'Properties': {'Path': '/{id}', 'Method': 'GET', 'RestApiId': 'ServerlessRestApi'}}}, metadata=None, codesign_config_arn=None))
2020-12-31 11:55:33,352 | Invoking function functools.partial(<function InvokeContext._initialize_all_functions_containers.<locals>.initialize_function_container at 0x10de81a60>, Function(name='putItemFunction', functionname='putItemFunction', runtime='nodejs12.x', memory=128, timeout=100, handler='src/handlers/put-item.putItemHandler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='.', environment={'Variables': {'SAMPLE_TABLE': 'SampleTable'}}, rolearn=None, layers=[], events={'Api': {'Type': 'Api', 'Properties': {'Path': '/', 'Method': 'POST', 'RestApiId': 'ServerlessRestApi'}}}, metadata=None, codesign_config_arn=None))
2020-12-31 11:55:33,354 | Waiting for async results
2020-12-31 11:55:33,354 | Environment variables overrides data is standard format
2020-12-31 11:55:33,354 | Loading AWS credentials from session with profile 'None'
2020-12-31 11:55:33,365 | Environment variables overrides data is standard format
2020-12-31 11:55:33,366 | Loading AWS credentials from session with profile 'None'
2020-12-31 11:55:33,366 | Environment variables overrides data is standard format
2020-12-31 11:55:33,375 | Loading AWS credentials from session with profile 'None'
2020-12-31 11:55:33,391 | Resolving code path. Cwd=/Users/viljamikuosmanen/test, CodeUri=.
2020-12-31 11:55:33,392 | Resolving code path. Cwd=/Users/viljamikuosmanen/test, CodeUri=.
2020-12-31 11:55:33,392 | Resolved absolute path to code is /Users/viljamikuosmanen/test
2020-12-31 11:55:33,392 | Resolved absolute path to code is /Users/viljamikuosmanen/test
2020-12-31 11:55:33,393 | Resolving code path. Cwd=/Users/viljamikuosmanen/test, CodeUri=.
2020-12-31 11:55:33,393 | Code /Users/viljamikuosmanen/test is not a zip/jar file
2020-12-31 11:55:33,393 | Resolved absolute path to code is /Users/viljamikuosmanen/test
2020-12-31 11:55:33,393 | Code /Users/viljamikuosmanen/test is not a zip/jar file
2020-12-31 11:55:33,393 | Code /Users/viljamikuosmanen/test is not a zip/jar file
2020-12-31 11:55:33,422 | Skip pulling image and use local one: amazon/aws-sam-cli-emulation-image-nodejs12.x:rapid-1.15.0.
2020-12-31 11:55:33,423 | Skip pulling image and use local one: amazon/aws-sam-cli-emulation-image-nodejs12.x:rapid-1.15.0.
2020-12-31 11:55:33,423 | Mounting /Users/viljamikuosmanen/test as /var/task:ro,delegated inside runtime container
2020-12-31 11:55:33,423 | Mounting /Users/viljamikuosmanen/test as /var/task:ro,delegated inside runtime container
2020-12-31 11:55:33,423 | Skip pulling image and use local one: amazon/aws-sam-cli-emulation-image-nodejs12.x:rapid-1.15.0.
2020-12-31 11:55:33,424 | Mounting /Users/viljamikuosmanen/test as /var/task:ro,delegated inside runtime container
Then moving the project under a new directory:
viljami@work:~/test$ cd ..
viljami@work:~$ mkdir test2
viljami@work:~$ mv test test2
test -> test2/test
viljami@work:~$ cd test2/test/
viljami@work:~/test2/test$ sam local start-api -n env.json --warm-containers eager --template template.yml --debug
2020-12-31 11:57:03,911 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2020-12-31 11:57:04,034 | local start-api command is called
2020-12-31 11:57:04,049 | No Parameters detected in the template
2020-12-31 11:57:04,082 | 5 resources found in the template
2020-12-31 11:57:04,082 | Found Serverless function with name='getAllItemsFunction' and CodeUri='.'
2020-12-31 11:57:04,082 | Found Serverless function with name='getByIdFunction' and CodeUri='.'
2020-12-31 11:57:04,082 | Found Serverless function with name='putItemFunction' and CodeUri='.'
2020-12-31 11:57:04,088 | Initializing the lambda functions containers.
2020-12-31 11:57:04,089 | Async execution started
2020-12-31 11:57:04,089 | Invoking function functools.partial(<function InvokeContext._initialize_all_functions_containers.<locals>.initialize_function_container at 0x112501a60>, Function(name='getAllItemsFunction', functionname='getAllItemsFunction', runtime='nodejs12.x', memory=128, timeout=100, handler='src/handlers/get-all-items.getAllItemsHandler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='.', environment={'Variables': {'SAMPLE_TABLE': 'SampleTable'}}, rolearn=None, layers=[], events={'Api': {'Type': 'Api', 'Properties': {'Path': '/', 'Method': 'GET', 'RestApiId': 'ServerlessRestApi'}}}, metadata=None, codesign_config_arn=None))
2020-12-31 11:57:04,089 | Invoking function functools.partial(<function InvokeContext._initialize_all_functions_containers.<locals>.initialize_function_container at 0x112501a60>, Function(name='getByIdFunction', functionname='getByIdFunction', runtime='nodejs12.x', memory=128, timeout=100, handler='src/handlers/get-by-id.getByIdHandler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='.', environment={'Variables': {'SAMPLE_TABLE': 'SampleTable'}}, rolearn=None, layers=[], events={'Api': {'Type': 'Api', 'Properties': {'Path': '/{id}', 'Method': 'GET', 'RestApiId': 'ServerlessRestApi'}}}, metadata=None, codesign_config_arn=None))
2020-12-31 11:57:04,090 | Invoking function functools.partial(<function InvokeContext._initialize_all_functions_containers.<locals>.initialize_function_container at 0x112501a60>, Function(name='putItemFunction', functionname='putItemFunction', runtime='nodejs12.x', memory=128, timeout=100, handler='src/handlers/put-item.putItemHandler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='.', environment={'Variables': {'SAMPLE_TABLE': 'SampleTable'}}, rolearn=None, layers=[], events={'Api': {'Type': 'Api', 'Properties': {'Path': '/', 'Method': 'POST', 'RestApiId': 'ServerlessRestApi'}}}, metadata=None, codesign_config_arn=None))
2020-12-31 11:57:04,091 | Waiting for async results
2020-12-31 11:57:04,091 | Environment variables overrides data is standard format
2020-12-31 11:57:04,092 | Loading AWS credentials from session with profile 'None'
2020-12-31 11:57:04,092 | Environment variables overrides data is standard format
2020-12-31 11:57:04,092 | Environment variables overrides data is standard format
2020-12-31 11:57:04,101 | Loading AWS credentials from session with profile 'None'
2020-12-31 11:57:04,101 | Loading AWS credentials from session with profile 'None'
2020-12-31 11:57:04,123 | Resolving code path. Cwd=/Users/viljamikuosmanen/test2/test, CodeUri=.
2020-12-31 11:57:04,124 | Resolved absolute path to code is /Users/viljamikuosmanen/test2/test
2020-12-31 11:57:04,124 | Resolving code path. Cwd=/Users/viljamikuosmanen/test2/test, CodeUri=.
2020-12-31 11:57:04,124 | Code /Users/viljamikuosmanen/test2/test is not a zip/jar file
2020-12-31 11:57:04,125 | Resolving code path. Cwd=/Users/viljamikuosmanen/test2/test, CodeUri=.
2020-12-31 11:57:04,125 | Resolved absolute path to code is /Users/viljamikuosmanen/test2/test
2020-12-31 11:57:04,125 | Resolved absolute path to code is /Users/viljamikuosmanen/test2/test
2020-12-31 11:57:04,125 | Code /Users/viljamikuosmanen/test2/test is not a zip/jar file
2020-12-31 11:57:04,125 | Code /Users/viljamikuosmanen/test2/test is not a zip/jar file
2020-12-31 11:57:04,149 | Skip pulling image and use local one: amazon/aws-sam-cli-emulation-image-nodejs12.x:rapid-1.15.0.
2020-12-31 11:57:04,149 | Mounting /Users/viljamikuosmanen/test2/test as /var/task:ro,delegated inside runtime container
2020-12-31 11:57:04,150 | Skip pulling image and use local one: amazon/aws-sam-cli-emulation-image-nodejs12.x:rapid-1.15.0.
2020-12-31 11:57:04,151 | Mounting /Users/viljamikuosmanen/test2/test as /var/task:ro,delegated inside runtime container
2020-12-31 11:57:04,151 | Skip pulling image and use local one: amazon/aws-sam-cli-emulation-image-nodejs12.x:rapid-1.15.0.
2020-12-31 11:57:04,151 | Mounting /Users/viljamikuosmanen/test2/test as /var/task:ro,delegated inside runtime container
2020-12-31 11:57:08,814 | Async execution completed
2020-12-31 11:57:08,814 | Containers Initialization is done.
2020-12-31 11:57:08,814 | No Parameters detected in the template
2020-12-31 11:57:08,838 | 5 resources found in the template
2020-12-31 11:57:08,838 | Found '1' API Events in Serverless function with name 'getAllItemsFunction'
2020-12-31 11:57:08,838 | Found '1' API Events in Serverless function with name 'getByIdFunction'
2020-12-31 11:57:08,838 | Found '1' API Events in Serverless function with name 'putItemFunction'
2020-12-31 11:57:08,838 | Detected Inline Swagger definition
2020-12-31 11:57:08,838 | Lambda function integration not found in Swagger document at path='/' method='get'
2020-12-31 11:57:08,838 | Lambda function integration not found in Swagger document at path='/' method='post'
2020-12-31 11:57:08,838 | Lambda function integration not found in Swagger document at path='/{id}' method='get'
2020-12-31 11:57:08,838 | Found '0' APIs in resource 'ServerlessRestApi'
2020-12-31 11:57:08,839 | Removed duplicates from '0' Explicit APIs and '3' Implicit APIs to produce '3' APIs
2020-12-31 11:57:08,839 | 3 APIs found in the template
2020-12-31 11:57:08,841 | Mounting getByIdFunction at http://127.0.0.1:3000/{id} [GET]
2020-12-31 11:57:08,841 | Mounting putItemFunction at http://127.0.0.1:3000/ [POST]
2020-12-31 11:57:08,841 | Mounting getAllItemsFunction at http://127.0.0.1:3000/ [GET]
2020-12-31 11:57:08,841 | You can now browse to the above endpoints to invoke your functions. You do not need to restart/reload SAM CLI while working on your functions, changes will be reflected instantly/automatically. You only need to restart SAM CLI if you update your AWS SAM template
2020-12-31 11:57:08,841 | Localhost server is starting up. Multi-threading = True
2020-12-31 11:57:08 * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)
It works!
So as long as the template isn't directly one level under $HOME, it works? 馃槄
Ok, I got the issue .. I believe that the issue in this snippet of code:
https://github.com/aws/aws-sam-cli/blob/ff2b11498d4f83fcd011e63ff29f4be8faba5b1d/samcli/lib/utils/file_observer.py#L105-L115
thanks @anttiviljami for your support.
So as long as the template isn't directly one level under
$HOME, it works? 馃槄
I think no .. I think the issue will happen if the parent directory of your project contains a lot of directories.
I will investigate more on this issue in the morning.
Thank you so much for your help @moelasmar ! This helped me already find a good workaround so I can proceed with my work. 馃憤
Hi! Just wanted to report another finding that's probably related to this:
When supplying --template ./template.yml the file change watcher is significantly slower (multiple seconds to notice changes to source files vs. almost instant) than when --template is not supplied and the runtime container gets mounted to the built function under .aws-sam/.
Meaning this message sometimes takes ages to show up after touching a file:
Lambda Function 'MyFunction' code has been changed, terminate its warm container. The new container will be created in lazy mode
I'm guessing once the underlying issue is fixed, this will also get resolved :+1:
Most helpful comment
I think no .. I think the issue will happen if the parent directory of your project contains a lot of directories.
I will investigate more on this issue in the morning.