Skip to content

Instantly share code, notes, and snippets.

View rifki192's full-sized avatar

Rifki rifki192

  • Bogor, Indonesia
View GitHub Profile
@rifki192
rifki192 / ECS-Container-Autoscale.js
Created June 23, 2016 05:56 — forked from djenriquez/ECS-Container-Autoscale.js
AWS ECS Container Autoscale Lambda function: Create a CloudWatch CPU metric for high and low alarms. Create SNS topics to trigger from each alarm. Subscribe the lambda function to the SNS topics. Let magic happen.
console.log('Loading event');
//Import AWS-SDK
var AWS = require('aws-sdk');
//Fetch the assigned cpu requirements for a task definition
var fetchRequiredCPU = function(taskDefinitionData)
{
var cpu = taskDefinitionData.taskDefinition.containerDefinitions[0].cpu;
return cpu;
};