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!!

feita há 2 anos4375 visualizações
1 Resposta
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
respondido há 2 anos

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas