Skip to content

Instantly share code, notes, and snippets.

@bobzsj87
Created January 9, 2020 21:06
Show Gist options
  • Select an option

  • Save bobzsj87/4d4f509b6c3b6e2021d456930e482485 to your computer and use it in GitHub Desktop.

Select an option

Save bobzsj87/4d4f509b6c3b6e2021d456930e482485 to your computer and use it in GitHub Desktop.
A quick lambda call to disable all instances' detailed monitoring. Can be scheduled with CloudWatch.
const AWS = require('aws-sdk');
const ec2 = new AWS.EC2();
exports.handler = async (event) => {
let ret = await ec2.describeInstanceStatus({}).promise();
const instances = ret.InstanceStatuses.map(a => a.InstanceId);
const param = {
InstanceIds: instances,
};
ret = await ec2.unmonitorInstances(param).promise();
console.log(JSON.stringify(ret));
return true;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment