Динамо DB Access проблема AWS лямбда - PullRequest
0 голосов
/ 08 февраля 2020

Динамо DB Функция:

function putInDB(u_id,h_id){
   var params = {
            TableName:"Nucleus_id",
            Item:{
                "user_id": u_id,
                "hub_id":h_id,
            }
        };
        console.log("Updating the item...");
       docClient.put(params)
        // docClient.put(params, function(err, data) {
        // if (err) {
        //     console.log(err);
        //     //return callback(null,{"ERROR_ID":"9","SUCCESS":"false"});
        // } else {
        //   // return callback(null,{"SUCCESS":"true","message":params});
        // }
        // });

}

Намерение:

const AddHubID_Handler =  {
canHandle(handlerInput) {
    const request = handlerInput.requestEnvelope.request;
    return request.type === 'IntentRequest' && request.intent.name === 'AddHubID' ;
},
handle(handlerInput) {
    const request = handlerInput.requestEnvelope.request;
    const responseBuilder = handlerInput.responseBuilder;
    let sessionAttributes = handlerInput.attributesManager.getSessionAttributes();

    let say = 'Hello from AddHubID. ';

    let slotStatus = '';
    let resolvedSlot;

    let slotValues = getSlotValues(request.intent.slots); 
    // getSlotValues returns .heardAs, .resolved, and .isValidated for each slot, according to request slot status codes ER_SUCCESS_MATCH, ER_SUCCESS_NO_MATCH, or traditional simple request slot without resolutions

    // console.log('***** slotValues: ' +  JSON.stringify(slotValues, null, 2));
    //   SLOT: id 

    var params={}
    if (slotValues && slotValues.id){
        putInDB( handlerInput.requestEnvelope.context.System.user.userId,slotValues.id.heardAs)


    say="your hub id is "+slotValues.id.heardAs + " has been saved ";
    }


    return responseBuilder
        .speak(say)
        .reprompt('try again, ' + say)
        .getResponse();
},

};

Привет, ребята. Нуб здесь. Я создаю навык alexa и использую AWS lambda Node.js Я получаю сообщение об ошибке «Отказано в доступе» для docClient.put (params). Я добавил следующие правила: введите описание изображения здесь

Я уверен, что что-то не так с тем, как я вызываю функцию. Пожалуйста помоги.

...