Why Amazon Lambda function throws key error?

Solution 1:

Your test execution needs input values. You can see in your error that the test used the default input {'key1': 'value1', 'key2': 'value2', 'key3': 'value3'}. You have to change the test input to a JSON string that contains the connection_id and queryStringParameters in the correct format.

It seems that you use Lambda in combination with the API Gateway. The gateway usually creates the event input. You can also create a test in the API Gateway, where you can specify the query parameters.