困っていた内容
Fargate 起動タイプで ECS タスクを実行しています。
ECS サービスのロードバランサー設定を変更するため、AWS CLI のupdate-serviceコマンドを実行しましたがInvalidParameterException
というエラーが表示されます。どうしたら良いでしょうか。
$ aws ecs update-service \
--cluster hato-ecs-cluster \
--service hato-ecs-service \
--load-balancers targetGroupArn=arn:aws:elasticloadbalancing:ap-northeast-1:123456789012:targetgroup/hato-targetgroup/1234567890123456,containerName=hato-container,containerPort=80
An error occurred (InvalidParameterException) when calling the UpdateService operation: The provided target group arn:aws:elasticloadbalancing:ap-northeast-1:123456789012:targetgroup/hato-targetgroup/1234567890123456 has target type
instance, which is incompatible with the awsvpc network mode specified in the task definition.
どう対応すればいいの?
ターゲットグループの「ターゲットの種類」を確認してください。
Fargate 起動タイプの場合、ネットワークモードはawsvpc
です。awsvpc ネットワークモードのタスクを含む ECS サービスは、ターゲットグループの種類にip
を指定する必要があり、instance
を指定したターゲットグループの設定はInvalidParameterException
となります。
現時点でターゲットグループの種類は、ターゲットグループ作成時にのみ指定可能なため、ターゲットグループを作り直すか、既存のip
のターゲットグループを指定してください。
※ AWS マネジメントコンソールで指定する場合の例
参考資料
awsvpc ネットワークモードを使用するタスクを含むサービスの場合、サービスのターゲットグループを作成するときに、instance ではなく、ip をターゲットタイプとして選択する必要があります 。
Fargate を使用する場合、awsvpcネットワークモードが必要です。
ターゲットグループを作成した後で、ターゲットの種類を変更することはできません。
ターゲットグループを作成した後で、ターゲットタイプを変更することはできません。