Reputation: 1608
I'm certain I'm doing something stupid here, or at least missing something obvious. Just running some very, very basic examples on the official AWS SDK module. I create two empty files, one within the directory of an existing larger Node.js project, one in another separate directory away from this other project. Both directories contain a node_modules directory created by NPM with, among other things, the aws-sdk module, same version in both cases, 0.9.5-pre.6.
In both empty files I put the following code:
// Include the AWS module
var AWS = require('aws-sdk');
AWS.config.update({
accessKeyId: 'OUR_SECURITY_KEY',
secretAccessKey: 'OUR_ACCESS_KEY'
});
AWS.config.update({region: 'OUR_REGION'});
// Create a Simple Queue Service instance
var sqs = new AWS.SQS();
// Retrieve a list of available queues on our account
sqs.client.listQueues(function (err, data) {
if (err) {
console.log(err);
}
else {
console.log(data);
}
});
Just a really simple bit of code to retrieve the list of queues in SQS on our account. For the record the result is the same if I create an S3 client and try to retrieve a list of S3 buckets.
When I run the file inside the other project's directory...
node testfile.js
...I see in the terminal window the response data...
{
ResponseMetadata: {
RequestId: 'SOME_REQUEST_ID'
},
QueueUrls: [ 'THE_CORRECT_URL_OF_MY_QUEUE' ]
}
...which is what I want. If I do the same with the file in the other directory I get an empty object back...
{}
This seems to be the case, or at least similar in all the different requests I've tried. If I try sendMessage to insert a message into the queue, it works in both files, but the problem file again receives an empty response object whereas the "working" file receives the usual response data.
Any thoughts on what silly thing I'm overlooking would be greatly appreciated!
Upvotes: 1
Views: 1260
Reputation: 26
just had the same issue (all requests returned {}). The problem was the XML parsing - namely xml2js. I manually replaced xml2js 0.2.5 with 0.2.4 in the aws-sdk dependencies. That solved the issue for me.
EDIT:
Updated xml2js to latest again and the issue seems to be fixed:
https://github.com/aws/aws-sdk-js/issues/69
https://github.com/Leonidas-from-XIV/node-xml2js/issues/76
Dominik
Upvotes: 1