livelycode/aws-lib — pull request #84 by reason-bv (2014-04-16 16:55:03+00:00)
Title: Fix issues with incorrect variable assignment of key, secret, and token obtained from Instance Metadata.

See issue https://github.com/livelycode/aws-lib/issues/83 .

When running in AWS with an instance role, setting `accessKeyId` and `secretAccessKey` to null does not result in the key, secret, and token being read correctly from the Instance Metadata service.

Or rather these values are being obtain, but they are being assigned to the variables that are then not referenced.

Here in `lib/aws.js` you are setting `securityToken`, `accessKeyId`, and `secretAccessKey` prior to the values in `obj` being reset with the values obtained from Instance Metadata.

```
var securityToken = obj.token;
var signHeader = obj.signHeader;
var host = obj.host;
var accessKeyId = obj.accessKeyId;
var path = obj.path;
var agent = obj.agent;
var secretAccessKey = obj.secretAccessKey;
var secure = obj.secure == null ? true : false;
var connection = secure ? https : http;
```

Then when you reference the scope variables later they are still null even though you have updated `obj`.

This pull request updates `lib/aws.js` to fix this issue.