Я пытаюсь записать в свою DynamoDB используя лямбда-функции. Когда я тестирую функцию Lambda в консоли, она работает отлично, однако, когда я пытаюсь подключиться к API Gateway, он больше не может правильно писать. По некоторым причинам он возвращает статус 200, но DynamoDB не обновляется.
Вот моя лямбда-функция:
const AWS = require('aws-sdk');
const dynamoDb = new AWS.DynamoDB.DocumentClient({ region: 'us-west-1' });
exports.handler = async function(event, ctx, callback) {
var params = {
Item: {
hash: event.hash,
email: event.email,
},
TableName: 'app',
}
try {
const data = await dynamoDb.put(params).promise()
console.log({ statusCode: 200, body: { params, data }})
} catch (err) {
console.log(err)
}
}
Вот что показывает журнал, когда я пытаюсь проверить его в консоли API Gateway
Execution log for request e0371e68-5348-11e9-9a7c-8382b3f4c143
Sun Mar 31 00:06:47 UTC 2019 : Starting execution for request: e0371e68-5348-11e9-9a7c-8382b3f4c143
Sun Mar 31 00:06:47 UTC 2019 : HTTP Method: POST, Resource Path: /submit
Sun Mar 31 00:06:47 UTC 2019 : Method request path: {}
Sun Mar 31 00:06:47 UTC 2019 : Method request query string: {hash=123, email=coolio@gmail.com}
Sun Mar 31 00:06:47 UTC 2019 : Method request headers: {}
Sun Mar 31 00:06:47 UTC 2019 : Method request body before transformations:
Sun Mar 31 00:06:47 UTC 2019 : Endpoint request URI: https://lambda.us-west-1.amazonaws.com/2015-03-31/functions/arn:aws:lambda:us-west-1:931121055930:function:testWrite/invocations
Sun Mar 31 00:06:47 UTC 2019 : Endpoint request headers: {x-amzn-lambda-integration-tag=e0371e68-5348-11e9-9a7c-8382b3f4c143, Authorization=**************************************************************************************************************************************************************************************************************************************************************************************93cbd8, X-Amz-Date=20190331T000647Z, x-amzn-apigateway-api-id=3sczyqizmj, X-Amz-Source-Arn=arn:aws:execute-api:us-west-1:931121055930:3sczyqizmj/test-invoke-stage/POST/submit, Accept=application/json, User-Agent=AmazonAPIGateway_3sczyqizmj, X-Amz-Security-Token=AgoJb3JpZ2luX2VjEK///////////wEaCXVzLXdlc3QtMSJHMEUCIGS4BNx1NHUNLpMA7DrFtGH+kWTJQeDR5GqVUAaCuV0tAiEAvzcYndz0VFYVmZBwzVHKnQ4iwJc/DGUKIZFWZOkgn4cq2gMIaBAAGgw5NjgyNDY1MTUyODEiDKAiOQkdH/UhsCMeXSq3AzFYXXcp72zKbO/bqHrXj1WNEs+TciQN4zbaK+5LycyRn9b+rTFXe9LhNzxP8FhogiMjS1jLXFV1MRoXr/7HVszX1pnREX+WI9EYC8hSxe9B1m6MA7GPMrrPRjnm5bDyjvLtGdalkqtJlJX6TpLM5jBV8eqtmoA04ByMGi1HiuIn/wUdZ9Dp0Kb [TRUNCATED]
Sun Mar 31 00:06:47 UTC 2019 : Endpoint request body after transformations:
Sun Mar 31 00:06:47 UTC 2019 : Sending request to https://lambda.us-west-1.amazonaws.com/2015-03-31/functions/arn:aws:lambda:us-west-1:931121055930:function:testWrite/invocations
Sun Mar 31 00:06:47 UTC 2019 : Received response. Status: 200, Integration latency: 298 ms
Sun Mar 31 00:06:47 UTC 2019 : Endpoint response headers: {Date=Sun, 31 Mar 2019 00:06:47 GMT, Content-Type=application/json, Content-Length=4, Connection=keep-alive, x-amzn-RequestId=7e5f6653-4ed5-42a0-a90e-4f7883b5da6c, x-amzn-Remapped-Content-Length=0, X-Amz-Executed-Version=$LATEST, X-Amzn-Trace-Id=root=1-5ca00497-731418de94afe73e4db56de8;sampled=0}
Sun Mar 31 00:06:47 UTC 2019 : Endpoint response body before transformations: null
Sun Mar 31 00:06:47 UTC 2019 : Method response body after transformations: null
Sun Mar 31 00:06:47 UTC 2019 : Method response headers: {X-Amzn-Trace-Id=Root=1-5ca00497-731418de94afe73e4db56de8;Sampled=0, Content-Type=application/json}
Sun Mar 31 00:06:47 UTC 2019 : Successfully completed execution
Sun Mar 31 00:06:47 UTC 2019 : Method completed with status: 200
Есть ли какая-нибудь подсказка, почему это не проходит?