getCredentialsForIdentity - ResourceNotFoundException - PullRequest
0 голосов
/ 06 июня 2018

Я пытаюсь создать пул идентификаторов Cognito, назначить ему роли и получить учетные данные из созданного пула идентификаторов.Но по какой-то причине не удается найти ресурс пула идентификаторов, созданный с ошибкой -

{ResourceNotFoundException: Identity 'us-east-2: 9b1d5236-c8e1-40f5-ab44-9968101c3fde' не найден.}

Мне прикреплен пример кода, и я не могу понять, что я делаю неправильно.Я огляделся безуспешно.Спасибо.

var AWS = require('aws-sdk');
var cognitoidentity = new AWS.CognitoIdentity({apiVersion: '2014-06-30'});

exports.handler = (event, context, callback) => {
    // TODO implement
    var params = {
        AllowUnauthenticatedIdentities: false, /* required */
        IdentityPoolName: 'admin_pool', /* required */
        CognitoIdentityProviders: [
            {
            ClientId: '6m1sp69cptu5e5j7ve3arknkjgm',
            ProviderName: 'cognito-idp.us-east-2.amazonaws.com/us-east-2_OAAtfnU3c3',
            ServerSideTokenCheck: false
            }
        ]
    };

    cognitoidentity.createIdentityPool(params, function(err, data) {
        if (err)
            console.log(err, err.stack); // an error occurred
        else {
            var idpid = data.IdentityPoolId;
            console.log(data);           // successful response
            let params = {
                IdentityPoolId: data.IdentityPoolId, /* required */
                Roles: { /* required */
                    'authenticated': 'arn:aws:iam::xxxxxxxxxx:role/cc_admin',
                    'unauthenticated': 'arn:aws:iam::xxxxxxxxxx:role/Cognito_admin_poolUnauth_Role'
                }
            };

            cognitoidentity.setIdentityPoolRoles(params, function(err, data) {
                if (err) console.log(err, err.stack); // an error occurred
                else {
                    console.log('retval:' + JSON.stringify(data));           // successful response

                    var params = {
                        IdentityId: idpid
                    };

                    cognitoidentity.getCredentialsForIdentity(params, function(err, data) {
                        if (err) console.log(err, err.stack); // an error occurred
                        else     console.log(data);           // successful response
                    });
                }
            });
        }
    });
};
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...