template.yml inside folder breaks 'sam local invoke'... still
See original GitHub issuesee this: https://github.com/awslabs/aws-sam-cli/issues/140 Same problem with version: version 0.3.0
Uninstalled sam npm, upgraded to latest sam local with pip (python 2)
Windows 10.
sam local invoke blah --template mytemps/mytemp.yaml -e myevents/test.json
Unable to import module 'lambda_function': No module named 'lambda_function'
Works when yaml template is in the root of the folder. Do I have to use codeUri or something?
YAML
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: An AWS Serverless Specification template describing your function.
Resources:
blah:
Type: 'AWS::Serverless::Function'
Properties:
Handler: lambda_function.lambda_handler
Runtime: python3.6
Description: ''
MemorySize: 128
Timeout: 300
Role: '......'
Environment:
Variables:
sdfsdfs: sdfsdfsdf
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
template.yml inside folder breaks 'sam local invoke'... still
So for example you have your template in a subfolder named "mytemps". If you copy your code to another subfolder named "mycode" ,...
Read more >sam local invoke - AWS Serverless Application Model
The AWS SAM CLI first tries to locate a template file built using the sam build command, located in the .aws-sam subfolder, and...
Read more >AWS SAM: Could not install from function as it does not ...
The hello-world sample project generated with sam init doesn't have one in the root folder either, but somehow sam build has no problem ......
Read more >DEEP DIVE INTO AWS SAM BUILDING AND PACKAGING ...
In this episode I talk to Eric Johnson, Developer Advocate for Serverless at AWS and we go into de depths of AWS SAM...
Read more >awslabs/aws-sam-local
The reason I want to change it is in handler, I will return a data map and it works on real lambda connected...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Welp im dumb looks like this is working. i just needed to copy my code to a different folder and use CodeUri to point to it.
I came here with a similar problem and @red8888’s suggestion to modify CodeUri helped me solve it.
When running with the template in a subdirectory:
sam local start-api -p 9090 --host 0.0.0.0 --template project/template.yml
I got errors about my handler module not being found. When I moved template.yml to the current directory it worked as expected.
The fix was to update the path of CodeUri
from
build/project.zip
to../build/project.zip
The structure is like this:
and I run the sam local command from inside the root directory.