Handler error python lambda function

0

I am trying to follow this tutorial https://aws.amazon.com/blogs/machine-learning/build-your-own-text-to-speech-applications-with-amazon-polly/ but keep having an error on my lambda functions when I click the 'test' button. My code is the "PostReader_ConvertToAudio" section of the tutorial.

My error code is as follow :

{
  "errorMessage": "'Records'",
  "errorType": "KeyError",
  "requestId": "9e788dd8-763c-4e85-b5c5-36520aeee1ca",
  "stackTrace": [
    "  File \"/var/task/lambda_function.py\", line 8, in lambda_handler\n    postId = event[\"Records\"][0][\"Sns\"][\"Message\"]\n"
  ]
}

Thank you for your help!!

질문됨 2년 전4375회 조회
1개 답변
0

The blog post doesn't explicitly provide example test data to test this function, unlike the other two functions in the post. This is because the function is relying on the data structure provided by the SNS invocation. SNS will invoke this function when a message is received and provide said message to the function; event["Records"][0]["Sns"]["Message"] is where the message will be found.

If you would like to run a test of this function, you will need to emulate the JSON data structure expected by the function:

{
    "Records": [
        {
            "Sns": {
                "Message": "ENTER RELEVANT DATA HERE"
            }
        }
    ]
}
AWS
답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠