Aws-sam-cli: SAM Lambda local test failing

Created on 30 Sep 2019  路  5Comments  路  Source: aws/aws-sam-cli

Hi,
I am exctly following the tutorial at:
https://docs.aws.amazon.com/en_pv/serverless-application-model/latest/developerguide/serverless-getting-started-hello-world.html

Which goes all good until i test the fucntion locally. At this point I get following error:

START RequestId: 5f54d9d2-599b-1139-050a-a458c89289e6 Version: $LATEST
[ERROR] Runtime.ImportModuleError: Unable to import module 'app': No module named 'app'
END RequestId: 5f54d9d2-599b-1139-050a-a458c89289e6
REPORT RequestId: 5f54d9d2-599b-1139-050a-a458c89289e6 Duration: 3.52 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 22 MB 
{
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Unable to import module 'app': No module named 'app'"
}
Function returned an invalid response (must include one of: body, headers, multiValueHeaders or statusCode in the response object). Response received:
2019-09-30 16:32:39 127.0.0.1 - - [30/Sep/2019 16:32:39] "GET /hello HTTP/1.1" 502 -

Windows 10
Docker Version 2.0.0.3 (31259)
SAM CLI, version 0.22.0

platforwindows windows

Most helpful comment

I would wager to guess you're not sharing drives with Docker. Check the installation guide here: https://docs.aws.amazon.com/en_pv/serverless-application-model/latest/developerguide/serverless-sam-cli-install-windows.html#serverless-sam-cli-install-windows-docker

Unfortunately the Windows install has a "blink and you'll miss it" checkbox on this, but try turning that setting on and see if things work, the error makes it look like the drive with your built code isn't mounting to the container.

All 5 comments

I would wager to guess you're not sharing drives with Docker. Check the installation guide here: https://docs.aws.amazon.com/en_pv/serverless-application-model/latest/developerguide/serverless-sam-cli-install-windows.html#serverless-sam-cli-install-windows-docker

Unfortunately the Windows install has a "blink and you'll miss it" checkbox on this, but try turning that setting on and see if things work, the error makes it look like the drive with your built code isn't mounting to the container.

I have that Docker checkbox marked for sharing drive. I think the log says that mounting is ok. So what else can be?

@smoms Docker for Windows is notorious for giving a false sense of hope. I would recommend toggling the share setting of the drive you want to share/work on. If that still doesn't work, a reboot helps. When Docker does not have permission, it mounts an empty directory instead of failing which explains the error you are seeing. Especially, if you followed the guide.

@jfuss many thanks! That helped indeed.

@smoms Docker for Windows is notorious for giving a false sense of hope. I would recommend toggling the share setting of the drive you want to share/work on. If that still doesn't work, a reboot helps. When Docker does not have permission, it mounts an empty directory instead of failing which explains the error you are seeing. Especially, if you followed the guide.

That took me so long to reach here. Checking and unchecking the shared drive checkbox on docker desktop fixed. Docker desktop is notorious.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

asyba picture asyba  路  3Comments

joekiller picture joekiller  路  4Comments

zhangzhx picture zhangzhx  路  3Comments

Inkromind picture Inkromind  路  4Comments

GerbenRampaart picture GerbenRampaart  路  3Comments