You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The sam local commands do not work as documented in the AWS Serverless Application Model Developer Guide. They require an additional call to sam build before they will work.
The documentation indicates the following commands should work from within the simple-go directory:
sam local invoke
sam local start-api
Observed result:
Running sam local invoke gets you:
$ sam local invoke --debug
2020-11-13 20:11:23,487 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2020-11-13 20:11:23,542 | local invoke command is called
2020-11-13 20:11:23,544 | No Parameters detected in the template
2020-11-13 20:11:23,561 | 2 resources found in the template
2020-11-13 20:11:23,561 | Found Serverless function with name='ExampleRoot' and CodeUri='./cmd/my-func/'
2020-11-13 20:11:23,564 | Found one Lambda function with name 'ExampleRoot'
2020-11-13 20:11:23,564 | Invoking my-func (go1.x)
2020-11-13 20:11:23,564 | No environment variables found for function 'ExampleRoot'
2020-11-13 20:11:23,564 | Environment variables overrides data is standard format
2020-11-13 20:11:23,564 | Loading AWS credentials from session with profile 'None'
2020-11-13 20:11:23,572 | Resolving code path. Cwd=/projects/simple-go, CodeUri=./cmd/my-func/
2020-11-13 20:11:23,572 | Resolved absolute path to code is /projects/simple-go/cmd/my-func
2020-11-13 20:11:23,572 | Code /projects/simple-go/cmd/my-func is not a zip/jar file
2020-11-13 20:11:23,575 | Skip pulling image and use local one: amazon/aws-sam-cli-emulation-image-go1.x:rapid-1.7.0.
2020-11-13 20:11:23,575 | Mounting /projects/simple-go/cmd/my-func as /var/task:ro,delegated inside runtime container
2020-11-13 20:11:23,885 | Starting a timer for 3 seconds for function 'ExampleRoot'
START RequestId: 6961a864-2a06-1dca-b722-c2635e27a299 Version: $LATEST
fork/exec /var/task/my-func: no such file or directory: PathError
fork/exec /var/task/my-func: no such file or directory: PathError
null
END RequestId: 6961a864-2a06-1dca-b722-c2635e27a299
REPORT RequestId: 6961a864-2a06-1dca-b722-c2635e27a299 Init Duration: 57.70 ms Duration: 1.44 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 16 MB
2020-11-13 20:11:24,184 | Sending Telemetry: {'metrics': [{'commandRun': {'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam local invoke', 'duration': 696, 'exitReason': 'success', 'exitCode': 0, 'requestId': '78d50567-a61f-42e3-9fa4-b3d0a2e30179', 'installationId': '72eb7872-74c2-473d-b9e1-6ea1da5e4588', 'sessionId': '7084671a-89d6-4499-b213-bd5cf632c207', 'executionEnvironment': 'CLI', 'pyversion': '3.8.5', 'samcliVersion': '1.7.0'}}]}
2020-11-13 20:11:24,530 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
{"errorType":"PathError","errorMessage":"fork/exec /var/task/my-func: no such file or directory"}
sam local start-api starts the API but fails with almost the same error once a request is made.
Expected result:
my-func should be built and executed or the documentation should be updated to indicate an additional step is necessary.
Working result:
Running sam build followed by sam local invoke does work:
$ sam build
Building codeuri: ./cmd/my-func/ runtime: go1.x metadata: {} functions: ['ExampleRoot']
Running GoModulesBuilder:Build
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 local invoke --debug
2020-11-13 20:23:37,364 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2020-11-13 20:23:37,415 | local invoke command is called
2020-11-13 20:23:37,416 | No Parameters detected in the template
2020-11-13 20:23:37,432 | 2 resources found in the template
2020-11-13 20:23:37,432 | Found Serverless function with name='ExampleRoot' and CodeUri='ExampleRoot'
2020-11-13 20:23:37,434 | Found one Lambda function with name 'ExampleRoot'
2020-11-13 20:23:37,434 | Invoking my-func (go1.x)
2020-11-13 20:23:37,434 | No environment variables found for function 'ExampleRoot'
2020-11-13 20:23:37,434 | Environment variables overrides data is standard format
2020-11-13 20:23:37,434 | Loading AWS credentials from session with profile 'None'
2020-11-13 20:23:37,443 | Resolving code path. Cwd=/projects/simple-go/.aws-sam/build, CodeUri=ExampleRoot
2020-11-13 20:23:37,443 | Resolved absolute path to code is /projects/simple-go/.aws-sam/build/ExampleRoot
2020-11-13 20:23:37,443 | Code /projects/simple-go/.aws-sam/build/ExampleRoot is not a zip/jar file
2020-11-13 20:23:37,447 | Skip pulling image and use local one: amazon/aws-sam-cli-emulation-image-go1.x:rapid-1.7.0.
2020-11-13 20:23:37,447 | Mounting /projects/simple-go/.aws-sam/build/ExampleRoot as /var/task:ro,delegated inside runtime container 2020-11-13 20:23:37,755 | Starting a timer for 3 seconds for function 'ExampleRoot'
2020/11/14 04:23:37 Simple Function
2020/11/14 04:23:37 <nil>
2020-11-13 20:23:40,756 | Function 'ExampleRoot' timed out after 3 seconds
2020-11-13 20:23:41,122 | Sending Telemetry: {'metrics': [{'commandRun': {'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam local invoke',
'duration': 3755, 'exitReason': 'success', 'exitCode': 0, 'requestId': 'cef4037b-9689-4610-876c-93413bc413bb', 'installationId': '72eb7872-74c2-473d-b9e1-6ea1da5e4588', 'session
Id': '547dafa5-7733-42bc-96d1-1ebe099d469b', 'executionEnvironment': 'CLI', 'pyversion': '3.8.5', 'samcliVersion': '1.7.0'}}]}
2020-11-13 20:23:41,437 | Telemetry response: 200
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
$ go version
go version go1.15.4 linux/amd64
$ sam --version
SAM CLI, version 1.7.0
$ cat /etc/issue
Ubuntu 20.04.1 LTS \n \l
Maybe there should be additional instructions for non-interpreted languages?
The text was updated successfully, but these errors were encountered:
Description:
The
sam local
commands do not work as documented in the AWS Serverless Application Model Developer Guide. They require an additional call tosam build
before they will work.Steps to reproduce:
Assume a simple project structure such as:
With a
template.yaml
of:The documentation indicates the following commands should work from within the
simple-go
directory:sam local invoke
sam local start-api
Observed result:
Running
sam local invoke
gets you:sam local start-api
starts the API but fails with almost the same error once a request is made.Expected result:
my-func
should be built and executed or the documentation should be updated to indicate an additional step is necessary.Working result:
Running
sam build
followed bysam local invoke
does work:Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
Maybe there should be additional instructions for non-interpreted languages?
The text was updated successfully, but these errors were encountered: