aws-samples / aws-samples/aws-serverless-app-with-aurora-and-python-sql-alchemy-example

Issues going through tutorial

Đang mở
#2 10 bình luận 0 reaction 1 người được giao Được @srijitm nhận Xem trên GitHub
bug documentation
Ngôn ngữ chính
Python
Star
67
Fork
16
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Hi @srijitm,

Thank you for linking me here from the comments on your article. It's brilliantly written and has been a godsend as I re-architect the backend for my start-up.

I was following the tutorial based in eu-west-2.

The issue I had was in the schema part of the tutorial - when CloudFormation was generating the schema, it got stuck on creating the SimpleBookStoreDBSchemaLambdaFunctionTrigger custom event with this error message:

> CloudFormation did not receive a response from your Custom Resource. Please check your logs for requestId [66edab8e-22df-4bd4-9eb1-26632f093a72]. If you are using the Python cfn-response module, you may need to update your Lambda function code so that CloudFormation can attach the updated version.

Eventually, I realised that CloudFormation won't acknowledge the creation of a Lambda function unless the cfn-response module is implemented, and so this caused it to trap. It doesn't seem like the [cfn-response](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-lambda-function-code-cfnresponsemodule.html) module was in your schema code and so no signal went back to CloudFormation to complete the stack creation.

Once I had added `cfnresponse.send()` to the sample code, it still did not work.

I found the CloudWatch Logs of the SimpleBookStoreDBSchemaLambdaFunction function which did get created and discovered that it was giving another error message in the logs:

> Unable to import module 'main': No module named 'sqlalchemy'

From my research, I found out that AWS Lambda does not natively support libraries other than common Python system libraries and boto3. I realised I needed to build the packages locally using `sam build --use-container` before deploying them.

Once I did this, I started testing the code locally with `sam local invoke` and ran into the same issues I found earlier in the CloudWatch logs.

This is where I'm less sure of my solution. I started doing more trial-and-error, deploying and testing locally using `sam build --use-container` and eventually, what worked for me was copying the `requirements.txt` file from the SimpleOnlineBookstoreDBSchemaLambdaLayer to the SimpleBookStoreDBSchemaLambdaFunction that was running as well. I think for some reason, the Lambda function needed the requirements of the layer in order to build properly.

After doing this, my last `sam deploy -g` worked perfectly and the schema appeared in the database when I accessed it through SSH.

I hope this will be helpful in improving your guide. I would love to hear your thoughts and potential explanations for some of the gotchas I encountered.

Thanks again,

Jacob

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.