3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Amazon ECS Execで"The execute command failed due to an internal error. Try again later."と言われた時の対応

Last updated at Posted at 2022-04-05

ECS Execを実行する時に以下のエラーが発生するときがある

The Session Manager plugin was installed successfully. Use the AWS CLI to start a session.


An error occurred (TargetNotConnectedException) when calling the ExecuteCommand operation: The execute command failed due to an internal error. Try again later.

まずやるべきこと : Amazon ECS Exec Checkerを使おう

以下からgit cloneしてきましょう
https://github.com/aws-containers/amazon-ecs-exec-checker

使い方などは割と簡単なので割愛します

Amazon ECS Exec Checkerで出てくる3パターン

1.ECSのタスクロールにSSM関連の権限が不足している

以下を参考にして、タスクロールを修正してみてください。

2.「読み取り専用ルートファイルシステム(Read-Only Root Filesystem)」にチェックが入っている

「タスク定義の新しいリビジョンの作成」→ 「コンテナの定義」より、以下の画像のチェックを外してください。

Screenshot from 2022-04-05 15-29-02.png

3.コンテナの定義の環境変数の中にAWS_ACCESS_KEY(AWS_ACCESS_KEY_ID) / AWS_SECRET_ACCESS_KEYが入っている

自分もココでハマりました。どうしても活用しないといけない場合は別の環境変数名に変更して見て下さい。

4.VPCエンドポイントの設定

該当のFargateがprivateサブネット上にある場合、ssmmessageへのVPCエンドポイントが設定されていること。ただ、Fargateからインターネットに繋がるような環境であれば、別段設定は不要です。
VPCエンドポイントは、基本的には同じVPC、同じサブネット上に作成していなければなりません。

5.ネットワーク(セキュリティグループ)の設定

ECS Fargateが立ち上がっているセキュリティグループと、VPCエンドポイントで設定したセキュリティグループのポートの443番が空いている必要があったはずです。
ハマりポイントとしては、VPCエンドポイントとECS側のセキュリティグループを同じにした場合。
同一セキュリティグループとはいえど、自分自身からのアクセスのインバウンドルールも追加する必要があります。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?