aws-samples / aws-bookstore-demo-app

AWS Bookstore Demo App is a full-stack sample web application that creates a storefront (and backend) for customers to shop for fictitious books. The entire application can be created with a single template. Built on AWS Full-Stack Template.
MIT No Attribution
623 stars 306 forks source link

CloudFormation deployment fails as a result of Python 2.7 runtime deprecation #27

Closed MattMcClernon closed 2 years ago

MattMcClernon commented 3 years ago

Describe the bug CFN stack deployment fails to create Lambda function UpdateSearchCluster with the following error:

"The runtime parameter of python2.7 is no longer supported for creating or updating AWS Lambda functions. We recommend you use the new runtime (python3.9) while creating or updating functions."

I edited the CFN YAML and changed it to Python 3.8, and the stack deploys successfully, but the UpdateSearchCluster function fails to execute with this error:

"Syntax error in module 'index': Missing parentheses in call to 'print'. Did you mean print("bookId " + id)? (index.py, line 25)"

This appears to be related to syntax changes between Python version 2 and 3.

triggan commented 3 years ago

It appears that the culprit is this line here: https://github.com/triggan/aws-bookstore-demo-app/blob/ebee1b7d7a8beed337b825383b9ccf206f52b7d8/functions/streaming/updateSearchCluster.py#L25

print() in Python 3 now requires parentheses, where it was not required in Python 2.

I can work up a PR to fix this in the repo and work back with the repo owners to get this fixed in the code on S3.

MattMcClernon commented 3 years ago

Hey Taylor,

I've edited the Python directly in the Lambda console and added the parentheses, and now the code is syntactically correct. but I cant execute it to confirm its working because its triggered by DynamoDB streams and relies on parameters passed in from DDB. Do you know if there is a way I can re-populate the Books table, either with the original Lambda book loader, or by adding my own new book details and image URL. The Lambda will not execute until we have new entries added to DDB, and pushed into the DDB stream.

triggan commented 2 years ago

This has now been fixed in the deployed version of the code. The UpdateSearchCluster Lambda now runs using Python 3.9.