Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Chaosfile.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"value": "true"
}
],
"stateFilter":[
"pending",
"running"
],
"slackWebhook": [
{
"channel": "#random",
Expand Down
17 changes: 15 additions & 2 deletions lambda/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,28 @@ exports.handler = function(event, context) {
console.log('Chaos Llama starting up');

if (llamaConfig.probability) {
if (randomIntFromInterval(1,100) >= llamaConfig.probability && llamaConfig.probability != 100) {
if (randomIntFromInterval(1,100) > llamaConfig.probability) {
console.log('Probability says it is not chaos time');
return context.done(null,null);
}
}

let params = {};

if(llamaConfig.stateFilter && llamaConfig.stateFilter.length > 0){
params = {
Filters: [
{
Name: 'instance-state-name',
Values: llamaConfig.stateFilter
},
]
};
}

var ec2 = new AWS.EC2();

ec2.describeInstances(function(err, data) {
ec2.describeInstances(params, function(err, data) {
if (err) {
return context.done(err, null);
}
Expand Down