LoginSignup
1
0

More than 5 years have passed since last update.

ECSのECSとコンテナのオートスケール

Posted at

はじめに

ECSのオートスケールで、コンテナのスケールと、コンテナが動いているEC2のスケールで、どっちがスケールするのか良く分からずでハマったので、方法をメモ的に残しておきます。

ECSのEC2のオートスケール

const AWS = require('aws-sdk');

//EC2を3台起動
const params = {
AutoScalingGroupName: "your-auto-scale-group",
MaxSize: 3,
MinSize: 3
};

const autoscaling = new AWS.AutoScaling();
autoscaling.updateAutoScalingGroup(params, function (err, data) {
  if (err) {
    console.log(err, err.stack); // an error occurred
  } else {
    console.log(data);           // successful response
  }
})
});

ECS のコンテナのオートスケール

const AWS = require('aws-sdk');
var ecs = new AWS.ECS();

// EC2上のコンテナを3つ起動
var params = {
  service: 'your-service-name',
  cluster: 'your-cluster-name',
  desiredCount: 3,
};
ecs.updateService(params, function(err, data) {
  if (err) {
    console.log(err, err.stack); // an error occurred
  } else {
     console.log(data);           // successful response
  }
});
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0