Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

AWS Lambda Runtime.UserCodeSyntaxError: Syntax error in module 'salesAnalysisReport': invalid syntax

I am working on AWS Solutions Architecting Module 13 Challenge Lab. I have written the following code in my AWS Lambda SalesAnalysisReport function’s salesAnalysisReport.py file :

    response = snsClient.publish(
        TopicArn = arn:aws:sns:us-east-1:507782174659:SalesReportTopic,
        Subject = 'Daily Sales Analysis Report',
        Message = message.getvalue()    
    )

I am running default hello-world test case and getting the following error message :

[ERROR] Runtime.UserCodeSyntaxError: Syntax error in module 'salesAnalysisReport': invalid syntax (salesAnalysisReport.py, line 129)
Traceback (most recent call last):
File "/var/task/salesAnalysisReport.py" Line 129
TopicArn = arn:aws:sns:us-east-1:507782174659:SalesReportTopic,END RequestId: 5bb30f77-0fae-453a-8f56-b89cdbd064a8

I am using Python 3.8 as directed in lab instructions.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I would like to know the cause of error so that I can resolve it

P.S. – Line 129(error causing line) is

TopicArn = arn:aws:sns:us-east-1:507782174659:SalesReportTopic,

I tried putting the value of TopicArn in double quotes and then using that for TopicArn but that didn’t work.

>Solution :

You need to enclose it in single quotes, so it is a string as required by Boto3.

Try:

response = snsClient.publish(
        TopicArn = 'arn:aws:sns:us-east-1:507782174659:SalesReportTopic',
        Subject = 'Daily Sales Analysis Report',
        Message = message.getvalue()    
)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading