Created
January 9, 2020 21:06
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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