Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

188
Vistas
Rate exceeded while running stop services script Fargate

Really need help with this AWS Fargate stopping script, Im receiving an error called "Rate exceeded" "ThrottilingException", is there a way to add that my script detects the error and if it sees the error, it will pause for a little bit and continue where it was left off?

var AWS  = require("aws-sdk");
AWS.config.update({region: "eu-central-1"});

var s3 = new AWS.S3({apiVersion: '2006-03-01'});
var ecs = new AWS.ECS({apiVersion: '2014-11-13'});


 
async function getServiceArns(token) {
  var params = {
    cluster: 'my-cluster',
    launchType: "FARGATE",
    maxResults: 100,
    nextToken: '',
    schedulingStrategy: "REPLICA"
  };


  return new Promise(function(resolve) {
    var services = []
    if (token) {
      params.nextToken = token
    }
    ecs.listServices(params, async function(err, data) {
      if(data.nextToken) {
        services.push(...(await getServiceArns(data.nextToken)))
      }
      services.push(...data.serviceArns)
      resolve(services)
    });
  })
}

async function main(){

  var arns =  await getServiceArns()
  
  var services = await Promise.all(arns.map(function(arn) {
    return new Promise(function(resolve) {
      ecs.describeServices({cluster: 'my-cluster', services:[arn]}, function(err, data) {
        resolve({arn, count: data.services[0].desiredCount})
      });
    })
  }))

  var filtered = services.filter(item => item.count > 0)
  var base64data = Buffer.from(JSON.stringify(filtered), 'binary');

  await s3.putObject({
    Bucket: 'my-bucket',
    Key: 'services.txt',
    Body: base64data,
  }).promise();
  await Promise.all(filtered.map(function(service) {
    var params = {
      desiredCount: 0,
      cluster: "my-cluster",
      service: service.arn,
    };
    console.log(service.arn)
    // return ecs.updateService(params).promise()
  }))


  console.log('successfully shutdown all services')
}
exports.handler = main
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda