Skip to content

Commit

Permalink
Prepping demo.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Puch authored and Andrew Puch committed May 1, 2016
1 parent cd4e000 commit 8427e84
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ npm install && npm update
**Copy external-scripts.json from github***
**Copy describe-instance.js from github into scripts**
**Copy i-love-you.js from github into scripts**
**Copy config-sample.json from github to config.json**
HUBOT_ADAPTER=slack HUBOT_SLACK_TOKEN=[TOKEN] bin/hubot
```
32 changes: 25 additions & 7 deletions describe-instance.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,34 @@
// Commands:
// hubot describe instance [instance_id] - Shows instance details.

var promise = require('bluebird'),
aws = require('aws-sdk');
ec2 = new aws.Ec2();
var config = require(__dirname + '/../config.json'),
promise = require('bluebird'),
aws = require('aws-sdk'),
ec2 = new aws.EC2(config);

module.exports = function(robot) {
robot.respond(/describe instance ([-\a-zA-Z0-9]+)/i, function(msg) {
msg.send("```Instance is being described.```");
});
var instance = msg.match[1].toLowerCase(),
message = "";

return new promise(function(resolve, reject) {
ec2.describeInstances({ InstanceIds : [ instance ] }, function(err, instance) {
if(err) {
reject(err);
}

resolve(instance);
});
}).then(function(instance) {
instance = instance.Reservations[0].Instances[0];

message = message + instance.InstanceType + "\n";
message = message + instance.PublicIpAddress + "\n";
message = message + instance.PrivateIpAddress + "\n";

robot.respond(/i love you/i, function(msg) {
msg.send("```asdfasdfsdft.```");
msg.send("```" + message + "```");
}).catch(function(e) {
msg.send("```" + e + "```");
});
});
};

0 comments on commit 8427e84

Please sign in to comment.