LoginSignup
3
2

More than 3 years have passed since last update.

【AWS】【Terraform】The container {container_name} did not have a container port {port_number} defined.

Posted at

状況

Fargateでnginxコンテナを起動してトップページが表示されるか確認したい

Error文 : The container test did not have a container port 80 defined.

Terraformのコード上ではportMappingは80番portで記入されており問題なし。

コンソールで実態確認

スクリーンショット 2020-07-16 11.09.27.png
ポートマッピングが反映されていない。と思ったら上のCPUユニット数も反映されていない。これか!

結論

container_definition.jsonにコンテナに割り当てる、"cpu", "memory"の記述がなかった。

Fargateでは必須の模様
スクリーンショット 2020-07-16 11.31.04.png

公式リファレンス AWS:ECS:TaskDefinition


container_definitions/service.json

[
  {
    "name": "nginx",
    "image": "nginx:latest",
    "cpu": 256, # 追加
    "memory": 512, # 追加
    "essential": true,
    "network_mode": "awsvpc",
    "portMappings": [
      {
        "containerPort": 80,
        "protocol": "tcp"
      }
    ]
  }
]

反映されましたね
スクリーンショット 2020-07-16 11.36.04.png

3
2
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
3
2