0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

個人的備忘録:family を忘れると ECS タスクは登録できない話

Posted at

はじめに

AWS ECSでタスク定義を登録しようとした際に、「フィールド: family は必須です」というエラーが表示され、登録ができない事象に遭遇しました。

書こうと思ったきっかけ

受講しているITスクールのハッカソンの開発の一環で、ECSのタスク定義をJSON形式で作成・登録していた際にこのエラーが発生しました。

備忘録として残しておくことで、同じミスを防ぎ、スムーズなデプロイにつなげたいと考えています。

内容

このエラーの原因は、ECSタスク定義において family フィールドが省略されていたことです。

family フィールドとは?

  • タスク定義の名前を指定する必須フィールド
  • 同一のfamily名で再登録するとリビジョンが上がる仕組み。

修正例

以下のように、containerDefinitions の外側に family フィールドを追加する必要があります:

{
  "family": "my-app-task",
  "containerDefinitions": [
    { ... }
  ],
  "taskRoleArn": "arn:aws:iam::xxxxxxxxxxxx:role/ecs-task-execution-role",
  "executionRoleArn": "arn:aws:iam::xxxxxxxxxxxx:role/ecs-task-execution-role",
  "networkMode": "awsvpc",
  "volumes": [
    {
      "name": "cws-instrumentation-volume",
      "host": {}
    }
  ],
  "requiresCompatibilities": ["FARGATE"],
  "cpu": "256",
  "memory": "512"
}

まとめ

family フィールドは見落としがちですが、ECSタスク定義には必須項目です。

これを忘れると、JSONの構造がいくら正しくても登録できず、手間がかかります。

今後はテンプレートとしてfamilyを最初に記述しておくことで、同様のミスを防いでいきたいと思います...!

0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?