Created
January 28, 2019 20:29
-
-
Save bobzsj87/24b41d2e8d4317facc209eb39bb65d24 to your computer and use it in GitHub Desktop.
simple lambda to update all container instances, could be triggered by cloudwatch rules
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 ecs = new AWS.ECS(); | |
| exports.handler = async (event) => { | |
| const clusters = ['your-cluster-name']; | |
| for (let cluster of clusters){ | |
| const data = await ecs.listContainerInstances({cluster}).promise(); | |
| for (let cid of data.containerInstanceArns){ | |
| let result = await ecs.updateContainerAgent({cluster, containerInstance: cid}).promise(); | |
| console.log(result); | |
| } | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment