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:
[32mSTART RequestId: 5f54d9d2-599b-1139-050a-a458c89289e6 Version: $LATEST[0m
[ERROR] Runtime.ImportModuleError: Unable to import module 'app': No module named 'app'
[32mEND RequestId: 5f54d9d2-599b-1139-050a-a458c89289e6[0m
[32mREPORT RequestId: 5f54d9d2-599b-1139-050a-a458c89289e6 Duration: 3.52 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 22 MB [0m
[31m{
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Unable to import module 'app': No module named 'app'"
}[0m
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
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.
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.