Skip to content

Commit

Permalink
checkCredentials should not continue when encountering errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mirkokiefer committed Dec 19, 2012
1 parent 7f3fb12 commit bab5e4d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/aws.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ function checkCredentials(obj, cb) {
if (obj.secretAccessKey == null || obj.accessKeyId == null || lapse > 0) {
var md = metadata.init();
md().call({endpoint: 'iam/security-credentials/'}, function(err, res) {
if (err) cb(err);
if (typeof res === 'undefined') cb(new Error('metadata API response undefined'));
if (err) return cb(err);
if (typeof res === 'undefined') return cb(new Error('metadata API response undefined'));
md().call({endpoint: 'iam/security-credentials/' + res.split('\n')[0]},
function(err, res) {
try {
res = JSON.parse(res);
} catch(e) {
cb(e);
return cb(e);
}
if (res.SecretAccessKey === null)
cb(new Error("secretAccessKey and accessKeyId not provided and could not be determined."));
return cb(new Error("secretAccessKey and accessKeyId not provided and could not be determined."));
obj.secretAccessKey = res.SecretAccessKey;
obj.accessKeyId = res.AccessKeyId;
obj.token = res.Token;
Expand Down

0 comments on commit bab5e4d

Please sign in to comment.