hubot-aws
Version:
Hubot masters aws commands
29 lines (25 loc) • 841 B
text/coffeescript
aws = require('../../aws').aws()
ec2 = new aws.EC2()
module.exports = (robot) ->
robot.respond /ec2 release address (.*)$/i, (msg) ->
params = {}
if msg.match[1].split('.').length == 4
params.PublicIp = msg.match[1]
else if msg.match[1].match(/^eipalloc-[a-zA-Z0-9].*/i)
params.AllocationId = msg.match[1]
else
return msg.send 'I need the Public IP or allocation ID (eipalloc-xxx) to release an elastic IP.'
ec2.releaseAddress params, (err, response) ->
if(err)
msg.send err
else
msg.send "Successfully released #{msg.match[1]}"
msg.send response