Response code 400 when trying to set scale-in protection

0

I want to to set scale-in protection as explained here via a PUT request to $ECS_AGENT_URI/task-protection/v1/state.

However, I always get the following error: Response code 400 (Bad Request) .

This is my code:

const got = require("got");

const SCALE_IN_PROTECTION_DURATION_MINUTES = 15;
const TASK_PROTECTION_URI = `${process.env.ECS_AGENT_URI}/task-protection/v1/state`;
try {
  const minutes = SCALE_IN_PROTECTION_DURATION_MINUTES;
  await got(TASK_PROTECTION_URI, {
    method: "PUT",
    json: { ProtectionEnabled: true, ExpiresInMinutes: minutes },
  });
} catch (error) {
  logger.error(error);
}

process.env.ECS_AGENT_URI is set properly and the instance agent version is 1.70.0

flo
質問済み 1年前361ビュー
1回答
0
承認された回答

The code was correct. The solution was to add the ecs:UpdateTaskProtection permission to my ECS task as described here.

flo
回答済み 1年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ