I want to start using aws-sam to test locally my lambdas. I tried to the tutorial from https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-quick-start.html
I created example app using sam init --runtime python3.6
And then when I do
sam build --use-container
I get this strange exception that it cannot get requirements.txt. What should I do ? I use pyhon 3.7.2
2019-02-13 10:06:42 Using SAM Template at C:\Users\XXXX\Documents\sam-app\template.yaml
2019-02-13 10:06:42 Changing event name from creating-client-class.iot-data to creating-client-class.iot-data-p
2019-02-13 10:06:42 Changing event name from before-call.apigateway to before-call.api-gateway
2019-02-13 10:06:42 Changing event name from request-created.machinelearning.Predict to request-created.machine
.Predict
2019-02-13 10:06:42 Changing event name from before-parameter-build.autoscaling.CreateLaunchConfiguration to be
meter-build.auto-scaling.CreateLaunchConfiguration
2019-02-13 10:06:42 Changing event name from before-parameter-build.route53 to before-parameter-build.route-53
2019-02-13 10:06:42 Changing event name from request-created.cloudsearchdomain.Search to request-created.clouds
ain.Search
2019-02-13 10:06:42 Changing event name from docs.*.autoscaling.CreateLaunchConfiguration.complete-section to d
o-scaling.CreateLaunchConfiguration.complete-section
2019-02-13 10:06:42 Changing event name from before-parameter-build.logs.CreateExportTask to before-parameter-b
dwatch-logs.CreateExportTask
2019-02-13 10:06:42 Changing event name from docs.*.logs.CreateExportTask.complete-section to docs.*.cloudwatch
ateExportTask.complete-section
2019-02-13 10:06:42 Changing event name from before-parameter-build.cloudsearchdomain.Search to before-paramete
loudsearch-domain.Search
2019-02-13 10:06:42 Changing event name from docs.*.cloudsearchdomain.Search.complete-section to docs.*.cloudse
in.Search.complete-section
2019-02-13 10:06:42 Changing event name from creating-client-class.iot-data to creating-client-class.iot-data-p
2019-02-13 10:06:42 Changing event name from before-call.apigateway to before-call.api-gateway
2019-02-13 10:06:42 Changing event name from request-created.machinelearning.Predict to request-created.machine
.Predict
2019-02-13 10:06:42 Changing event name from before-parameter-build.autoscaling.CreateLaunchConfiguration to be
meter-build.auto-scaling.CreateLaunchConfiguration
2019-02-13 10:06:42 Changing event name from before-parameter-build.route53 to before-parameter-build.route-53
2019-02-13 10:06:42 Changing event name from request-created.cloudsearchdomain.Search to request-created.clouds
ain.Search
2019-02-13 10:06:42 Changing event name from docs.*.autoscaling.CreateLaunchConfiguration.complete-section to d
o-scaling.CreateLaunchConfiguration.complete-section
2019-02-13 10:06:42 Changing event name from before-parameter-build.logs.CreateExportTask to before-parameter-b
dwatch-logs.CreateExportTask
2019-02-13 10:06:42 Changing event name from docs.*.logs.CreateExportTask.complete-section to docs.*.cloudwatch
ateExportTask.complete-section
2019-02-13 10:06:42 Changing event name from before-parameter-build.cloudsearchdomain.Search to before-paramete
loudsearch-domain.Search
2019-02-13 10:06:42 Changing event name from docs.*.cloudsearchdomain.Search.complete-section to docs.*.cloudse
in.Search.complete-section
2019-02-13 10:06:42 'build' command is called
2019-02-13 10:06:42 Starting Build inside a container
2019-02-13 10:06:42 Looking for credentials via: env
2019-02-13 10:06:42 Looking for credentials via: assume-role
2019-02-13 10:06:42 Looking for credentials via: shared-credentials-file
2019-02-13 10:06:42 Found credentials in shared credentials file: ~/.aws/credentials
2019-02-13 10:06:42 Loading JSON file: C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\botocore\dat
ts.json
2019-02-13 10:06:42 Event choose-service-name: calling handler <function handle_service_name_alias at 0x0000023
>
2019-02-13 10:06:42 Loading JSON file: C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\botocore\dat
essrepo\2017-09-08\service-2.json
2019-02-13 10:06:42 Event creating-client-class.serverlessapplicationrepository: calling handler <function add_
presigned_url at 0x00000237DD8E8EA0>
2019-02-13 10:06:42 The s3 config key is not a dictionary type, ignoring its value of: None
2019-02-13 10:06:42 Setting serverlessrepo timeout as (60, 60)
2019-02-13 10:06:42 Loading JSON file: C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\botocore\dat
json
2019-02-13 10:06:42 Registering retry handlers for service: serverlessrepo
2019-02-13 10:06:42 No Parameters detected in the template
2019-02-13 10:06:42 2 resources found in the template
2019-02-13 10:06:42 Found Serverless function with name='HelloWorldFunction' and CodeUri='hello_world/'
2019-02-13 10:06:42 Trying paths: ['C:\\Users\\XXXX\\.docker\\config.json', 'C:\\Users\\XXXX\\.dockercf
2019-02-13 10:06:42 Found file at path: C:\Users\XXXX\.docker\config.json
2019-02-13 10:06:42 Found 'credsStore' section
2019-02-13 10:06:42 Building resource 'HelloWorldFunction'
2019-02-13 10:06:43 Trying paths: ['C:\\Users\\XXXX\\.docker\\config.json', 'C:\\Users\\XXXX\\.dockercf
2019-02-13 10:06:43 Found file at path: C:\Users\XXXX\.docker\config.json
2019-02-13 10:06:43 Found 'credsStore' section
2019-02-13 10:06:43 http://localhost:None "GET /v1.35/images/lambci/lambda:build-python3.6/json HTTP/1.1" 200 N
2019-02-13 10:06:43 Looking for auth config
2019-02-13 10:06:43 Using credentials store "wincred"
2019-02-13 10:06:43 Looking for auth entry for 'https://index.docker.io/v1/'
2019-02-13 10:06:43 No entry found
2019-02-13 10:06:43 No entry in credstore - fetching from auth dict
2019-02-13 10:06:43 Looking for auth entry for 'docker.io'
2019-02-13 10:06:43 No entry found
2019-02-13 10:06:43 No auth config found
2019-02-13 10:06:45 http://localhost:None "POST /v1.35/images/create?tag=build-python3.6&fromImage=lambci%2Flam
1.1" 200 None
Fetching lambci/lambda:build-python3.6 Docker container image......
2019-02-13 10:06:45 Mounting C:\Users\XXXX\Documents\sam-app\hello_world as /tmp/samcli/source:ro inside ru
tainer
2019-02-13 10:06:45 http://localhost:None "POST /v1.35/containers/create HTTP/1.1" 201 90
2019-02-13 10:06:45 http://localhost:None "GET /v1.35/containers/daa68e5aa3872c114bf1ed108626f6e526829570d9affa
523a55d8c/json HTTP/1.1" 200 None
2019-02-13 10:06:45 http://localhost:None "GET /v1.35/containers/daa68e5aa3872c114bf1ed108626f6e526829570d9affa
523a55d8c/json HTTP/1.1" 200 None
2019-02-13 10:06:47 http://localhost:None "POST /v1.35/containers/daa68e5aa3872c114bf1ed108626f6e526829570d9aff
9523a55d8c/start HTTP/1.1" 204 0
2019-02-13 10:06:47 http://localhost:None "GET /v1.35/containers/daa68e5aa3872c114bf1ed108626f6e526829570d9affa
523a55d8c/json HTTP/1.1" 200 None
2019-02-13 10:06:47 http://localhost:None "POST /containers/daa68e5aa3872c114bf1ed108626f6e526829570d9affa75e3b
5d8c/attach?stdout=1&stderr=1&logs=1&stream=1&stdin=0 HTTP/1.1" 101 0
Using the request object from command line argument
Loading workflow module 'aws_lambda_builders.workflows'
Registering workflow 'PythonPipBuilder' with capability 'Capability(language='python', dependency_manager='pip'
tion_framework=None)'
Registering workflow 'NodejsNpmBuilder' with capability 'Capability(language='nodejs', dependency_manager='npm'
tion_framework=None)'
Registering workflow 'RubyBundlerBuilder' with capability 'Capability(language='ruby', dependency_manager='bund
lication_framework=None)'
Found workflow 'PythonPipBuilder' to support capabilities 'Capability(language='python', dependency_manager='pi
cation_framework=None)'
Running workflow 'PythonPipBuilder'
Running PythonPipBuilder:ResolveDependencies
PythonPipBuilder:ResolveDependencies failed
Traceback (most recent call last):
File "/var/lang/lib/python3.6/site-packages/aws_lambda_builders/workflows/python_pip/actions.py", line 27, in
self.scratch_dir
File "/var/lang/lib/python3.6/site-packages/aws_lambda_builders/workflows/python_pip/packager.py", line 140,
dependencies
raise RequirementsFileNotFoundError(requirements_path)
aws_lambda_builders.workflows.python_pip.packager.RequirementsFileNotFoundError: Requirements file not found: /
i/source/requirements.txt
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/var/lang/lib/python3.6/site-packages/aws_lambda_builders/workflow.py", line 164, in run
action.execute()
File "/var/lang/lib/python3.6/site-packages/aws_lambda_builders/workflows/python_pip/actions.py", line 30, in
raise ActionFailedError(str(ex))
aws_lambda_builders.actions.ActionFailedError: Requirements file not found: /tmp/samcli/source/requirements.txt
Builder workflow failed
Traceback (most recent call last):
File "/var/lang/lib/python3.6/site-packages/aws_lambda_builders/workflows/python_pip/actions.py", line 27, in
self.scratch_dir
File "/var/lang/lib/python3.6/site-packages/aws_lambda_builders/workflows/python_pip/packager.py", line 140,
dependencies
raise RequirementsFileNotFoundError(requirements_path)
aws_lambda_builders.workflows.python_pip.packager.RequirementsFileNotFoundError: Requirements file not found: /
i/source/requirements.txt
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/var/lang/lib/python3.6/site-packages/aws_lambda_builders/workflow.py", line 164, in run
action.execute()
File "/var/lang/lib/python3.6/site-packages/aws_lambda_builders/workflows/python_pip/actions.py", line 30, in
raise ActionFailedError(str(ex))
aws_lambda_builders.actions.ActionFailedError: Requirements file not found: /tmp/samcli/source/requirements.txt
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/var/lang/lib/python3.6/site-packages/aws_lambda_builders/__main__.py", line 98, in main
options=params["options"])
File "/var/lang/lib/python3.6/site-packages/aws_lambda_builders/builder.py", line 108, in build
return workflow.run()
File "/var/lang/lib/python3.6/site-packages/aws_lambda_builders/workflow.py", line 173, in run
reason=str(ex))
aws_lambda_builders.exceptions.WorkflowFailedError: PythonPipBuilder:ResolveDependencies - Requirements file no
/tmp/samcli/source/requirements.txt
2019-02-13 10:06:47 Build inside container returned response {"jsonrpc": "2.0", "id": 1, "error": {"code": 400,
": "PythonPipBuilder:ResolveDependencies - Requirements file not found: /tmp/samcli/source/requirements.txt"}}
2019-02-13 10:06:48 http://localhost:None "GET /v1.35/containers/daa68e5aa3872c114bf1ed108626f6e526829570d9affa
523a55d8c/json HTTP/1.1" 200 None
2019-02-13 10:06:48 http://localhost:None "DELETE /v1.35/containers/daa68e5aa3872c114bf1ed108626f6e526829570d9a
049523a55d8c?v=False&link=False&force=True HTTP/1.1" 204 0
Build Failed
Error: PythonPipBuilder:ResolveDependencies - Requirements file not found: /tmp/samcli/source/requirements.txt
for me the issue was the permissions of the file requirements.txt
I ran chmod a+rw requirements.txt
and the container could successfully see the file. You might be able to do only +r
if you really are concerned about that.