Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

186
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda