Skip to content

Instantly share code, notes, and snippets.

@bobzsj87
Created January 28, 2019 20:29
Show Gist options
  • Select an option

  • Save bobzsj87/24b41d2e8d4317facc209eb39bb65d24 to your computer and use it in GitHub Desktop.

Select an option

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
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