I am trying to perform a dynamodb db operation and generate a report which worked fine but some times in production, am seeing the error - CredentialsError: Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1 using identity poolid. Hence I updated the code to refresh the token as below -
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.789.0.min.js"></script>
var GetWallboardx = () => {
AWS.config.region = 'eu-west-2';
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: 'eu-west-2:xxxxxxxxxxxxxxxxx0e8',
});
//refreshes credentials using AWS.CognitoIdentity.getCredentialsForIdentity()
AWS.config.credentials.refresh(error => {
if (error) {
console.error(error);
} else {;
var docClient = new AWS.DynamoDB.DocumentClient();
}
});
docClient.scan(params, function(err, data) {
-- some db operation --
})
setTimeout(GetWallboardx,RefreshInterval)// run this every 5 seconds
}
GetWallboardx()
if I try to use this 'refresh approach' looks like am not able to access dynamo db as the error says - Error:: ResourceNotFoundException: Requested resource not found. Can any one please help me. I did not get this exception when I did not use the 'refresh' earlier like this -
var docClient;
AWS.config.region = 'eu-west-2';
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: 'eu-west-2:xxxxxxxxxxxxxxxxx0e8',
});
docClient = new AWS.DynamoDB.DocumentClient();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…